@limetech/lime-elements 38.19.6 → 38.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/cjs/lime-elements.cjs.js +1 -1
- package/dist/cjs/{limel-breadcrumbs_8.cjs.entry.js → limel-breadcrumbs_7.cjs.entry.js} +3 -37
- package/dist/cjs/limel-breadcrumbs_7.cjs.entry.js.map +1 -0
- package/dist/cjs/limel-card.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/limel-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-chip_2.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-dynamic-label_3.cjs.entry.js +125 -0
- package/dist/cjs/limel-dynamic-label_3.cjs.entry.js.map +1 -0
- package/dist/cjs/limel-grid.cjs.entry.js +3 -0
- package/dist/cjs/limel-grid.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-slider.cjs.entry.js +24 -7
- package/dist/cjs/limel-slider.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-switch.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/card/card.js +0 -1
- package/dist/collection/components/card/card.js.map +1 -1
- package/dist/collection/components/checkbox/checkbox.css +0 -1
- package/dist/collection/components/checkbox/checkbox.js +1 -4
- package/dist/collection/components/checkbox/checkbox.js.map +1 -1
- package/dist/collection/components/chip/chip.js +1 -4
- package/dist/collection/components/chip/chip.js.map +1 -1
- package/dist/collection/components/chip-set/chip.types.js.map +1 -1
- package/dist/collection/components/dynamic-label/dynamic-label.js +0 -1
- package/dist/collection/components/dynamic-label/dynamic-label.js.map +1 -1
- package/dist/collection/components/dynamic-label/label.types.js.map +1 -1
- package/dist/collection/components/grid/grid.js +7 -4
- package/dist/collection/components/grid/grid.js.map +1 -1
- package/dist/collection/components/list/list.css +0 -2
- package/dist/collection/components/menu-list/menu-list.css +0 -2
- package/dist/collection/components/slider/slider.css +12 -112
- package/dist/collection/components/slider/slider.js +59 -6
- package/dist/collection/components/slider/slider.js.map +1 -1
- package/dist/collection/components/switch/switch.js +1 -4
- package/dist/collection/components/switch/switch.js.map +1 -1
- package/dist/esm/lime-elements.js +1 -1
- package/dist/esm/{limel-breadcrumbs_8.entry.js → limel-breadcrumbs_7.entry.js} +4 -37
- package/dist/esm/limel-breadcrumbs_7.entry.js.map +1 -0
- package/dist/esm/limel-card.entry.js.map +1 -1
- package/dist/esm/limel-checkbox.entry.js +1 -1
- package/dist/esm/limel-checkbox.entry.js.map +1 -1
- package/dist/esm/limel-chip_2.entry.js.map +1 -1
- package/dist/esm/limel-dynamic-label_3.entry.js +119 -0
- package/dist/esm/limel-dynamic-label_3.entry.js.map +1 -0
- package/dist/esm/limel-grid.entry.js +3 -0
- package/dist/esm/limel-grid.entry.js.map +1 -1
- package/dist/esm/limel-slider.entry.js +24 -7
- package/dist/esm/limel-slider.entry.js.map +1 -1
- package/dist/esm/limel-switch.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/lime-elements.esm.js.map +1 -1
- package/dist/lime-elements/p-0d247b83.entry.js +2 -0
- package/dist/lime-elements/p-0d247b83.entry.js.map +1 -0
- package/dist/lime-elements/p-27645eef.entry.js.map +1 -1
- package/dist/lime-elements/p-6c08122b.entry.js.map +1 -1
- package/dist/lime-elements/p-6fbb2a69.entry.js.map +1 -1
- package/dist/lime-elements/p-877f91b1.entry.js +2 -0
- package/dist/lime-elements/p-877f91b1.entry.js.map +1 -0
- package/dist/lime-elements/p-aa51b1af.entry.js +90 -0
- package/dist/lime-elements/p-aa51b1af.entry.js.map +1 -0
- package/dist/lime-elements/p-f0da36cf.entry.js +266 -0
- package/dist/lime-elements/p-f0da36cf.entry.js.map +1 -0
- package/dist/lime-elements/p-f8fc7d89.entry.js +134 -0
- package/dist/lime-elements/{p-4044f10d.entry.js.map → p-f8fc7d89.entry.js.map} +1 -1
- package/dist/types/components/card/card.d.ts +0 -1
- package/dist/types/components/checkbox/checkbox.d.ts +0 -1
- package/dist/types/components/chip/chip.d.ts +0 -1
- package/dist/types/components/chip-set/chip.types.d.ts +1 -2
- package/dist/types/components/dynamic-label/dynamic-label.d.ts +0 -1
- package/dist/types/components/dynamic-label/label.types.d.ts +4 -1
- package/dist/types/components/grid/grid.d.ts +5 -4
- package/dist/types/components/slider/slider.d.ts +13 -0
- package/dist/types/components/switch/switch.d.ts +0 -1
- package/dist/types/components.d.ts +32 -30
- package/package.json +1 -1
- package/dist/cjs/limel-breadcrumbs_8.cjs.entry.js.map +0 -1
- package/dist/cjs/limel-dynamic-label_2.cjs.entry.js +0 -91
- package/dist/cjs/limel-dynamic-label_2.cjs.entry.js.map +0 -1
- package/dist/esm/limel-breadcrumbs_8.entry.js.map +0 -1
- package/dist/esm/limel-dynamic-label_2.entry.js +0 -86
- package/dist/esm/limel-dynamic-label_2.entry.js.map +0 -1
- package/dist/lime-elements/p-0ffd5100.entry.js +0 -2
- package/dist/lime-elements/p-0ffd5100.entry.js.map +0 -1
- package/dist/lime-elements/p-2a70fa06.entry.js +0 -266
- package/dist/lime-elements/p-2a70fa06.entry.js.map +0 -1
- package/dist/lime-elements/p-4044f10d.entry.js +0 -134
- package/dist/lime-elements/p-550e1ea9.entry.js +0 -90
- package/dist/lime-elements/p-550e1ea9.entry.js.map +0 -1
- package/dist/lime-elements/p-69b6119b.entry.js +0 -2
- package/dist/lime-elements/p-69b6119b.entry.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.js","sourceRoot":"","sources":["../../../src/components/chip/chip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,OAAO,EACP,KAAK,EAEL,CAAC,EACD,IAAI,EACJ,IAAI,GACP,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;A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CAAC;EAEO,iBAAiB;IACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;MAChB,OAAO;KACV;IAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;IAE9C,OAAO,CACH,WACI,IAAI,EAAC,aAAa,gBACP,GAAG,mBACA,GAAG,mBACH,KAAK,mBACJ,IAAI,CAAC,QAAQ,EAC5B,KAAK,EAAE;QACH,kCAAkC,EAAE,iBAAiB;OACxD,GACH,CACL,CAAC;EACN,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBJ","sourcesContent":["import {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Host,\n Prop,\n} from '@stencil/core';\nimport { Icon } from '../../global/shared-types/icon.types';\nimport { Languages } from '../date-picker/date.types';\nimport { Link } from '../../global/shared-types/link.types';\nimport { getRel } from '../../util/link-helper';\nimport { getIconName } from '../icon/get-icon-props';\nimport {\n makeEnterClickable,\n removeEnterClickable,\n} from '../../util/make-enter-clickable';\nimport translate from '../../global/translations';\nimport { BACKSPACE, DELETE } from '../../util/keycodes';\nimport { ChipType, Chip as OldChipInterface } from '../chip-set/chip.types';\nimport { Image } from '../../global/shared-types/image.types';\nimport { isEmpty } from 'lodash-es';\n\nimport { ListSeparator } from '../list/list-item.types';\nimport { LimelMenuCustomEvent, MenuItem } from '../../components';\n\ninterface ChipInterface extends Omit<OldChipInterface, 'id' | 'badge'> {\n /**\n * Identifier for the chip. Must be unique.\n */\n identifier?: number | string;\n\n /**\n * The value of the badge.\n */\n badge?: string | number;\n}\n\n/**\n * Chips and buttons are both interactive elements in UI design,\n * but they serve different purposes and are used in different contexts.\n *\n * :::warning\n * Do not use the chip component carelessly, as an alternative for\n * [`limel-button`](#/component/limel-button/) in the UI design!\n *\n * **Buttons:**\n * Buttons are used to trigger actions. They are typically used to\n * submit forms, open dialogs, initiate a process, or perform any action\n * that changes the state of the application.\n * Buttons' labels usually contain action words, in other words, the labels is\n * a _verb in imperative mood_ such as \"Submit\" or \"Delete\".\n * Buttons are placed in areas where it's clear they will initiate\n * an action when clicked.\n *\n * **Chips:**\n * Chips however are elements which may look like buttons, but they are\n * representing choices, filters, or tags, in a small block\n * or clearly bundled into a group. Chips are rarely used alone in the\n * user interface.\n * They are often used in a so called \"chip-set\", or placed together in\n * a section of the UI, where the user can expect more than one chip to be present.\n *\n * For example, a chip may represent a filter in a filter bar, or a tag in a tag list,\n * or an item in a shopping list.\n * Clicking a chip can also trigger an action, for example toggling a filter ON or OFF,\n * or opening a page with all posts tagged with the tag represented by the chip,\n * or navigating to a page with more information about the item in the shopping list.\n * :::\n *\n * @exampleComponent limel-example-chip-button\n * @exampleComponent limel-example-chip-link\n * @exampleComponent limel-example-chip-icon-colors\n * @exampleComponent limel-example-chip-image\n * @exampleComponent limel-example-chip-badge\n * @exampleComponent limel-example-chip-filter\n * @exampleComponent limel-example-chip-removable\n * @exampleComponent limel-example-chip-menu\n * @exampleComponent limel-example-chip-loading\n * @exampleComponent limel-example-chip-progress\n * @exampleComponent limel-example-chip-size\n * @exampleComponent limel-example-chip-readonly-border\n * @exampleComponent limel-example-chip-aria-role\n */\n@Component({\n tag: 'limel-chip',\n shadow: { delegatesFocus: true },\n styleUrl: 'chip.scss',\n})\nexport class Chip implements ChipInterface {\n /**\n * Defines the language for translations.\n * Will translate the translatable strings on the components.\n */\n @Prop({ reflect: true })\n public language: Languages = 'en';\n\n /**\n * Label displayed on the chip\n */\n @Prop({ reflect: true })\n public text: string;\n\n /**\n * Icon of the chip.\n */\n @Prop()\n public icon?: string | Icon;\n\n /**\n * A picture to be displayed instead of the icon on the chip.\n */\n @Prop()\n public image?: Image;\n\n /**\n * If supplied, the chip will become a clickable link.\n */\n @Prop()\n public link?: Omit<Link, 'text'>;\n\n /**\n * The value of the badge, displayed on the chip.\n */\n @Prop({ reflect: true })\n public badge?: string | number;\n\n /**\n * Set to `true` to disable the chip.\n */\n @Prop({ reflect: true })\n public disabled = false;\n\n /**\n * Set to `true` to render the chip as a static UI element.\n * Useful when the parent component has a `readonly` state.\n */\n @Prop({ reflect: true })\n public readonly = false;\n\n /**\n * Set to `true` to visualize the chip in a \"selected\" state.\n * This is typically used when the chip is used in a chip-set\n * along with other chips.\n */\n @Prop({ reflect: true })\n public selected = false;\n\n /**\n * Set to `true` to visualize the chip in an \"invalid\" or \"error\" state.\n */\n @Prop({ reflect: true })\n public invalid = false;\n\n /**\n * Set to `true` to render a remove button on the chip.\n */\n @Prop({ reflect: true })\n public removable = false;\n\n /**\n * Set to `filter` to render the chip with a distinct style\n * suitable for visualizing filters.\n *\n * @beta\n */\n @Prop({ reflect: true })\n public type?: ChipType = 'default';\n\n /**\n * Set to `true` to put the component in the `loading` state,\n * and render an indeterminate progress indicator inside the chip.\n * This does _not_ disable the interactivity of the chip!\n */\n @Prop({ reflect: true })\n public loading? = false;\n\n /**\n * Reflects the current value of a progress bar on the chip,\n * visualizing the percentage of an ongoing process.\n * Must be a number between `0` and `100`.\n */\n @Prop({ reflect: true })\n public progress?: number;\n\n /**\n * Identifier for the chip. Must be unique.\n */\n @Prop({ reflect: true })\n public identifier?: number | string = crypto.randomUUID();\n\n /**\n * Defines the size of the chip.\n */\n @Prop({ reflect: true })\n public size: 'small' | 'default' = 'default';\n\n /**\n * When provided, the chip will render an ellipsis menu with the supplied items.\n * Also, this will hide the \"remove button\" when `removable={true}`, as\n * the remove button will automatically become the last item in the menu.\n */\n @Prop()\n public menuItems?: Array<MenuItem | ListSeparator> = [];\n\n /**\n * Fired when clicking on the remove button of a `removable` chip.\n * The value of `identifier` is emitted as the event detail.\n */\n @Event()\n public remove: EventEmitter<number | string>;\n\n /**\n * Emitted when a menu item is selected from the actions menu.\n */\n @Event()\n public menuItemSelected: EventEmitter<MenuItem>;\n\n @Element()\n private host: HTMLLimelChipElement;\n\n public componentWillLoad() {\n makeEnterClickable(this.host);\n }\n\n public disconnectedCallback() {\n removeEnterClickable(this.host);\n }\n\n public render() {\n return (\n <Host onClick={this.filterClickWhenDisabled}>\n {this.link ? this.renderAsLink() : this.renderAsButton()}\n </Host>\n );\n }\n\n private renderAsButton = () => {\n return [\n <button\n id={'chip-' + this.identifier}\n class=\"chip\"\n role=\"button\"\n disabled={this.disabled || this.readonly}\n aria-busy={this.loading ? 'true' : 'false'}\n aria-live=\"polite\"\n onKeyDown={this.handleDeleteKeyDown}\n >\n {this.renderSpinner()}\n {this.renderPicture()}\n {this.renderLabel()}\n {this.renderBadge()}\n {this.renderProgressBar()}\n </button>,\n this.renderRemoveButton(),\n this.renderActionsMenu(),\n ];\n };\n\n private renderAsLink = () => {\n const rel = getRel(this.link?.target, this.link?.rel);\n\n return [\n <a\n id={'chip-' + this.identifier}\n class=\"chip\"\n href={this.link.href}\n title={this.link.title}\n target={this.link.target}\n rel={rel}\n aria-disabled={this.disabled || this.readonly}\n tabindex={this.disabled || this.readonly ? -1 : 0}\n onKeyDown={this.handleDeleteKeyDown}\n >\n {this.renderSpinner()}\n {this.renderPicture()}\n {this.renderLabel()}\n {this.renderBadge()}\n {this.renderProgressBar()}\n </a>,\n this.renderRemoveButton(),\n this.renderActionsMenu(),\n ];\n };\n\n private renderLabel = () => {\n return <span class=\"text\">{this.text}</span>;\n };\n\n private renderPicture() {\n const icon = getIconName(this.icon);\n\n if (!icon && !this.image) {\n return;\n }\n\n if (!isEmpty(this.image)) {\n return (\n <img src={this.image.src} alt={this.image.alt} loading=\"lazy\" />\n );\n }\n\n return (\n <limel-icon\n badge={true}\n name={icon}\n style={{\n color: `${(this.icon as Icon)?.color}`,\n 'background-color': `${\n (this.icon as Icon)?.backgroundColor\n }`,\n }}\n />\n );\n }\n\n private renderBadge() {\n if (!this.badge) {\n return;\n }\n\n return <limel-badge label={this.badge} />;\n }\n\n private renderRemoveButton() {\n if (\n !this.removable ||\n this.readonly ||\n this.disabled ||\n !!this.menuItems?.length\n ) {\n return;\n }\n\n const svgData =\n '<svg viewBox=\"0 0 32 32\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" d=\"m8 8 16 16M24 8 8 24\"/></svg>';\n\n return (\n <button\n class=\"trailing-button remove-button\"\n tabIndex={-1}\n aria-label={this.removeChipLabel}\n aria-controls={'chip-' + this.identifier}\n innerHTML={svgData}\n onClick={this.handleRemoveClick}\n />\n );\n }\n\n private renderActionsMenu() {\n if (!this.menuItems?.length) {\n return;\n }\n\n const svgData =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\" xml:space=\"preserve\"><circle fill=\"currentColor\" cx=\"16\" cy=\"16\" r=\"2\"/><circle fill=\"currentColor\" cx=\"16\" cy=\"24\" r=\"2\"/><circle fill=\"currentColor\" cx=\"16\" cy=\"8\" r=\"2\"/></svg>';\n\n const menuItems = this.getMenuItems();\n\n return (\n <limel-menu\n items={menuItems}\n onSelect={this.handleActionMenuSelect}\n openDirection=\"bottom-end\"\n onCancel={this.handleActionMenuCancel}\n >\n <button\n slot=\"trigger\"\n disabled={this.disabled}\n class=\"trailing-button\"\n aria-label={this.actionMenuLabel}\n innerHTML={svgData}\n />\n </limel-menu>\n );\n }\n\n private getMenuItems() {\n let menuItems = [...this.menuItems];\n\n if (this.removable) {\n menuItems = [\n ...menuItems,\n { separator: true },\n {\n text: this.removeChipLabel(),\n icon: {\n name: 'delete_sign',\n color: 'rgb(var(--color-red-default))',\n },\n value: '_remove',\n },\n ];\n }\n\n return menuItems;\n }\n\n private filterClickWhenDisabled = (e) => {\n if (this.disabled || this.readonly) {\n e.preventDefault();\n }\n };\n\n private handleRemoveClick = (event: MouseEvent | KeyboardEvent) => {\n event.stopPropagation();\n this.remove.emit(this.identifier);\n };\n\n private handleDeleteKeyDown = (event: KeyboardEvent) => {\n if (!this.removable) {\n return;\n }\n\n const keys = [DELETE, BACKSPACE];\n\n if (keys.includes(event.key)) {\n this.handleRemoveClick(event);\n }\n };\n\n private removeChipLabel = (): string => {\n return translate.get('remove', this.language) + ' ' + this.text;\n };\n\n private actionMenuLabel = (): string => {\n return translate.get('file-viewer.more-actions', this.language);\n };\n\n private renderSpinner() {\n if (!this.loading) {\n return;\n }\n\n return <limel-linear-progress indeterminate={true} />;\n }\n\n private renderProgressBar() {\n if (!this.progress) {\n return;\n }\n\n const currentPercentage = this.progress + '%';\n\n return (\n <div\n role=\"progressbar\"\n aria-label=\"%\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n aria-valuenow={this.progress}\n style={{\n '--limel-chip-progress-percentage': currentPercentage,\n }}\n />\n );\n }\n\n private handleActionMenuSelect = (\n event: LimelMenuCustomEvent<MenuItem>\n ) => {\n const menuItem = event.detail;\n\n if (!menuItem) {\n return;\n }\n\n if (menuItem.value === '_remove') {\n this.remove.emit(this.identifier);\n\n return;\n }\n\n this.menuItemSelected.emit(menuItem);\n };\n\n private handleActionMenuCancel = (event: LimelMenuCustomEvent<void>) => {\n event.stopPropagation();\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chip.js","sourceRoot":"","sources":["../../../src/components/chip/chip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,OAAO,EACP,KAAK,EAEL,CAAC,EACD,IAAI,EACJ,IAAI,GACP,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;A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,CAAC;EAEO,iBAAiB;IACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;MAChB,OAAO;KACV;IAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;IAE9C,OAAO,CACH,WACI,IAAI,EAAC,aAAa,gBACP,GAAG,mBACA,GAAG,mBACH,KAAK,mBACJ,IAAI,CAAC,QAAQ,EAC5B,KAAK,EAAE;QACH,kCAAkC,EAAE,iBAAiB;OACxD,GACH,CACL,CAAC;EACN,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBJ","sourcesContent":["import {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Host,\n Prop,\n} from '@stencil/core';\nimport { Icon } from '../../global/shared-types/icon.types';\nimport { Languages } from '../date-picker/date.types';\nimport { Link } from '../../global/shared-types/link.types';\nimport { getRel } from '../../util/link-helper';\nimport { getIconName } from '../icon/get-icon-props';\nimport {\n makeEnterClickable,\n removeEnterClickable,\n} from '../../util/make-enter-clickable';\nimport translate from '../../global/translations';\nimport { BACKSPACE, DELETE } from '../../util/keycodes';\nimport { ChipType, Chip as OldChipInterface } from '../chip-set/chip.types';\nimport { Image } from '../../global/shared-types/image.types';\nimport { isEmpty } from 'lodash-es';\n\nimport { ListSeparator } from '../list/list-item.types';\nimport { LimelMenuCustomEvent, MenuItem } from '../../components';\n\ninterface ChipInterface extends Omit<OldChipInterface, 'id' | 'badge'> {\n /**\n * Identifier for the chip. Must be unique.\n */\n identifier?: number | string;\n\n /**\n * The value of the badge.\n */\n badge?: string | number;\n}\n\n/**\n * Chips and buttons are both interactive elements in UI design,\n * but they serve different purposes and are used in different contexts.\n *\n * :::warning\n * Do not use the chip component carelessly, as an alternative for\n * [`limel-button`](#/component/limel-button/) in the UI design!\n *\n * **Buttons:**\n * Buttons are used to trigger actions. They are typically used to\n * submit forms, open dialogs, initiate a process, or perform any action\n * that changes the state of the application.\n * Buttons' labels usually contain action words, in other words, the labels is\n * a _verb in imperative mood_ such as \"Submit\" or \"Delete\".\n * Buttons are placed in areas where it's clear they will initiate\n * an action when clicked.\n *\n * **Chips:**\n * Chips however are elements which may look like buttons, but they are\n * representing choices, filters, or tags, in a small block\n * or clearly bundled into a group. Chips are rarely used alone in the\n * user interface.\n * They are often used in a so called \"chip-set\", or placed together in\n * a section of the UI, where the user can expect more than one chip to be present.\n *\n * For example, a chip may represent a filter in a filter bar, or a tag in a tag list,\n * or an item in a shopping list.\n * Clicking a chip can also trigger an action, for example toggling a filter ON or OFF,\n * or opening a page with all posts tagged with the tag represented by the chip,\n * or navigating to a page with more information about the item in the shopping list.\n * :::\n *\n * @exampleComponent limel-example-chip-button\n * @exampleComponent limel-example-chip-link\n * @exampleComponent limel-example-chip-icon-colors\n * @exampleComponent limel-example-chip-image\n * @exampleComponent limel-example-chip-badge\n * @exampleComponent limel-example-chip-filter\n * @exampleComponent limel-example-chip-removable\n * @exampleComponent limel-example-chip-menu\n * @exampleComponent limel-example-chip-loading\n * @exampleComponent limel-example-chip-progress\n * @exampleComponent limel-example-chip-size\n * @exampleComponent limel-example-chip-readonly-border\n * @exampleComponent limel-example-chip-aria-role\n */\n@Component({\n tag: 'limel-chip',\n shadow: { delegatesFocus: true },\n styleUrl: 'chip.scss',\n})\nexport class Chip implements ChipInterface {\n /**\n * Defines the language for translations.\n * Will translate the translatable strings on the components.\n */\n @Prop({ reflect: true })\n public language: Languages = 'en';\n\n /**\n * Label displayed on the chip\n */\n @Prop({ reflect: true })\n public text: string;\n\n /**\n * Icon of the chip.\n */\n @Prop()\n public icon?: string | Icon;\n\n /**\n * A picture to be displayed instead of the icon on the chip.\n */\n @Prop()\n public image?: Image;\n\n /**\n * If supplied, the chip will become a clickable link.\n */\n @Prop()\n public link?: Omit<Link, 'text'>;\n\n /**\n * The value of the badge, displayed on the chip.\n */\n @Prop({ reflect: true })\n public badge?: string | number;\n\n /**\n * Set to `true` to disable the chip.\n */\n @Prop({ reflect: true })\n public disabled = false;\n\n /**\n * Set to `true` to render the chip as a static UI element.\n * Useful when the parent component has a `readonly` state.\n */\n @Prop({ reflect: true })\n public readonly = false;\n\n /**\n * Set to `true` to visualize the chip in a \"selected\" state.\n * This is typically used when the chip is used in a chip-set\n * along with other chips.\n */\n @Prop({ reflect: true })\n public selected = false;\n\n /**\n * Set to `true` to visualize the chip in an \"invalid\" or \"error\" state.\n */\n @Prop({ reflect: true })\n public invalid = false;\n\n /**\n * Set to `true` to render a remove button on the chip.\n */\n @Prop({ reflect: true })\n public removable = false;\n\n /**\n * Set to `filter` to render the chip with a distinct style\n * suitable for visualizing filters.\n *\n */\n @Prop({ reflect: true })\n public type?: ChipType = 'default';\n\n /**\n * Set to `true` to put the component in the `loading` state,\n * and render an indeterminate progress indicator inside the chip.\n * This does _not_ disable the interactivity of the chip!\n */\n @Prop({ reflect: true })\n public loading? = false;\n\n /**\n * Reflects the current value of a progress bar on the chip,\n * visualizing the percentage of an ongoing process.\n * Must be a number between `0` and `100`.\n */\n @Prop({ reflect: true })\n public progress?: number;\n\n /**\n * Identifier for the chip. Must be unique.\n */\n @Prop({ reflect: true })\n public identifier?: number | string = crypto.randomUUID();\n\n /**\n * Defines the size of the chip.\n */\n @Prop({ reflect: true })\n public size: 'small' | 'default' = 'default';\n\n /**\n * When provided, the chip will render an ellipsis menu with the supplied items.\n * Also, this will hide the \"remove button\" when `removable={true}`, as\n * the remove button will automatically become the last item in the menu.\n */\n @Prop()\n public menuItems?: Array<MenuItem | ListSeparator> = [];\n\n /**\n * Fired when clicking on the remove button of a `removable` chip.\n * The value of `identifier` is emitted as the event detail.\n */\n @Event()\n public remove: EventEmitter<number | string>;\n\n /**\n * Emitted when a menu item is selected from the actions menu.\n */\n @Event()\n public menuItemSelected: EventEmitter<MenuItem>;\n\n @Element()\n private host: HTMLLimelChipElement;\n\n public componentWillLoad() {\n makeEnterClickable(this.host);\n }\n\n public disconnectedCallback() {\n removeEnterClickable(this.host);\n }\n\n public render() {\n return (\n <Host onClick={this.filterClickWhenDisabled}>\n {this.link ? this.renderAsLink() : this.renderAsButton()}\n </Host>\n );\n }\n\n private renderAsButton = () => {\n return [\n <button\n id={'chip-' + this.identifier}\n class=\"chip\"\n role=\"button\"\n disabled={this.disabled || this.readonly}\n aria-busy={this.loading ? 'true' : 'false'}\n aria-live=\"polite\"\n onKeyDown={this.handleDeleteKeyDown}\n >\n {this.renderSpinner()}\n {this.renderPicture()}\n {this.renderLabel()}\n {this.renderBadge()}\n {this.renderProgressBar()}\n </button>,\n this.renderRemoveButton(),\n this.renderActionsMenu(),\n ];\n };\n\n private renderAsLink = () => {\n const rel = getRel(this.link?.target, this.link?.rel);\n\n return [\n <a\n id={'chip-' + this.identifier}\n class=\"chip\"\n href={this.link.href}\n title={this.link.title}\n target={this.link.target}\n rel={rel}\n aria-disabled={this.disabled || this.readonly}\n tabindex={this.disabled || this.readonly ? -1 : 0}\n onKeyDown={this.handleDeleteKeyDown}\n >\n {this.renderSpinner()}\n {this.renderPicture()}\n {this.renderLabel()}\n {this.renderBadge()}\n {this.renderProgressBar()}\n </a>,\n this.renderRemoveButton(),\n this.renderActionsMenu(),\n ];\n };\n\n private renderLabel = () => {\n return <span class=\"text\">{this.text}</span>;\n };\n\n private renderPicture() {\n const icon = getIconName(this.icon);\n\n if (!icon && !this.image) {\n return;\n }\n\n if (!isEmpty(this.image)) {\n return (\n <img src={this.image.src} alt={this.image.alt} loading=\"lazy\" />\n );\n }\n\n return (\n <limel-icon\n badge={true}\n name={icon}\n style={{\n color: `${(this.icon as Icon)?.color}`,\n 'background-color': `${\n (this.icon as Icon)?.backgroundColor\n }`,\n }}\n />\n );\n }\n\n private renderBadge() {\n if (!this.badge) {\n return;\n }\n\n return <limel-badge label={this.badge} />;\n }\n\n private renderRemoveButton() {\n if (\n !this.removable ||\n this.readonly ||\n this.disabled ||\n !!this.menuItems?.length\n ) {\n return;\n }\n\n const svgData =\n '<svg viewBox=\"0 0 32 32\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" d=\"m8 8 16 16M24 8 8 24\"/></svg>';\n\n return (\n <button\n class=\"trailing-button remove-button\"\n tabIndex={-1}\n aria-label={this.removeChipLabel}\n aria-controls={'chip-' + this.identifier}\n innerHTML={svgData}\n onClick={this.handleRemoveClick}\n />\n );\n }\n\n private renderActionsMenu() {\n if (!this.menuItems?.length) {\n return;\n }\n\n const svgData =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\" xml:space=\"preserve\"><circle fill=\"currentColor\" cx=\"16\" cy=\"16\" r=\"2\"/><circle fill=\"currentColor\" cx=\"16\" cy=\"24\" r=\"2\"/><circle fill=\"currentColor\" cx=\"16\" cy=\"8\" r=\"2\"/></svg>';\n\n const menuItems = this.getMenuItems();\n\n return (\n <limel-menu\n items={menuItems}\n onSelect={this.handleActionMenuSelect}\n openDirection=\"bottom-end\"\n onCancel={this.handleActionMenuCancel}\n >\n <button\n slot=\"trigger\"\n disabled={this.disabled}\n class=\"trailing-button\"\n aria-label={this.actionMenuLabel}\n innerHTML={svgData}\n />\n </limel-menu>\n );\n }\n\n private getMenuItems() {\n let menuItems = [...this.menuItems];\n\n if (this.removable) {\n menuItems = [\n ...menuItems,\n { separator: true },\n {\n text: this.removeChipLabel(),\n icon: {\n name: 'delete_sign',\n color: 'rgb(var(--color-red-default))',\n },\n value: '_remove',\n },\n ];\n }\n\n return menuItems;\n }\n\n private filterClickWhenDisabled = (e) => {\n if (this.disabled || this.readonly) {\n e.preventDefault();\n }\n };\n\n private handleRemoveClick = (event: MouseEvent | KeyboardEvent) => {\n event.stopPropagation();\n this.remove.emit(this.identifier);\n };\n\n private handleDeleteKeyDown = (event: KeyboardEvent) => {\n if (!this.removable) {\n return;\n }\n\n const keys = [DELETE, BACKSPACE];\n\n if (keys.includes(event.key)) {\n this.handleRemoveClick(event);\n }\n };\n\n private removeChipLabel = (): string => {\n return translate.get('remove', this.language) + ' ' + this.text;\n };\n\n private actionMenuLabel = (): string => {\n return translate.get('file-viewer.more-actions', this.language);\n };\n\n private renderSpinner() {\n if (!this.loading) {\n return;\n }\n\n return <limel-linear-progress indeterminate={true} />;\n }\n\n private renderProgressBar() {\n if (!this.progress) {\n return;\n }\n\n const currentPercentage = this.progress + '%';\n\n return (\n <div\n role=\"progressbar\"\n aria-label=\"%\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n aria-valuenow={this.progress}\n style={{\n '--limel-chip-progress-percentage': currentPercentage,\n }}\n />\n );\n }\n\n private handleActionMenuSelect = (\n event: LimelMenuCustomEvent<MenuItem>\n ) => {\n const menuItem = event.detail;\n\n if (!menuItem) {\n return;\n }\n\n if (menuItem.value === '_remove') {\n this.remove.emit(this.identifier);\n\n return;\n }\n\n this.menuItemSelected.emit(menuItem);\n };\n\n private handleActionMenuCancel = (event: LimelMenuCustomEvent<void>) => {\n event.stopPropagation();\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.types.js","sourceRoot":"","sources":["../../../src/components/chip-set/chip.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Image } from '../../global/shared-types/image.types';\nimport { Icon } from '../../global/shared-types/icon.types';\nimport { MenuItem } from '../menu/menu.types';\nimport { ListSeparator } from '../list/list-item.types';\nimport { Color } from '../../global/shared-types/color.types';\n\n/**\n * @public\n */\nexport interface Chip<T = any> {\n /**\n * ID of the chip. Must be unique.\n */\n id: number | string;\n\n /**\n * Text to display inside the chip.\n */\n text: string;\n\n /**\n * Name of the icon to use. Not valid for `filter`.\n */\n icon?: string | Icon;\n\n /**\n * A picture to be displayed instead of the icon on the chip.\n */\n image?: Image;\n\n /**\n * Color of the icon. Overrides `--icon-color`.\n *\n * @deprecated This property is deprecated and will be removed soon!\n *\n * Use the new `Icon` interface instead and write:\n * ```\n * icon {\n * name: string,\n * color: string,\n * },\n * ```\n */\n iconFillColor?: Color;\n\n /**\n * `title` attribute of the icon\n *\n * @deprecated This property is deprecated and will be removed soon!\n *\n * Use the new `Icon` interface instead and write:\n * ```\n * icon {\n * name: string,\n * title: string,\n * },\n * ```\n */\n iconTitle?: string;\n\n /**\n * Background color of the icon. Overrides `--icon-background-color`.\n *\n * @deprecated This property is deprecated and will be removed soon!\n *\n * Use the new `Icon` interface instead and write:\n * ```\n * icon {\n * name: string,\n * backgroundColor: string,\n * },\n * ```\n */\n iconBackgroundColor?: Color;\n\n /**\n * Whether the chip should be removable. Not valid for `choice`.\n */\n removable?: boolean;\n\n /**\n * Whether the chip is selected. Only valid for `choice` and `filter`.\n */\n selected?: boolean;\n\n /**\n * Value of the chip.\n */\n value?: T;\n\n /**\n * The value of the badge.\n */\n badge?: number;\n\n /**\n * If supplied, the chip will render a link, using the supplied href.\n */\n href?: string;\n\n /**\n * List of the items to display as in a menu, on the chip.\n */\n menuItems?: Array<MenuItem | ListSeparator>;\n\n /**\n * Set to `true` to put the chip in the `loading` state, and render an\n * indeterminate progress indicator inside the chip.\n */\n loading?: boolean;\n}\n\n/**\n * This type is used to determine the visual style and behavior of a Chip component.\n
|
|
1
|
+
{"version":3,"file":"chip.types.js","sourceRoot":"","sources":["../../../src/components/chip-set/chip.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Image } from '../../global/shared-types/image.types';\nimport { Icon } from '../../global/shared-types/icon.types';\nimport { MenuItem } from '../menu/menu.types';\nimport { ListSeparator } from '../list/list-item.types';\nimport { Color } from '../../global/shared-types/color.types';\n\n/**\n * @public\n */\nexport interface Chip<T = any> {\n /**\n * ID of the chip. Must be unique.\n */\n id: number | string;\n\n /**\n * Text to display inside the chip.\n */\n text: string;\n\n /**\n * Name of the icon to use. Not valid for `filter`.\n */\n icon?: string | Icon;\n\n /**\n * A picture to be displayed instead of the icon on the chip.\n */\n image?: Image;\n\n /**\n * Color of the icon. Overrides `--icon-color`.\n *\n * @deprecated This property is deprecated and will be removed soon!\n *\n * Use the new `Icon` interface instead and write:\n * ```\n * icon {\n * name: string,\n * color: string,\n * },\n * ```\n */\n iconFillColor?: Color;\n\n /**\n * `title` attribute of the icon\n *\n * @deprecated This property is deprecated and will be removed soon!\n *\n * Use the new `Icon` interface instead and write:\n * ```\n * icon {\n * name: string,\n * title: string,\n * },\n * ```\n */\n iconTitle?: string;\n\n /**\n * Background color of the icon. Overrides `--icon-background-color`.\n *\n * @deprecated This property is deprecated and will be removed soon!\n *\n * Use the new `Icon` interface instead and write:\n * ```\n * icon {\n * name: string,\n * backgroundColor: string,\n * },\n * ```\n */\n iconBackgroundColor?: Color;\n\n /**\n * Whether the chip should be removable. Not valid for `choice`.\n */\n removable?: boolean;\n\n /**\n * Whether the chip is selected. Only valid for `choice` and `filter`.\n */\n selected?: boolean;\n\n /**\n * Value of the chip.\n */\n value?: T;\n\n /**\n * The value of the badge.\n */\n badge?: number;\n\n /**\n * If supplied, the chip will render a link, using the supplied href.\n */\n href?: string;\n\n /**\n * List of the items to display as in a menu, on the chip.\n */\n menuItems?: Array<MenuItem | ListSeparator>;\n\n /**\n * Set to `true` to put the chip in the `loading` state, and render an\n * indeterminate progress indicator inside the chip.\n */\n loading?: boolean;\n}\n\n/**\n * This type is used to determine the visual style and behavior of a Chip component.\n * @public\n */\nexport type ChipType = 'default' | 'filter';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-label.js","sourceRoot":"","sources":["../../../src/components/dynamic-label/dynamic-label.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAInD
|
|
1
|
+
{"version":3,"file":"dynamic-label.js","sourceRoot":"","sources":["../../../src/components/dynamic-label/dynamic-label.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAInD;;;;;;;;;;;;;;;GAeG;AAMH,MAAM,OAAO,YAAY;;;wBAgBuB,EAAE;kBAQrB,EAAE;;EAEpB,MAAM;;IACT,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC;IAE9D,OAAO;MACH,IAAI,CAAC,UAAU,CAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,mCAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;MACtD,IAAI,CAAC,WAAW,CAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,mCAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;KAC1D,CAAC;EACN,CAAC;EAEO,UAAU,CAAC,IAAoB;IACnC,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,QAAQ,EAAE;MACX,OAAO;KACV;IAED,IAAI,SAA6B,CAAC;IAClC,IAAI,mBAAuC,CAAC;IAE5C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;MAC1B,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC;MACvB,mBAAmB,GAAG,IAAI,CAAC,eAAe,CAAC;KAC9C;IAED,MAAM,SAAS,GAAG;MACd,IAAI,EAAE,cAAc;MACpB,IAAI,EAAE,QAAQ;MACd,KAAK,EAAE;QACH,KAAK,EAAE,SAAS;QAChB,kBAAkB,EAAE,mBAAmB;OAC1C;KACJ,CAAC;IAEF,OAAO,kCAAgB,SAAS,EAAI,CAAC;EACzC,CAAC;EAEO,WAAW,CAAC,QAAgB,EAAE;IAClC,OAAO,iBAAQ,KAAK,CAAS,CAAC;EAClC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ","sourcesContent":["import { getIconName } from '../icon/get-icon-props';\nimport { Component, Prop, h } from '@stencil/core';\nimport { Label, LabelValue } from './label.types';\nimport { Icon } from '../../interface';\n\n/**\n * This components displays a different label depending on the current given\n * value. A label can consist of a text and an optional icon. If no matching\n * label is found among the given `labels`, the `defaultLabel` will be displayed.\n *\n * One use case of the component is to enhance the visualization of a `boolean`\n * field like a checkbox or switch in a `readonly` state.\n *\n * The reason we offer this component is that the default styling\n * of the Checkbox or Toggle switch in the `readonly` state may not always\n * provide the best way of _visualizing information_, potentially leading to\n * confusion and negatively affecting the end-users' experience.\n *\n * @exampleComponent limel-example-dynamic-label\n * @exampleComponent limel-example-dynamic-label-readonly-boolean\n */\n@Component({\n tag: 'limel-dynamic-label',\n shadow: true,\n styleUrl: 'dynamic-label.scss',\n})\nexport class DynamicLabel {\n /**\n * The current value of the component which is used to match with the given\n * `labels` to determine what label to display.\n *\n * If not matching label is found, the `defaultLabel` is displayed.\n */\n @Prop()\n public value: LabelValue;\n\n /**\n * The label to display when no matching value is found in the `labels`\n * array. This is a fallback label that ensures there's always a label\n * displayed for the component.\n */\n @Prop({ reflect: true })\n public defaultLabel: Omit<Label, 'value'> = {};\n\n /**\n * A list of available labels. Each label has a corresponding value that\n * will be matched with the current `value` of the component to determine\n * what label to display.\n */\n @Prop()\n public labels: Label[] = [];\n\n public render() {\n const label = this.labels.find((l) => l.value === this.value);\n\n return [\n this.renderIcon(label?.icon ?? this.defaultLabel.icon),\n this.renderLabel(label?.text ?? this.defaultLabel.text),\n ];\n }\n\n private renderIcon(icon?: string | Icon) {\n const iconName = getIconName(icon);\n if (!iconName) {\n return;\n }\n\n let iconColor: string | undefined;\n let iconBackgroundColor: string | undefined;\n\n if (typeof icon === 'object') {\n iconColor = icon.color;\n iconBackgroundColor = icon.backgroundColor;\n }\n\n const iconProps = {\n role: 'presentation',\n name: iconName,\n style: {\n color: iconColor,\n 'background-color': iconBackgroundColor,\n },\n };\n\n return <limel-icon {...iconProps} />;\n }\n\n private renderLabel(label: string = '') {\n return <label>{label}</label>;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.types.js","sourceRoot":"","sources":["../../../src/components/dynamic-label/label.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Icon } from '../../interface';\n\nexport type LabelValue = string | number | boolean | null | undefined;\n\n/**\n * @
|
|
1
|
+
{"version":3,"file":"label.types.js","sourceRoot":"","sources":["../../../src/components/dynamic-label/label.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Icon } from '../../interface';\n\nexport type LabelValue = string | number | boolean | null | undefined;\n\n/**\n * Represents a label that can be displayed in the `limel-dynamic-label` component.\n * Each label has a value that is used to match with the current value of the component.\n *\n * @public\n */\nexport interface Label<T = LabelValue> {\n /**\n * The value of the label\n */\n value: T;\n\n /**\n * Text to display when the label is active\n */\n text?: string;\n\n /**\n * Icon to display when the label is active\n */\n icon?: string | Icon;\n}\n"]}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* to enable easy configuration of its child-elements.
|
|
3
|
+
* This component is deprecated and will be removed in a future version of
|
|
4
|
+
* Lime Elements. Please use CSS for your flexible container needs 🙂
|
|
6
5
|
*
|
|
7
|
-
* @
|
|
6
|
+
* @deprecated Please use CSS instead https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout
|
|
7
|
+
* @private
|
|
8
8
|
* @slot - Grid content
|
|
9
9
|
*/
|
|
10
10
|
export class Grid {
|
|
11
|
+
componentWillLoad() {
|
|
12
|
+
console.warn('limel-grid is deprecated, please use CSS instead: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout');
|
|
13
|
+
}
|
|
11
14
|
render() {
|
|
12
15
|
return h("slot", null);
|
|
13
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../../src/components/grid/grid.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;GAOG;AAMH,MAAM,OAAO,IAAI;EACN,MAAM;IACT,OAAO,eAAQ,CAAC;EACpB,CAAC;;;;;;;;;CACJ","sourcesContent":["import { Component, h } from '@stencil/core';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../../src/components/grid/grid.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;GAOG;AAMH,MAAM,OAAO,IAAI;EACN,iBAAiB;IACpB,OAAO,CAAC,IAAI,CACR,oHAAoH,CACvH,CAAC;EACN,CAAC;EAEM,MAAM;IACT,OAAO,eAAQ,CAAC;EACpB,CAAC;;;;;;;;;CACJ","sourcesContent":["import { Component, h } from '@stencil/core';\n\n/**\n * This component is deprecated and will be removed in a future version of\n * Lime Elements. Please use CSS for your flexible container needs 🙂\n *\n * @deprecated Please use CSS instead https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout\n * @private\n * @slot - Grid content\n */\n@Component({\n tag: 'limel-grid',\n shadow: true,\n styleUrl: 'grid.scss',\n})\nexport class Grid {\n public componentWillLoad() {\n console.warn(\n 'limel-grid is deprecated, please use CSS instead: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout'\n );\n }\n\n public render() {\n return <slot />;\n }\n}\n"]}
|
|
@@ -154,7 +154,6 @@
|
|
|
154
154
|
|
|
155
155
|
limel-dynamic-label {
|
|
156
156
|
margin-top: 0.375rem;
|
|
157
|
-
margin-left: 0.25rem;
|
|
158
157
|
}
|
|
159
158
|
|
|
160
159
|
.mdc-checkbox {
|
|
@@ -4684,7 +4683,6 @@ img {
|
|
|
4684
4683
|
|
|
4685
4684
|
limel-dynamic-label {
|
|
4686
4685
|
margin-top: 0.375rem;
|
|
4687
|
-
margin-left: 0.25rem;
|
|
4688
4686
|
}
|
|
4689
4687
|
|
|
4690
4688
|
.mdc-checkbox {
|
|
@@ -160,7 +160,6 @@
|
|
|
160
160
|
|
|
161
161
|
limel-dynamic-label {
|
|
162
162
|
margin-top: 0.375rem;
|
|
163
|
-
margin-left: 0.25rem;
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
.mdc-checkbox {
|
|
@@ -4754,7 +4753,6 @@ img {
|
|
|
4754
4753
|
|
|
4755
4754
|
limel-dynamic-label {
|
|
4756
4755
|
margin-top: 0.375rem;
|
|
4757
|
-
margin-left: 0.25rem;
|
|
4758
4756
|
}
|
|
4759
4757
|
|
|
4760
4758
|
.mdc-checkbox {
|
|
@@ -521,114 +521,24 @@
|
|
|
521
521
|
width: 100%;
|
|
522
522
|
}
|
|
523
523
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
font-family: var(--mdc-typography-subtitle1-font-family, var(--mdc-typography-font-family, inherit));
|
|
530
|
-
font-size: 0.875rem;
|
|
531
|
-
/* @alternate */
|
|
532
|
-
font-size: var(--mdc-typography-subtitle1-font-size, 0.875rem);
|
|
533
|
-
font-weight: 400;
|
|
534
|
-
/* @alternate */
|
|
535
|
-
font-weight: var(--mdc-typography-subtitle1-font-weight, 400);
|
|
536
|
-
letter-spacing: 0.009375em;
|
|
537
|
-
/* @alternate */
|
|
538
|
-
letter-spacing: var(--mdc-typography-subtitle1-letter-spacing, 0.009375em);
|
|
539
|
-
text-decoration: inherit;
|
|
540
|
-
/* @alternate */
|
|
541
|
-
text-decoration: var(--mdc-typography-subtitle1-text-decoration, inherit);
|
|
542
|
-
text-transform: inherit;
|
|
543
|
-
/* @alternate */
|
|
544
|
-
text-transform: var(--mdc-typography-subtitle1-text-transform, inherit);
|
|
545
|
-
position: absolute;
|
|
546
|
-
/* @noflip */ /*rtl:ignore*/
|
|
547
|
-
left: 0;
|
|
548
|
-
/* @noflip */ /*rtl:ignore*/
|
|
549
|
-
-webkit-transform-origin: left top;
|
|
550
|
-
/* @noflip */ /*rtl:ignore*/
|
|
551
|
-
transform-origin: left top;
|
|
552
|
-
line-height: 1.15rem;
|
|
553
|
-
text-align: left;
|
|
554
|
-
text-overflow: ellipsis;
|
|
555
|
-
white-space: nowrap;
|
|
556
|
-
cursor: text;
|
|
557
|
-
overflow: hidden;
|
|
558
|
-
/* @alternate */
|
|
559
|
-
will-change: transform;
|
|
560
|
-
transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1), color 150ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
561
|
-
}
|
|
562
|
-
[dir=rtl] .mdc-floating-label, .mdc-floating-label[dir=rtl] {
|
|
563
|
-
/*rtl:begin:ignore*/
|
|
564
|
-
/* @noflip */ /*rtl:ignore*/
|
|
565
|
-
right: 0;
|
|
566
|
-
/* @noflip */ /*rtl:ignore*/
|
|
567
|
-
left: auto;
|
|
568
|
-
/* @noflip */ /*rtl:ignore*/
|
|
569
|
-
-webkit-transform-origin: right top;
|
|
570
|
-
/* @noflip */ /*rtl:ignore*/
|
|
571
|
-
transform-origin: right top;
|
|
572
|
-
/* @noflip */ /*rtl:ignore*/
|
|
573
|
-
text-align: right;
|
|
574
|
-
/*rtl:end:ignore*/
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
.mdc-floating-label--float-above {
|
|
578
|
-
cursor: auto;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
.mdc-floating-label--required::after {
|
|
582
|
-
/* @noflip */ /*rtl:ignore*/
|
|
583
|
-
margin-left: 1px;
|
|
584
|
-
/* @noflip */ /*rtl:ignore*/
|
|
585
|
-
margin-right: 0px;
|
|
586
|
-
content: "*";
|
|
587
|
-
}
|
|
588
|
-
[dir=rtl] .mdc-floating-label--required, .mdc-floating-label--required[dir=rtl] {
|
|
589
|
-
/*rtl:begin:ignore*/
|
|
590
|
-
/*rtl:end:ignore*/
|
|
591
|
-
}
|
|
592
|
-
[dir=rtl] .mdc-floating-label--required::after, .mdc-floating-label--required[dir=rtl]::after {
|
|
593
|
-
/* @noflip */ /*rtl:ignore*/
|
|
594
|
-
margin-left: 0;
|
|
595
|
-
/* @noflip */ /*rtl:ignore*/
|
|
596
|
-
margin-right: 1px;
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
.mdc-floating-label--float-above {
|
|
600
|
-
transform: translateY(-106%) scale(0.75);
|
|
524
|
+
:host(limel-slider) {
|
|
525
|
+
isolation: isolate;
|
|
526
|
+
position: relative;
|
|
527
|
+
display: flex;
|
|
528
|
+
flex-direction: column;
|
|
601
529
|
}
|
|
602
530
|
|
|
603
|
-
.
|
|
604
|
-
|
|
531
|
+
:host(limel-slider:not([invalid]):not([invalid=true])) .limel-notched-outline,
|
|
532
|
+
:host(limel-slider[disabled]:not([disabled=false])) .limel-notched-outline {
|
|
533
|
+
--limel-notched-outline-border-color: transparent;
|
|
534
|
+
--limel-notched-outline-background-color: transparent;
|
|
605
535
|
}
|
|
606
536
|
|
|
607
|
-
|
|
608
|
-
0% {
|
|
609
|
-
/* @noflip */ /*rtl:ignore*/
|
|
610
|
-
transform: translateX(calc(0 - 0%)) translateY(-106%) scale(0.75);
|
|
611
|
-
}
|
|
612
|
-
33% {
|
|
613
|
-
animation-timing-function: cubic-bezier(0.5, 0, 0.701732, 0.495819);
|
|
614
|
-
/* @noflip */ /*rtl:ignore*/
|
|
615
|
-
transform: translateX(calc(4% - 0%)) translateY(-106%) scale(0.75);
|
|
616
|
-
}
|
|
617
|
-
66% {
|
|
618
|
-
animation-timing-function: cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);
|
|
619
|
-
/* @noflip */ /*rtl:ignore*/
|
|
620
|
-
transform: translateX(calc(-4% - 0%)) translateY(-106%) scale(0.75);
|
|
621
|
-
}
|
|
622
|
-
100% {
|
|
623
|
-
/* @noflip */ /*rtl:ignore*/
|
|
624
|
-
transform: translateX(calc(0 - 0%)) translateY(-106%) scale(0.75);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
:host(limel-slider) {
|
|
628
|
-
isolation: isolate;
|
|
629
|
-
position: relative;
|
|
537
|
+
div[slot=content] {
|
|
630
538
|
display: flex;
|
|
631
539
|
flex-direction: column;
|
|
540
|
+
width: 100%;
|
|
541
|
+
padding: 0 0.25rem;
|
|
632
542
|
}
|
|
633
543
|
|
|
634
544
|
.mdc-slider {
|
|
@@ -636,20 +546,10 @@
|
|
|
636
546
|
margin: 0 0.75rem;
|
|
637
547
|
}
|
|
638
548
|
|
|
639
|
-
.mdc-floating-label,
|
|
640
549
|
.mdc-slider .mdc-slider__value-indicator-text {
|
|
641
550
|
font-family: inherit;
|
|
642
551
|
}
|
|
643
552
|
|
|
644
|
-
.slider__label {
|
|
645
|
-
padding-left: 1.25rem;
|
|
646
|
-
top: 0.75rem;
|
|
647
|
-
color: rgba(var(--contrast-1200), 1);
|
|
648
|
-
}
|
|
649
|
-
:host(limel-slider.disabled:not(.readonly)) .slider__label {
|
|
650
|
-
color: rgba(var(--contrast-1200), 0.5);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
553
|
.slider__content-range-container {
|
|
654
554
|
display: flex;
|
|
655
555
|
order: 2;
|
|
@@ -13,11 +13,30 @@ const DEFAULT_MIN_VALUE = 0;
|
|
|
13
13
|
*/
|
|
14
14
|
export class Slider {
|
|
15
15
|
constructor() {
|
|
16
|
+
this.renderRangeContainer = () => {
|
|
17
|
+
return (h("div", { class: "slider__content-range-container" }, h("span", { class: "slider__content-min-label" }, this.multiplyByFactor(this.valuemin), this.unit), h("span", { class: "slider__content-max-label" }, this.multiplyByFactor(this.valuemax), this.unit)));
|
|
18
|
+
};
|
|
19
|
+
this.renderSliderContainer = (inputProps) => {
|
|
20
|
+
return (h("div", { class: {
|
|
21
|
+
'mdc-slider': true,
|
|
22
|
+
'mdc-slider--discrete': true,
|
|
23
|
+
'mdc-slider--disabled': this.disabled || this.readonly,
|
|
24
|
+
} }, this.renderSliderInput(inputProps), this.renderTrack(), this.renderThumb()));
|
|
25
|
+
};
|
|
26
|
+
this.renderSliderInput = (inputProps) => {
|
|
27
|
+
return (h("input", Object.assign({ class: "mdc-slider__input", type: "range", min: this.multiplyByFactor(this.valuemin), max: this.multiplyByFactor(this.valuemax), value: this.multiplyByFactor(this.value), name: "volume", "aria-labelledby": this.labelId, "aria-controls": this.helperTextId }, inputProps)));
|
|
28
|
+
};
|
|
29
|
+
this.renderTrack = () => {
|
|
30
|
+
return (h("div", { class: "mdc-slider__track" }, h("div", { class: "mdc-slider__track--inactive" }), h("div", { class: "mdc-slider__track--active" }, h("div", { class: "mdc-slider__track--active_fill" }))));
|
|
31
|
+
};
|
|
32
|
+
this.renderThumb = () => {
|
|
33
|
+
return (h("div", { class: "mdc-slider__thumb" }, h("div", { class: "mdc-slider__value-indicator-container", "aria-hidden": "true" }, h("div", { class: "mdc-slider__value-indicator" }, h("span", { class: "mdc-slider__value-indicator-text" }, this.multiplyByFactor(this.value)))), h("div", { class: "mdc-slider__thumb-knob" })));
|
|
34
|
+
};
|
|
16
35
|
this.renderHelperLine = () => {
|
|
17
36
|
if (!this.helperText) {
|
|
18
37
|
return;
|
|
19
38
|
}
|
|
20
|
-
return (h("limel-helper-line", { helperText: this.helperText, helperTextId: this.helperTextId }));
|
|
39
|
+
return (h("limel-helper-line", { helperText: this.helperText, helperTextId: this.helperTextId, invalid: this.invalid }));
|
|
21
40
|
};
|
|
22
41
|
this.initialize = () => {
|
|
23
42
|
const inputElement = this.getInputElement();
|
|
@@ -150,6 +169,8 @@ export class Slider {
|
|
|
150
169
|
this.factor = DEFAULT_FACTOR;
|
|
151
170
|
this.label = undefined;
|
|
152
171
|
this.helperText = undefined;
|
|
172
|
+
this.required = false;
|
|
173
|
+
this.invalid = false;
|
|
153
174
|
this.unit = '';
|
|
154
175
|
this.value = undefined;
|
|
155
176
|
this.valuemax = DEFAULT_MAX_VALUE;
|
|
@@ -182,11 +203,7 @@ export class Slider {
|
|
|
182
203
|
if (this.disabled || this.readonly) {
|
|
183
204
|
inputProps.disabled = true;
|
|
184
205
|
}
|
|
185
|
-
return (h(Host, { class: this.getContainerClassList() }, h("
|
|
186
|
-
'mdc-slider': true,
|
|
187
|
-
'mdc-slider--discrete': true,
|
|
188
|
-
'mdc-slider--disabled': this.disabled || this.readonly,
|
|
189
|
-
} }, h("input", Object.assign({ class: "mdc-slider__input", type: "range", min: this.multiplyByFactor(this.valuemin), max: this.multiplyByFactor(this.valuemax), value: this.multiplyByFactor(this.value), name: "volume", "aria-labelledby": this.labelId, "aria-controls": this.helperTextId }, inputProps)), h("div", { class: "mdc-slider__track" }, h("div", { class: "mdc-slider__track--inactive" }), h("div", { class: "mdc-slider__track--active" }, h("div", { class: "mdc-slider__track--active_fill" }))), h("div", { class: "mdc-slider__thumb" }, h("div", { class: "mdc-slider__value-indicator-container", "aria-hidden": "true" }, h("div", { class: "mdc-slider__value-indicator" }, h("span", { class: "mdc-slider__value-indicator-text" }, this.multiplyByFactor(this.value)))), h("div", { class: "mdc-slider__thumb-knob" }))), this.renderHelperLine()));
|
|
206
|
+
return (h(Host, { class: this.getContainerClassList() }, h("limel-notched-outline", { labelId: this.labelId, label: this.label, required: this.required, invalid: this.invalid, disabled: this.disabled, readonly: this.readonly, hasValue: !!this.value, hasFloatingLabel: true }, h("div", { slot: "content" }, this.renderRangeContainer(), this.renderSliderContainer(inputProps))), this.renderHelperLine()));
|
|
190
207
|
}
|
|
191
208
|
watchDisabled() {
|
|
192
209
|
this.updateDisabledState();
|
|
@@ -317,6 +334,42 @@ export class Slider {
|
|
|
317
334
|
"attribute": "helper-text",
|
|
318
335
|
"reflect": true
|
|
319
336
|
},
|
|
337
|
+
"required": {
|
|
338
|
+
"type": "boolean",
|
|
339
|
+
"mutable": false,
|
|
340
|
+
"complexType": {
|
|
341
|
+
"original": "boolean",
|
|
342
|
+
"resolved": "boolean",
|
|
343
|
+
"references": {}
|
|
344
|
+
},
|
|
345
|
+
"required": false,
|
|
346
|
+
"optional": false,
|
|
347
|
+
"docs": {
|
|
348
|
+
"tags": [],
|
|
349
|
+
"text": "Set to `true` to indicate that the slider is required."
|
|
350
|
+
},
|
|
351
|
+
"attribute": "required",
|
|
352
|
+
"reflect": true,
|
|
353
|
+
"defaultValue": "false"
|
|
354
|
+
},
|
|
355
|
+
"invalid": {
|
|
356
|
+
"type": "boolean",
|
|
357
|
+
"mutable": false,
|
|
358
|
+
"complexType": {
|
|
359
|
+
"original": "boolean",
|
|
360
|
+
"resolved": "boolean",
|
|
361
|
+
"references": {}
|
|
362
|
+
},
|
|
363
|
+
"required": false,
|
|
364
|
+
"optional": false,
|
|
365
|
+
"docs": {
|
|
366
|
+
"tags": [],
|
|
367
|
+
"text": "Set to `true` to indicate that the current value of the slider is invalid."
|
|
368
|
+
},
|
|
369
|
+
"attribute": "invalid",
|
|
370
|
+
"reflect": true,
|
|
371
|
+
"defaultValue": "false"
|
|
372
|
+
},
|
|
320
373
|
"unit": {
|
|
321
374
|
"type": "string",
|
|
322
375
|
"mutable": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../src/components/slider/slider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA8B,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACH,SAAS,EACT,OAAO,EACP,K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port {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Host,\n Prop,\n State,\n Watch,\n} from '@stencil/core';\nimport { getPercentageClass } from './get-percentage-class';\nimport { createRandomString } from '../../util/random-string';\n\nconst DEFAULT_FACTOR = 1;\nconst DEFAULT_MAX_VALUE = 100;\nconst DEFAULT_MIN_VALUE = 0;\n\n/**\n * @exampleComponent limel-example-slider-basic\n * @exampleComponent limel-example-slider-multiplier\n * @exampleComponent limel-example-slider-multiplier-percentage-colors\n * @exampleComponent limel-example-slider-composite\n */\n@Component({\n tag: 'limel-slider',\n shadow: true,\n styleUrl: 'slider.scss',\n})\nexport class Slider {\n /**\n * Disables the slider when `true`,\n * and visually shows that the field is editable but disabled.\n * This tells the users that if certain requirements are met,\n * the slider may become interactable.\n */\n @Prop({ reflect: true })\n public disabled = false;\n\n /**\n * Disables the slider when `true`. This visualizes the slider slightly differently.\n * But shows no visual sign indicating that the slider field\n * is disabled or can ever become interactable.\n */\n @Prop({ reflect: true })\n public readonly = false;\n\n /**\n * Default value: 1.\n * The factor that the properties `value`, `valuemax`, `valuemin`, and\n * `step` are multiplied by. On `change` divides the value by the factor,\n * so the original format stays the same.\n */\n @Prop({ reflect: true })\n public factor: number = DEFAULT_FACTOR;\n\n /**\n * Label to display next to the input\n */\n @Prop({ reflect: true })\n public label: string;\n\n /**\n * Optional helper text to display below the slider\n */\n @Prop({ reflect: true })\n public helperText: string;\n\n /**\n * Unit to display next to the value\n */\n @Prop({ reflect: true })\n public unit: string = '';\n\n /**\n * The value of the input\n */\n @Prop({ reflect: true })\n public value: number;\n\n /**\n * The maximum value allowed\n */\n @Prop({ reflect: true })\n public valuemax: number = DEFAULT_MAX_VALUE;\n\n /**\n * The minimum value allowed\n */\n @Prop({ reflect: true })\n public valuemin: number = DEFAULT_MIN_VALUE;\n\n /**\n * The stepping interval to use when adjusting the value\n */\n @Prop({ reflect: true })\n public step: number;\n\n /**\n * Emitted when the value has been changed\n */\n @Event()\n private change: EventEmitter<number>;\n\n @Element()\n private rootElement: HTMLLimelSliderElement;\n\n @State()\n private percentageClass: string;\n\n private mdcSlider: MDCSlider;\n private labelId: string;\n private helperTextId: string;\n private observer: ResizeObserver;\n\n public constructor() {\n this.labelId = createRandomString();\n this.helperTextId = createRandomString();\n }\n\n public connectedCallback() {\n this.initialize();\n this.observer = new ResizeObserver(this.resizeObserverCallback);\n this.observer.observe(this.rootElement);\n }\n\n public componentWillLoad() {\n this.setPercentageClass(this.value);\n }\n\n public componentDidLoad() {\n this.initialize();\n }\n\n public disconnectedCallback() {\n this.destroyMDCSlider();\n this.observer.disconnect();\n }\n\n public render() {\n const inputProps: any = {};\n if (this.step) {\n inputProps.step = this.multiplyByFactor(this.step);\n }\n\n if (this.disabled || this.readonly) {\n inputProps.disabled = true;\n }\n\n return (\n <Host class={this.getContainerClassList()}>\n <label\n class=\"slider__label mdc-floating-label mdc-floating-label--float-above\"\n id={this.labelId}\n >\n {this.label}\n </label>\n <div class=\"slider__content-range-container\">\n <span class=\"slider__content-min-label\">\n {this.multiplyByFactor(this.valuemin)}\n {this.unit}\n </span>\n <span class=\"slider__content-max-label\">\n {this.multiplyByFactor(this.valuemax)}\n {this.unit}\n </span>\n </div>\n <div\n class={{\n 'mdc-slider': true,\n 'mdc-slider--discrete': true,\n 'mdc-slider--disabled': this.disabled || this.readonly,\n }}\n >\n <input\n class=\"mdc-slider__input\"\n type=\"range\"\n min={this.multiplyByFactor(this.valuemin)}\n max={this.multiplyByFactor(this.valuemax)}\n value={this.multiplyByFactor(this.value)}\n name=\"volume\"\n aria-labelledby={this.labelId}\n aria-controls={this.helperTextId}\n {...inputProps}\n />\n <div class=\"mdc-slider__track\">\n <div class=\"mdc-slider__track--inactive\"></div>\n <div class=\"mdc-slider__track--active\">\n <div class=\"mdc-slider__track--active_fill\"></div>\n </div>\n </div>\n <div class=\"mdc-slider__thumb\">\n <div\n class=\"mdc-slider__value-indicator-container\"\n aria-hidden=\"true\"\n >\n <div class=\"mdc-slider__value-indicator\">\n <span class=\"mdc-slider__value-indicator-text\">\n {this.multiplyByFactor(this.value)}\n </span>\n </div>\n </div>\n <div class=\"mdc-slider__thumb-knob\"></div>\n </div>\n </div>\n {this.renderHelperLine()}\n </Host>\n );\n }\n\n @Watch('disabled')\n protected watchDisabled() {\n this.updateDisabledState();\n }\n\n @Watch('readonly')\n protected watchReadonly() {\n this.updateDisabledState();\n }\n\n @Watch('value')\n protected watchValue() {\n if (!this.mdcSlider) {\n return;\n }\n\n const value = this.multiplyByFactor(this.getValue());\n this.mdcSlider.setValue(value);\n\n if (this.isStepConfigured()) {\n return;\n }\n\n const step = this.multiplyByFactor(this.step);\n if (!this.isMultipleOfStep(value, step)) {\n return;\n }\n\n this.reCreateSliderWithStep();\n }\n\n private renderHelperLine = () => {\n if (!this.helperText) {\n return;\n }\n\n return (\n <limel-helper-line\n helperText={this.helperText}\n helperTextId={this.helperTextId}\n />\n );\n };\n\n private initialize = () => {\n const inputElement = this.getInputElement();\n if (!inputElement) {\n return;\n }\n\n const value = this.getValue();\n\n /*\n For some reason the input element's `value` attribute is removed\n (probably by Stencil) when the element is first rendered. But if the\n attribute is missing when MDCSlider is initialized (MDC v11.0.0),\n MDCSlider crashes.\n So we add the attribute right before initializing MDCSlider. /Ads\n */\n inputElement.setAttribute('value', `${this.multiplyByFactor(value)}`);\n\n /*\n When creating the `mdcSlider` component, its important that the value set in\n the input field obeys the range and the step size.\n\n The MDCSlider will throw an exception unless the value in the input element\n is dividible by the step value and is in the provided range.\n If an exception occurs, this component will crash and it will be impossible to change\n its value.\n The logic below ensures that the component will render even though the\n provided value is wrong.\n This could be considered wrong, but it at least fixes so that it's possible\n to change the value from the UI.\n */\n const greaterThanOrEqualMin = value >= this.valuemin;\n const lessThanOrEqualMax = value <= this.valuemax;\n\n if (!greaterThanOrEqualMin) {\n const newMin = this.multiplyByFactor(value);\n inputElement.setAttribute('min', `${newMin}`);\n }\n\n if (!lessThanOrEqualMax) {\n const newMax = this.multiplyByFactor(value);\n inputElement.setAttribute('max', `${newMax}`);\n }\n\n if (!this.isMultipleOfStep(value, this.step)) {\n inputElement.removeAttribute('step');\n }\n\n this.createMDCSlider();\n };\n\n private reCreateSliderWithStep = () => {\n const inputElement = this.getInputElement();\n const step = `${this.multiplyByFactor(this.step)}`;\n\n inputElement.setAttribute('step', step);\n\n this.destroyMDCSlider();\n this.createMDCSlider();\n };\n\n private createMDCSlider = () => {\n const element = this.getRootElement();\n\n this.mdcSlider = new MDCSlider(element);\n this.mdcSlider.listen('MDCSlider:change', this.changeHandler);\n this.mdcSlider.listen('MDCSlider:input', this.inputHandler);\n };\n\n private destroyMDCSlider() {\n this.mdcSlider.unlisten('MDCSlider:change', this.changeHandler);\n this.mdcSlider.unlisten('MDCSlider:input', this.inputHandler);\n this.mdcSlider.destroy();\n this.mdcSlider = undefined;\n }\n\n private changeHandler = (\n event: CustomEvent<MDCSliderChangeEventDetail>\n ) => {\n let value = event.detail.value;\n const step = this.multiplyByFactor(this.step);\n\n if (!this.isMultipleOfStep(value, step)) {\n value = this.roundToStep(value, step);\n }\n\n this.change.emit(value / this.factor);\n };\n\n private inputHandler = (event: CustomEvent<MDCSliderChangeEventDetail>) => {\n this.setPercentageClass(event.detail.value / this.factor);\n };\n\n private getContainerClassList = () => {\n return {\n [this.percentageClass]: true,\n disabled: this.disabled || this.readonly,\n readonly: this.readonly,\n };\n };\n\n private resizeObserverCallback = () => {\n this.mdcSlider?.layout();\n };\n\n private updateDisabledState = () => {\n if (!this.mdcSlider) {\n return;\n }\n\n this.mdcSlider?.setDisabled(this.disabled || this.readonly);\n };\n\n private multiplyByFactor = (value: number) => {\n return Math.round(value * this.factor);\n };\n\n private getValue = () => {\n let value = this.value;\n if (!Number.isFinite(value)) {\n value = this.valuemin;\n }\n\n return value;\n };\n\n private setPercentageClass = (value: number) => {\n this.percentageClass = getPercentageClass(\n (value - this.valuemin) / (this.valuemax - this.valuemin)\n );\n };\n\n private isMultipleOfStep = (value: number, step: number): boolean => {\n if (!step) {\n return true;\n }\n\n return value % step === 0;\n };\n\n private roundToStep = (value: number, step: number): number => {\n return Math.round(value / step) * step;\n };\n\n private getRootElement = (): HTMLElement | undefined => {\n return this.rootElement.shadowRoot.querySelector('.mdc-slider');\n };\n\n private getInputElement = (): HTMLInputElement | undefined => {\n const element = this.getRootElement();\n if (!element) {\n return;\n }\n\n return element.querySelector('input');\n };\n\n private isStepConfigured = (): boolean => {\n if (!this.step) {\n return true;\n }\n\n const input = this.getInputElement();\n if (!input) {\n return true;\n }\n\n return input.hasAttribute('step');\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../src/components/slider/slider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA8B,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACH,SAAS,EACT,OAAO,EACP,KAAK,EAEL,CAAC,EACD,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,KAAK,GACR,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B;;;;;GAKG;AAMH,MAAM,OAAO,MAAM;EAkGf;IAuFQ,yBAAoB,GAAG,GAAG,EAAE;MAChC,OAAO,CACH,WAAK,KAAK,EAAC,iCAAiC;QACxC,YAAM,KAAK,EAAC,2BAA2B;UAClC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC;UACpC,IAAI,CAAC,IAAI,CACP;QACP,YAAM,KAAK,EAAC,2BAA2B;UAClC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC;UACpC,IAAI,CAAC,IAAI,CACP,CACL,CACT,CAAC;IACN,CAAC,CAAC;IAEM,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+FJ","sourcesContent":["import { MDCSlider, MDCSliderChangeEventDetail } from '@material/slider';\nimport {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Host,\n Prop,\n State,\n Watch,\n} from '@stencil/core';\nimport { getPercentageClass } from './get-percentage-class';\nimport { createRandomString } from '../../util/random-string';\n\nconst DEFAULT_FACTOR = 1;\nconst DEFAULT_MAX_VALUE = 100;\nconst DEFAULT_MIN_VALUE = 0;\n\n/**\n * @exampleComponent limel-example-slider-basic\n * @exampleComponent limel-example-slider-multiplier\n * @exampleComponent limel-example-slider-multiplier-percentage-colors\n * @exampleComponent limel-example-slider-composite\n */\n@Component({\n tag: 'limel-slider',\n shadow: true,\n styleUrl: 'slider.scss',\n})\nexport class Slider {\n /**\n * Disables the slider when `true`,\n * and visually shows that the field is editable but disabled.\n * This tells the users that if certain requirements are met,\n * the slider may become interactable.\n */\n @Prop({ reflect: true })\n public disabled = false;\n\n /**\n * Disables the slider when `true`. This visualizes the slider slightly differently.\n * But shows no visual sign indicating that the slider field\n * is disabled or can ever become interactable.\n */\n @Prop({ reflect: true })\n public readonly = false;\n\n /**\n * Default value: 1.\n * The factor that the properties `value`, `valuemax`, `valuemin`, and\n * `step` are multiplied by. On `change` divides the value by the factor,\n * so the original format stays the same.\n */\n @Prop({ reflect: true })\n public factor: number = DEFAULT_FACTOR;\n\n /**\n * Label to display next to the input\n */\n @Prop({ reflect: true })\n public label: string;\n\n /**\n * Optional helper text to display below the slider\n */\n @Prop({ reflect: true })\n public helperText: string;\n\n /**\n * Set to `true` to indicate that the slider is required.\n */\n @Prop({ reflect: true })\n public required = false;\n\n /**\n * Set to `true` to indicate that the current value of the slider is invalid.\n */\n @Prop({ reflect: true })\n public invalid = false;\n\n /**\n * Unit to display next to the value\n */\n @Prop({ reflect: true })\n public unit: string = '';\n\n /**\n * The value of the input\n */\n @Prop({ reflect: true })\n public value: number;\n\n /**\n * The maximum value allowed\n */\n @Prop({ reflect: true })\n public valuemax: number = DEFAULT_MAX_VALUE;\n\n /**\n * The minimum value allowed\n */\n @Prop({ reflect: true })\n public valuemin: number = DEFAULT_MIN_VALUE;\n\n /**\n * The stepping interval to use when adjusting the value\n */\n @Prop({ reflect: true })\n public step: number;\n\n /**\n * Emitted when the value has been changed\n */\n @Event()\n private change: EventEmitter<number>;\n\n @Element()\n private rootElement: HTMLLimelSliderElement;\n\n @State()\n private percentageClass: string;\n\n private mdcSlider: MDCSlider;\n private labelId: string;\n private helperTextId: string;\n private observer: ResizeObserver;\n\n public constructor() {\n this.labelId = createRandomString();\n this.helperTextId = createRandomString();\n }\n\n public connectedCallback() {\n this.initialize();\n this.observer = new ResizeObserver(this.resizeObserverCallback);\n this.observer.observe(this.rootElement);\n }\n\n public componentWillLoad() {\n this.setPercentageClass(this.value);\n }\n\n public componentDidLoad() {\n this.initialize();\n }\n\n public disconnectedCallback() {\n this.destroyMDCSlider();\n this.observer.disconnect();\n }\n\n public render() {\n const inputProps: any = {};\n if (this.step) {\n inputProps.step = this.multiplyByFactor(this.step);\n }\n\n if (this.disabled || this.readonly) {\n inputProps.disabled = true;\n }\n\n return (\n <Host class={this.getContainerClassList()}>\n <limel-notched-outline\n labelId={this.labelId}\n label={this.label}\n required={this.required}\n invalid={this.invalid}\n disabled={this.disabled}\n readonly={this.readonly}\n hasValue={!!this.value}\n hasFloatingLabel={true}\n >\n <div slot=\"content\">\n {this.renderRangeContainer()}\n {this.renderSliderContainer(inputProps)}\n </div>\n </limel-notched-outline>\n {this.renderHelperLine()}\n </Host>\n );\n }\n\n @Watch('disabled')\n protected watchDisabled() {\n this.updateDisabledState();\n }\n\n @Watch('readonly')\n protected watchReadonly() {\n this.updateDisabledState();\n }\n\n @Watch('value')\n protected watchValue() {\n if (!this.mdcSlider) {\n return;\n }\n\n const value = this.multiplyByFactor(this.getValue());\n this.mdcSlider.setValue(value);\n\n if (this.isStepConfigured()) {\n return;\n }\n\n const step = this.multiplyByFactor(this.step);\n if (!this.isMultipleOfStep(value, step)) {\n return;\n }\n\n this.reCreateSliderWithStep();\n }\n\n private renderRangeContainer = () => {\n return (\n <div class=\"slider__content-range-container\">\n <span class=\"slider__content-min-label\">\n {this.multiplyByFactor(this.valuemin)}\n {this.unit}\n </span>\n <span class=\"slider__content-max-label\">\n {this.multiplyByFactor(this.valuemax)}\n {this.unit}\n </span>\n </div>\n );\n };\n\n private renderSliderContainer = (inputProps: any) => {\n return (\n <div\n class={{\n 'mdc-slider': true,\n 'mdc-slider--discrete': true,\n 'mdc-slider--disabled': this.disabled || this.readonly,\n }}\n >\n {this.renderSliderInput(inputProps)}\n {this.renderTrack()}\n {this.renderThumb()}\n </div>\n );\n };\n\n private renderSliderInput = (inputProps: any) => {\n return (\n <input\n class=\"mdc-slider__input\"\n type=\"range\"\n min={this.multiplyByFactor(this.valuemin)}\n max={this.multiplyByFactor(this.valuemax)}\n value={this.multiplyByFactor(this.value)}\n name=\"volume\"\n aria-labelledby={this.labelId}\n aria-controls={this.helperTextId}\n {...inputProps}\n />\n );\n };\n\n private renderTrack = () => {\n return (\n <div class=\"mdc-slider__track\">\n <div class=\"mdc-slider__track--inactive\" />\n <div class=\"mdc-slider__track--active\">\n <div class=\"mdc-slider__track--active_fill\" />\n </div>\n </div>\n );\n };\n\n private renderThumb = () => {\n return (\n <div class=\"mdc-slider__thumb\">\n <div\n class=\"mdc-slider__value-indicator-container\"\n aria-hidden=\"true\"\n >\n <div class=\"mdc-slider__value-indicator\">\n <span class=\"mdc-slider__value-indicator-text\">\n {this.multiplyByFactor(this.value)}\n </span>\n </div>\n </div>\n <div class=\"mdc-slider__thumb-knob\" />\n </div>\n );\n };\n\n private renderHelperLine = () => {\n if (!this.helperText) {\n return;\n }\n\n return (\n <limel-helper-line\n helperText={this.helperText}\n helperTextId={this.helperTextId}\n invalid={this.invalid}\n />\n );\n };\n\n private initialize = () => {\n const inputElement = this.getInputElement();\n if (!inputElement) {\n return;\n }\n\n const value = this.getValue();\n\n /*\n For some reason the input element's `value` attribute is removed\n (probably by Stencil) when the element is first rendered. But if the\n attribute is missing when MDCSlider is initialized (MDC v11.0.0),\n MDCSlider crashes.\n So we add the attribute right before initializing MDCSlider. /Ads\n */\n inputElement.setAttribute('value', `${this.multiplyByFactor(value)}`);\n\n /*\n When creating the `mdcSlider` component, its important that the value set in\n the input field obeys the range and the step size.\n\n The MDCSlider will throw an exception unless the value in the input element\n is dividible by the step value and is in the provided range.\n If an exception occurs, this component will crash and it will be impossible to change\n its value.\n The logic below ensures that the component will render even though the\n provided value is wrong.\n This could be considered wrong, but it at least fixes so that it's possible\n to change the value from the UI.\n */\n const greaterThanOrEqualMin = value >= this.valuemin;\n const lessThanOrEqualMax = value <= this.valuemax;\n\n if (!greaterThanOrEqualMin) {\n const newMin = this.multiplyByFactor(value);\n inputElement.setAttribute('min', `${newMin}`);\n }\n\n if (!lessThanOrEqualMax) {\n const newMax = this.multiplyByFactor(value);\n inputElement.setAttribute('max', `${newMax}`);\n }\n\n if (!this.isMultipleOfStep(value, this.step)) {\n inputElement.removeAttribute('step');\n }\n\n this.createMDCSlider();\n };\n\n private reCreateSliderWithStep = () => {\n const inputElement = this.getInputElement();\n const step = `${this.multiplyByFactor(this.step)}`;\n\n inputElement.setAttribute('step', step);\n\n this.destroyMDCSlider();\n this.createMDCSlider();\n };\n\n private createMDCSlider = () => {\n const element = this.getRootElement();\n\n this.mdcSlider = new MDCSlider(element);\n this.mdcSlider.listen('MDCSlider:change', this.changeHandler);\n this.mdcSlider.listen('MDCSlider:input', this.inputHandler);\n };\n\n private destroyMDCSlider() {\n this.mdcSlider.unlisten('MDCSlider:change', this.changeHandler);\n this.mdcSlider.unlisten('MDCSlider:input', this.inputHandler);\n this.mdcSlider.destroy();\n this.mdcSlider = undefined;\n }\n\n private changeHandler = (\n event: CustomEvent<MDCSliderChangeEventDetail>\n ) => {\n let value = event.detail.value;\n const step = this.multiplyByFactor(this.step);\n\n if (!this.isMultipleOfStep(value, step)) {\n value = this.roundToStep(value, step);\n }\n\n this.change.emit(value / this.factor);\n };\n\n private inputHandler = (event: CustomEvent<MDCSliderChangeEventDetail>) => {\n this.setPercentageClass(event.detail.value / this.factor);\n };\n\n private getContainerClassList = () => {\n return {\n [this.percentageClass]: true,\n disabled: this.disabled || this.readonly,\n readonly: this.readonly,\n };\n };\n\n private resizeObserverCallback = () => {\n this.mdcSlider?.layout();\n };\n\n private updateDisabledState = () => {\n if (!this.mdcSlider) {\n return;\n }\n\n this.mdcSlider?.setDisabled(this.disabled || this.readonly);\n };\n\n private multiplyByFactor = (value: number) => {\n return Math.round(value * this.factor);\n };\n\n private getValue = () => {\n let value = this.value;\n if (!Number.isFinite(value)) {\n value = this.valuemin;\n }\n\n return value;\n };\n\n private setPercentageClass = (value: number) => {\n this.percentageClass = getPercentageClass(\n (value - this.valuemin) / (this.valuemax - this.valuemin)\n );\n };\n\n private isMultipleOfStep = (value: number, step: number): boolean => {\n if (!step) {\n return true;\n }\n\n return value % step === 0;\n };\n\n private roundToStep = (value: number, step: number): number => {\n return Math.round(value / step) * step;\n };\n\n private getRootElement = (): HTMLElement | undefined => {\n return this.rootElement.shadowRoot.querySelector('.mdc-slider');\n };\n\n private getInputElement = (): HTMLInputElement | undefined => {\n const element = this.getRootElement();\n if (!element) {\n return;\n }\n\n return element.querySelector('input');\n };\n\n private isStepConfigured = (): boolean => {\n if (!this.step) {\n return true;\n }\n\n const input = this.getInputElement();\n if (!input) {\n return true;\n }\n\n return input.hasAttribute('step');\n };\n}\n"]}
|
|
@@ -234,10 +234,7 @@ export class Switch {
|
|
|
234
234
|
"required": false,
|
|
235
235
|
"optional": true,
|
|
236
236
|
"docs": {
|
|
237
|
-
"tags": [
|
|
238
|
-
"name": "beta",
|
|
239
|
-
"text": undefined
|
|
240
|
-
}],
|
|
237
|
+
"tags": [],
|
|
241
238
|
"text": "The labels to use to clarify what kind of data is being visualized,\nwhen the component is `readonly`."
|
|
242
239
|
},
|
|
243
240
|
"defaultValue": "[]"
|