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 all 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
2 changes: 1 addition & 1 deletion packages/main/src/ListItemBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import draggableElementStyles from "./generated/themes/DraggableElement.css.js";
@event("_forward-before")
class ListItemBase extends UI5Element implements ITabbable {
/**
* Defines the selected state of the `ListItem`.
* Defines the selected state of the component.
* @default false
* @public
*/
Expand Down
151 changes: 112 additions & 39 deletions packages/main/src/Option.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
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 event from "@ui5/webcomponents-base/dist/decorators/event.js";
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
import type { IOption } from "./Select.js";
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";

import StandardListItem from "./StandardListItem.js";
import ListItemType from "./types/ListItemType.js";
import { IButton } from "./Button.js";
import type { ListItemAccessibilityAttributes as OptionAccessibilityAttributes } from "./ListItem.js";
import HighlightTypes from "./types/HighlightTypes.js";
import { IOption } from "./Select.js";

/**
* @class
*
Expand All @@ -14,80 +22,145 @@ import type { IOption } from "./Select.js";
*
* `import "@ui5/webcomponents/dist/Option.js";`
* @constructor
* @extends UI5Element
* @implements {IOption}
* @extends StandardListItem
* @public
*/
@customElement({
tag: "ui5-option",
})
/**
* **Note:** The event is inherited and not supported. If used, it won't take any effect.
* @public
* @abstract
* @deprecated
*/
@customElement("ui5-option")
class Option extends UI5Element implements IOption {
@event("detail-click")
class Option extends StandardListItem implements IOption {
/**
* Defines the selected state of the component.
* @default false
* Defines the text of the component.
*
* **Note:** Although this slot accepts HTML Elements, it is strongly recommended that you only use text in order to preserve the intended design.
* @public
*/
@property({ type: Boolean })
selected!: boolean;
@slot({ type: Node, "default": true, invalidateOnChildChange: true })
text!: Array<Node>;

/**
* Defines the text of the tooltip that would be displayed for the option component.
* 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
* @since 2.0.0
*/
@property()
tooltip!: string;
value!: string;

/**
* 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
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default "Active"
* @public
* @deprecated
*/
@property({ defaultValue: null })
icon?: string | null;
@property({ type: ListItemType, defaultValue: ListItemType.Active })
declare type: `${ListItemType}`;

/**
* 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`.
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default {}
* @public
* @deprecated
*/
@property({ type: Object })
declare accessibilityAttributes: OptionAccessibilityAttributes;

/**
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default false
* @public
* @deprecated
*/
@property({ type: Boolean })
declare navigated: boolean;

/**
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default "None"
* @public
* @deprecated
*/
@property({ type: HighlightTypes, defaultValue: HighlightTypes.None })
declare highlight: `${HighlightTypes}`;

/**
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default "None"
* @public
* @deprecated
*/
@property({ type: ValueState, defaultValue: ValueState.None })
declare additionalTextState: `${ValueState}`;

/**
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default ""
* @public
* @deprecated
*/
@property()
value!: string;
declare description: string;

/**
* Defines the additional text displayed at the end of the option element.
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default false
* @public
* @deprecated
*/
@property({ type: Boolean })
declare iconEnd: boolean;

/**
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default ""
* @public
* @since 1.3.0
* @deprecated
*/
@property()
additionalText!: string;
declare image: string;

/**
* Defines the focused state of the component.
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default false
* @since 1.0.0-rc.13
* @private
* @public
* @deprecated
*/
@property({ type: Boolean })
focused!: boolean;
declare movable: boolean;

/**
* Defines the text of the component.
*
* **Note:** Although this slot accepts HTML Elements, it is strongly recommended that you only use text in order to preserve the intended design.
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default ""
* @public
* @deprecated
*/
@slot({ type: Node, "default": true, invalidateOnChildChange: true })
text!: Array<Node>;
@property()
declare accessibleName: string;

/**
* **Note:** The slot is inherited and not supported. If set, it won't take any effect.
* @public
* @deprecated
*/
@slot()
declare deleteButton: Array<IButton>;

/**
* **Note:** The slot is inherited and not supported. If set, it won't take any effect.
* @public
* @deprecated
*/
@slot()
declare imageContent: Array<HTMLElement>;

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

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

import CustomListItem from "./CustomListItem.js";
import { IButton } from "./Button.js";
import ListItemType from "./types/ListItemType.js";
import type { ListItemAccessibilityAttributes as CustomOptionAccessibilityAttributes } from "./ListItem.js";
import HighlightTypes from "./types/HighlightTypes.js";
import { IOption } from "./Select.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 CustomListItem
* @public
*/
@customElement({
tag: "ui5-option-custom",
})
/**
* **Note:** The event is inherited and not supported. If used, it won't take any effect.
* @public
* @deprecated
*/
@event("detail-click")
class OptionCustom extends CustomListItem implements IOption {
/**
* Defines the text, displayed inside the `ui5-select` input filed
* when the option gets selected.
* @default ""
* @public
*/
@property()
displayText!: 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;

/**
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default false
* @public
* @deprecated
*/
@property({ type: Boolean })
declare iconEnd: boolean;

/**
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default "Active"
* @public
* @deprecated
*/
@property({ type: ListItemType, defaultValue: ListItemType.Active })
declare type: `${ListItemType}`;

/**
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default {}
* @public
* @deprecated
*/
@property({ type: Object })
declare accessibilityAttributes: CustomOptionAccessibilityAttributes;

/**
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default false
* @public
* @deprecated
*/
@property({ type: Boolean })
declare navigated: boolean;

/**
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default "None"
* @public
* @deprecated
*/
@property({ type: HighlightTypes, defaultValue: HighlightTypes.None })
declare highlight: `${HighlightTypes}`;

/**
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default false
* @public
* @deprecated
*/
@property({ type: Boolean })
declare movable: boolean;

/**
* **Note:** The property is inherited and not supported. If set, it won't take any effect.
* @default ""
* @public
* @deprecated
*/
@property()
declare accessibleName: string;

/**
* **Note:** The slot is inherited and not supported. If set, it won't take any effect.
* @public
* @deprecated
*/
@slot()
declare deleteButton: Array<IButton>;

/**
* Defines the text of the component.
*
* **Note:** Although this slot accepts HTML Elements, it is strongly recommended that you only use text in order to preserve the intended design.
* @public
*/
@slot({ type: Node, "default": true, invalidateOnChildChange: true })
content!: Array<Node>;

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