Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ui5-option): make options physical elements #8903

Merged
merged 32 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9c0f58f
refactor(ui5-option): make options physical elements
dobrinyonkov May 7, 2024
bb2821e
refactor(ui5-option): rename menu wording to custom
dobrinyonkov May 7, 2024
261e420
fix: jsdocs
dobrinyonkov May 7, 2024
5195bfa
fix: restore displayText property
dobrinyonkov May 7, 2024
eb85099
fix: missing tooltip
dobrinyonkov May 7, 2024
8b96b2e
fix: storybook samples
dobrinyonkov May 8, 2024
c892a07
fix: reuse padding via css var
dobrinyonkov May 8, 2024
af7bed7
fix: documentation of Option and CustomOption
dobrinyonkov May 8, 2024
1afba5d
fix: API types
dobrinyonkov May 8, 2024
2801e2d
fix: reuse padding via css var v3
dobrinyonkov May 8, 2024
6884266
fix: address comments in select
dobrinyonkov May 8, 2024
306c4d5
fix: use declarative open proeprty on popups
dobrinyonkov May 8, 2024
ee8a253
Merge remote-tracking branch 'origin/main' into ui5-option-physical
dobrinyonkov May 8, 2024
16e1dd4
chore: select ts cleanup
dobrinyonkov May 8, 2024
85371a0
Merge remote-tracking branch 'origin/main' into ui5-option-physical
dobrinyonkov May 13, 2024
c7e2dcb
refactor: option and custom option now exented list items
dobrinyonkov May 15, 2024
690b1ca
Merge remote-tracking branch 'origin/main' into ui5-option-physical
dobrinyonkov May 15, 2024
f65c1e4
chore: clean changes
dobrinyonkov May 15, 2024
7516d6b
Merge remote-tracking branch 'origin/main' into ui5-option-physical
dobrinyonkov May 15, 2024
9307d7c
chore: clean changes
dobrinyonkov May 15, 2024
4f403fc
test: stabilize test
dobrinyonkov May 15, 2024
154370d
fix: form formatted value
dobrinyonkov May 16, 2024
4f49349
chore: clear noise
dobrinyonkov May 16, 2024
061505b
chore: reorder types
dobrinyonkov May 16, 2024
6eac3b4
chore: more noise modifications clear
dobrinyonkov May 16, 2024
d50306e
Merge remote-tracking branch 'origin/main' into ui5-option-physical
dobrinyonkov May 17, 2024
999cf6f
Merge remote-tracking branch 'origin/main' into ui5-option-physical
dobrinyonkov May 20, 2024
7f81669
chore: remove select menu related file
dobrinyonkov May 20, 2024
fb28d58
Merge remote-tracking branch 'origin/main' into ui5-option-physical
dobrinyonkov May 20, 2024
d7ff647
fix: unsupported properties and jsdocs
dobrinyonkov May 20, 2024
b555522
Merge remote-tracking branch 'origin/main' into ui5-option-physical
dobrinyonkov May 20, 2024
ee6ad6f
chore: remove story file
dobrinyonkov May 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 9 additions & 47 deletions packages/main/src/Option.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
import type { IOption } from "./Select.js";

import OptionBase from "./OptionBase.js";

/**
* @class
*
Expand All @@ -14,50 +15,24 @@ import type { IOption } from "./Select.js";
*
* `import "@ui5/webcomponents/dist/Option.js";`
* @constructor
* @extends UI5Element
* @implements {IOption}
* @extends OptionBase
* @public
* @abstract
*/
@customElement("ui5-option")
class Option extends UI5Element implements IOption {
/**
* Defines the selected state of the component.
* @default false
* @public
*/
@property({ type: Boolean })
selected!: boolean;

/**
* Defines the text of the tooltip that would be displayed for the option component.
* @default ""
* @public
* @since 2.0.0
*/
@property()
tooltip!: string;

@customElement({
tag: "ui5-option",
})
class Option extends OptionBase {
/**
* Defines the `icon` source URI.
*
* **Note:**
* SAP-icons font provides numerous built-in icons. To find all the available icons, see the
* [Icon Explorer](https://sdk.openui5.org/test-resources/sap/m/demokit/iconExplorer/webapp/index.html).
* @default null
* @public
*/
@property({ defaultValue: null })
icon?: string | null;

/**
* Defines the value of the `ui5-select` inside an HTML Form element when this component is selected.
* For more information on HTML Form support, see the `name` property of `ui5-select`.
* @default ""
* @public
*/
@property()
value!: string;
icon!: string;

/**
* Defines the additional text displayed at the end of the option element.
Expand All @@ -68,15 +43,6 @@ class Option extends UI5Element implements IOption {
@property()
additionalText!: string;

/**
* Defines the focused state of the component.
* @default false
* @since 1.0.0-rc.13
* @private
*/
@property({ type: Boolean })
focused!: boolean;

/**
* Defines the text of the component.
*
Expand All @@ -85,10 +51,6 @@ class Option extends UI5Element implements IOption {
*/
@slot({ type: Node, "default": true, invalidateOnChildChange: true })
text!: Array<Node>;

get stableDomRef() {
return this.getAttribute("stable-dom-ref") || `${this._id}-stable-dom-ref`;
}
}

Option.define();
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/OptionBase.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<slot></slot>
75 changes: 75 additions & 0 deletions packages/main/src/OptionBase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import property from "@ui5/webcomponents-base/dist/decorators/property.js";

import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";

import OptionBaseTemplate from "./generated/templates/OptionBaseTemplate.lit.js";

/**
* @class
*
* ### Overview
*
* The base of the `ui5-option` and `ui5-option-custom` components defines the content of an option in the `ui5-select`.
*
* ### ES6 Module Import
*
* @constructor
* @extends UI5Element
* @public
*/
@customElement({
template: OptionBaseTemplate,
renderer: litRender,
})
class OptionBase extends UI5Element {
/**
* Defines the selected state of the component.
* @default false
* @public
*/
@property({ type: Boolean })
selected!: boolean;

/**
* Defines the text of the tooltip that would be displayed for the option component.
* @default ""
* @public
* @since 2.0.0
*/
@property()
tooltip!: string;

/**
* Defines the value of the `ui5-select` inside an HTML Form element when this component is selected.
* For more information on HTML Form support, see the `name` property of `ui5-select`.
* @default ""
* @public
*/
@property()
value!: string;

/**
* Defines the focused state of the component.
* @default false
* @since 1.0.0-rc.13
* @private
*/
@property({ type: Boolean })
focused!: boolean;

get stableDomRef() {
return this.getAttribute("stable-dom-ref") || `${this._id}-stable-dom-ref`;
}

get isCustom() {
return false;
}

get effectiveDisplayText() {
return this.textContent || "";
}
}

export default OptionBase;
59 changes: 59 additions & 0 deletions packages/main/src/OptionCustom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
import property from "@ui5/webcomponents-base/dist/decorators/property.js";

import OptionBase from "./OptionBase.js";
import optionCustomCss from "./generated/themes/OptionCustom.css.js";

/**
* @class
*
* ### Overview
*
* The `ui5-option-custom` component defines a custom content of an option in the `ui5-select`.
* A component to be the same way as the standard `ui5-option`.
* The component accepts arbitrary HTML content to allow full customization.
*
* ### ES6 Module Import
*
* `import "@ui5/webcomponents/dist/OptionCustom.js";`
* @constructor
* @since 2.0.0
* @extends OptionBase
* @public
*/
@customElement({
tag: "ui5-option-custom",
styles: [
optionCustomCss,
],
})
class OptionCustom extends OptionBase {
/**
* Defines the text, displayed inside the `ui5-select` input filed
* when the option gets selected.
* @default ""
* @public
*/
@property()
displayText!: string;

/**
* Defines the content of the component.
* @public
*/
@slot({ type: HTMLElement, "default": true })
content!: Array<HTMLElement>;

get isCustom() {
return true;
}

get effectiveDisplayText() {
return this.displayText || this.textContent || "";
}
}

OptionCustom.define();

export default OptionCustom;
2 changes: 1 addition & 1 deletion packages/main/src/Select.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{{#if hasCustomLabel}}
<slot name="label"></slot>
{{else}}
{{_text}}
{{text}}
{{/if}}
</div>

Expand Down
Loading