@limetech/lime-elements 38.26.1 → 38.28.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/cjs/lime-elements.cjs.js +1 -1
  4. package/dist/cjs/limel-color-picker-palette.cjs.entry.js +2 -1
  5. package/dist/cjs/limel-color-picker-palette.cjs.entry.js.map +1 -1
  6. package/dist/cjs/limel-color-picker.cjs.entry.js +3 -2
  7. package/dist/cjs/limel-color-picker.cjs.entry.js.map +1 -1
  8. package/dist/cjs/limel-form.cjs.entry.js +4 -0
  9. package/dist/cjs/limel-form.cjs.entry.js.map +1 -1
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/collection/components/color-picker/color-picker-palette.js +20 -1
  12. package/dist/collection/components/color-picker/color-picker-palette.js.map +1 -1
  13. package/dist/collection/components/color-picker/color-picker.js +24 -4
  14. package/dist/collection/components/color-picker/color-picker.js.map +1 -1
  15. package/dist/collection/components/form/fields/schema-field.js +4 -0
  16. package/dist/collection/components/form/fields/schema-field.js.map +1 -1
  17. package/dist/collection/components/form/form.types.js.map +1 -1
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/lime-elements.js +1 -1
  20. package/dist/esm/limel-color-picker-palette.entry.js +2 -1
  21. package/dist/esm/limel-color-picker-palette.entry.js.map +1 -1
  22. package/dist/esm/limel-color-picker.entry.js +3 -2
  23. package/dist/esm/limel-color-picker.entry.js.map +1 -1
  24. package/dist/esm/limel-form.entry.js +4 -0
  25. package/dist/esm/limel-form.entry.js.map +1 -1
  26. package/dist/esm/loader.js +1 -1
  27. package/dist/lime-elements/index.esm.js.map +1 -1
  28. package/dist/lime-elements/lime-elements.esm.js +1 -1
  29. package/dist/lime-elements/lime-elements.esm.js.map +1 -1
  30. package/dist/lime-elements/{p-e1213871.entry.js → p-489d7f63.entry.js} +2 -2
  31. package/dist/lime-elements/p-489d7f63.entry.js.map +1 -0
  32. package/dist/lime-elements/{p-0345965e.entry.js → p-4f85b3c4.entry.js} +2 -2
  33. package/dist/lime-elements/p-4f85b3c4.entry.js.map +1 -0
  34. package/dist/lime-elements/{p-179e9d78.entry.js → p-d24988e7.entry.js} +2 -2
  35. package/dist/lime-elements/{p-179e9d78.entry.js.map → p-d24988e7.entry.js.map} +1 -1
  36. package/dist/types/components/color-picker/color-picker-palette.d.ts +4 -0
  37. package/dist/types/components/color-picker/color-picker.d.ts +9 -2
  38. package/dist/types/components/form/form.types.d.ts +4 -0
  39. package/dist/types/components.d.ts +28 -8
  40. package/package.json +1 -1
  41. package/dist/lime-elements/p-0345965e.entry.js.map +0 -1
  42. package/dist/lime-elements/p-e1213871.entry.js.map +0 -1
@@ -31,6 +31,10 @@ export declare class Palette implements FormComponent {
31
31
  * invalid.
32
32
  */
33
33
  invalid: boolean;
34
+ /**
35
+ * Set to `false` to disallow custom color values to be typed into the input field.
36
+ */
37
+ manualInput: boolean;
34
38
  /**
35
39
  * Defines the number of columns in the color swatch grid.
36
40
  * If not provided, it will default to the number of colors in the palette.
@@ -12,9 +12,10 @@ import type { CustomColorSwatch } from './color-picker.types';
12
12
  * Make sure to read our [guidelines about usage of colors](/#/DesignGuidelines/color-system.md/) from our palette.
13
13
  * :::
14
14
  *
15
- * @exampleComponent limel-example-color-picker
16
- * @exampleComponent limel-example-color-picker-readonly
15
+ * @exampleComponent limel-example-color-picker-basic
17
16
  * @exampleComponent limel-example-color-picker-custom-palette
17
+ * @exampleComponent limel-example-color-picker-manual-input
18
+ * @exampleComponent limel-example-color-picker-composite
18
19
  */
19
20
  export declare class ColorPicker implements FormComponent {
20
21
  /**
@@ -60,6 +61,12 @@ export declare class ColorPicker implements FormComponent {
60
61
  * when the field is focused and empty.
61
62
  */
62
63
  placeholder: string;
64
+ /**
65
+ * Set to `false` to disallow custom color values to be typed into the input field.
66
+ * Setting this to `false` does not completely disable the color picker.
67
+ * It will only allow users to pick from the provided color palette.
68
+ */
69
+ manualInput: boolean;
63
70
  /**
64
71
  * An array of either color value strings, or objects with a `name` and a `value`,
65
72
  * which replaces the default palette. Any valid CSS color format is accepted as value
@@ -178,6 +178,10 @@ export interface LimeSchemaOptions {
178
178
  * Mark the field as disabled
179
179
  */
180
180
  disabled?: boolean;
181
+ /**
182
+ * Hide the field from the UI while preserving its value in the form data.
183
+ */
184
+ hidden?: boolean;
181
185
  help?: string | Partial<Help>;
182
186
  }
183
187
  /**
@@ -947,9 +947,10 @@ export namespace Components {
947
947
  * :::note
948
948
  * Make sure to read our [guidelines about usage of colors](/#/DesignGuidelines/color-system.md/) from our palette.
949
949
  * :::
950
- * @exampleComponent limel-example-color-picker
951
- * @exampleComponent limel-example-color-picker-readonly
950
+ * @exampleComponent limel-example-color-picker-basic
952
951
  * @exampleComponent limel-example-color-picker-custom-palette
952
+ * @exampleComponent limel-example-color-picker-manual-input
953
+ * @exampleComponent limel-example-color-picker-composite
953
954
  */
954
955
  interface LimelColorPicker {
955
956
  /**
@@ -968,6 +969,10 @@ export namespace Components {
968
969
  * The label of the input field
969
970
  */
970
971
  "label": string;
972
+ /**
973
+ * Set to `false` to disallow custom color values to be typed into the input field. Setting this to `false` does not completely disable the color picker. It will only allow users to pick from the provided color palette.
974
+ */
975
+ "manualInput": boolean;
971
976
  /**
972
977
  * An array of either color value strings, or objects with a `name` and a `value`, which replaces the default palette. Any valid CSS color format is accepted as value (HEX, RGB/A, HSL, HWB, color-mix(), named colors, etc.).
973
978
  */
@@ -1017,6 +1022,10 @@ export namespace Components {
1017
1022
  * Label of the input field
1018
1023
  */
1019
1024
  "label": string;
1025
+ /**
1026
+ * Set to `false` to disallow custom color values to be typed into the input field.
1027
+ */
1028
+ "manualInput": boolean;
1020
1029
  /**
1021
1030
  * Custom color palette to use instead of Lime palette. Internal prop passed from parent.
1022
1031
  */
@@ -3902,9 +3911,10 @@ declare global {
3902
3911
  * :::note
3903
3912
  * Make sure to read our [guidelines about usage of colors](/#/DesignGuidelines/color-system.md/) from our palette.
3904
3913
  * :::
3905
- * @exampleComponent limel-example-color-picker
3906
- * @exampleComponent limel-example-color-picker-readonly
3914
+ * @exampleComponent limel-example-color-picker-basic
3907
3915
  * @exampleComponent limel-example-color-picker-custom-palette
3916
+ * @exampleComponent limel-example-color-picker-manual-input
3917
+ * @exampleComponent limel-example-color-picker-composite
3908
3918
  */
3909
3919
  interface HTMLLimelColorPickerElement extends Components.LimelColorPicker, HTMLStencilElement {
3910
3920
  }
@@ -6013,9 +6023,10 @@ declare namespace LocalJSX {
6013
6023
  * :::note
6014
6024
  * Make sure to read our [guidelines about usage of colors](/#/DesignGuidelines/color-system.md/) from our palette.
6015
6025
  * :::
6016
- * @exampleComponent limel-example-color-picker
6017
- * @exampleComponent limel-example-color-picker-readonly
6026
+ * @exampleComponent limel-example-color-picker-basic
6018
6027
  * @exampleComponent limel-example-color-picker-custom-palette
6028
+ * @exampleComponent limel-example-color-picker-manual-input
6029
+ * @exampleComponent limel-example-color-picker-composite
6019
6030
  */
6020
6031
  interface LimelColorPicker {
6021
6032
  /**
@@ -6034,6 +6045,10 @@ declare namespace LocalJSX {
6034
6045
  * The label of the input field
6035
6046
  */
6036
6047
  "label"?: string;
6048
+ /**
6049
+ * Set to `false` to disallow custom color values to be typed into the input field. Setting this to `false` does not completely disable the color picker. It will only allow users to pick from the provided color palette.
6050
+ */
6051
+ "manualInput"?: boolean;
6037
6052
  /**
6038
6053
  * Emits chosen value to the parent component
6039
6054
  */
@@ -6087,6 +6102,10 @@ declare namespace LocalJSX {
6087
6102
  * Label of the input field
6088
6103
  */
6089
6104
  "label"?: string;
6105
+ /**
6106
+ * Set to `false` to disallow custom color values to be typed into the input field.
6107
+ */
6108
+ "manualInput"?: boolean;
6090
6109
  /**
6091
6110
  * Emits chosen value to the parent component
6092
6111
  */
@@ -9059,9 +9078,10 @@ declare module "@stencil/core" {
9059
9078
  * :::note
9060
9079
  * Make sure to read our [guidelines about usage of colors](/#/DesignGuidelines/color-system.md/) from our palette.
9061
9080
  * :::
9062
- * @exampleComponent limel-example-color-picker
9063
- * @exampleComponent limel-example-color-picker-readonly
9081
+ * @exampleComponent limel-example-color-picker-basic
9064
9082
  * @exampleComponent limel-example-color-picker-custom-palette
9083
+ * @exampleComponent limel-example-color-picker-manual-input
9084
+ * @exampleComponent limel-example-color-picker-composite
9065
9085
  */
9066
9086
  "limel-color-picker": LocalJSX.LimelColorPicker & JSXBase.HTMLAttributes<HTMLLimelColorPickerElement>;
9067
9087
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limetech/lime-elements",
3
- "version": "38.26.1",
3
+ "version": "38.28.0",
4
4
  "description": "Lime Elements",
5
5
  "author": "Lime Technologies",
6
6
  "license": "Apache-2.0",
@@ -1 +0,0 @@
1
- {"version":3,"names":["colors","brightnesses","getColorName","color","brightness","getSwatchValue","getSwatchName","createSwatch","name","value","colorPickerPaletteCss","Palette","this","renderSwatches","getPalette","map","renderSwatchButton","swatch","index","isSelected","classList","usesCustomPalette","h","class","style","title","disabled","key","onClick","handleSwatchClick","handleChange","event","stopPropagation","change","emit","detail","newValue","render","background","getColumnCount","label","helperText","onChange","required","invalid","placeholder","palette","entry","normalized","normalizeEntry","swatches","b","push","_a","length","columnCount"],"sources":["./src/components/color-picker/swatches.ts","./src/components/color-picker/color-picker-palette.scss?tag=limel-color-picker-palette&encapsulation=shadow","./src/components/color-picker/color-picker-palette.tsx"],"sourcesContent":["export const colors = [\n 'red',\n 'pink',\n 'magenta',\n 'purple',\n 'violet',\n 'indigo',\n 'blue',\n 'sky',\n 'cyan',\n 'teal',\n 'green',\n 'lime',\n 'grass',\n 'yellow',\n 'amber',\n 'orange',\n 'coral',\n 'brown',\n 'gray',\n 'glaucous',\n];\n\nexport const brightnesses = ['lighter', 'light', 'default', 'dark', 'darker'];\n\nexport interface Swatch {\n name: string;\n value: string;\n disabled?: boolean;\n}\n\n/**\n * Returns the CSS variable name holding the RGB triplet for the color & brightness.\n *\n * @param color the base color identifier (e.g. \"red\", \"blue\")\n * @param brightness the brightness variant (e.g. \"light\", \"default\")\n * @returns CSS variable name in the form --color-{color}-{brightness}\n */\nexport function getColorName(color: string, brightness: string): string {\n return `--color-${color}-${brightness}`;\n}\n\n/**\n * Swatch value: inline CSS color value in the required format: rgb(var(--color-*-*))\n * @param color\n * @param brightness\n */\nexport function getSwatchValue(color: string, brightness: string): string {\n return `rgb(var(${getColorName(color, brightness)}))`;\n}\n\n/**\n * Swatch name: human readable label like \"red default\"\n * @param color\n * @param brightness\n */\nexport function getSwatchName(color: string, brightness: string): string {\n return `${color} ${brightness}`;\n}\n\n/**\n * Convenience factory returning both name & value.\n * @param color\n * @param brightness\n */\nexport function createSwatch(color: string, brightness: string): Swatch {\n return {\n name: getSwatchName(color, brightness),\n value: getSwatchValue(color, brightness),\n };\n}\n\n/**\n * Returns the CSS color value for the given color and brightness.\n * @param color\n * @param brightness\n */\nexport function getCssColor(color: string, brightness: string): string {\n return getSwatchValue(color, brightness);\n}\n","@use '../../style/internal/shared_input-select-picker';\n@use '../../style/mixins';\n@import './partial-styles/lime-admin-hack';\n\n:host(limel-color-picker-palette) {\n --limel-color-palette-gap: 0.25rem;\n --limel-color-palette-max-column-count: 25;\n --limel-color-palette-min-width: 8rem;\n box-sizing: border-box;\n\n border-radius: 0.75rem; // is like popover's default `--popover-border-radius`\n display: flex;\n flex-direction: column;\n gap: 1rem;\n padding: 0.75rem;\n}\n\n*,\n*:before,\n:after {\n box-sizing: border-box;\n}\n\n.color-picker-palette {\n display: grid;\n gap: var(--limel-color-palette-gap);\n grid-template-columns: repeat(\n min(\n var(--color-picker-column-count),\n var(--limel-color-palette-max-column-count)\n ),\n 1fr\n );\n width: 100%;\n max-width: 58rem;\n min-width: var(--limel-color-palette-min-width);\n}\n\n.chosen-color-name {\n display: flex;\n gap: 0.5rem;\n}\n\nlimel-input-field {\n flex-grow: 1;\n width: min-content;\n}\n\n.chosen-color-preview {\n flex-shrink: 0;\n isolation: isolate;\n\n position: relative;\n width: shared_input-select-picker.$height-of-mdc-text-field;\n height: shared_input-select-picker.$height-of-mdc-text-field;\n\n border: 1px solid rgba(var(--contrast-700), 0.65);\n border-radius: 50%;\n\n &:before,\n &:after {\n content: '';\n position: absolute;\n inset: 0;\n border-radius: inherit;\n }\n\n &:before {\n @include mixins.add-chessboard-background();\n z-index: 0;\n }\n\n &:after {\n background: var(--background);\n z-index: 1;\n }\n}\n\nbutton.swatch {\n all: unset;\n position: relative;\n display: flex;\n justify-content: center;\n align-items: center;\n\n max-width: 3rem;\n min-width: max(\n 2rem,\n 100% /\n min(\n var(--color-picker-column-count),\n var(--limel-color-palette-max-column-count)\n ) -\n (\n min(\n var(--color-picker-column-count),\n var(--limel-color-palette-max-column-count)\n ) -\n 1\n ) *\n var(--limel-color-palette-gap)\n );\n aspect-ratio: 1;\n border-radius: 0.1875rem;\n\n @include mixins.visualize-keyboard-focus();\n\n // Since the background color will be overwritten by the mixin,\n // we need to set it explicitly here and repeated in the mixin.\n background-color: var(--limel-color-picker-swatch-color);\n &:not([disabled]) {\n @include mixins.is-flat-clickable(\n $background-color: var(--limel-color-picker-swatch-color),\n $background-color--hovered: var(--limel-color-picker-swatch-color)\n );\n }\n\n &:focus-visible {\n box-shadow:\n var(--shadow-depth-8-focused),\n 0 0 0 0.125rem rgb(var(--contrast-100)) inset;\n }\n\n &[disabled] {\n cursor: not-allowed;\n box-shadow: 0 0 0 0.125rem rgb(var(--contrast-100), 0.6) inset;\n\n &:after {\n content: '';\n position: absolute;\n inset: 0;\n margin: auto;\n width: 0.125rem;\n height: 100%;\n\n opacity: 0.6;\n rotate: 45deg;\n border-radius: 1rem;\n background-color: rgb(var(--contrast-100));\n }\n }\n}\n\nbutton.swatch--selected {\n box-shadow: var(--button-shadow-inset);\n\n border-radius: 50%;\n}\n","import { Component, h, Prop, Event, EventEmitter } from '@stencil/core';\nimport { FormComponent } from '../form/form.types';\nimport { brightnesses, colors, createSwatch, Swatch } from './swatches';\nimport type { CustomPalette, CustomColorSwatch } from './color-picker.types';\n\n/**\n * @private\n */\n@Component({\n tag: 'limel-color-picker-palette',\n shadow: { delegatesFocus: true },\n styleUrl: 'color-picker-palette.scss',\n})\nexport class Palette implements FormComponent {\n /**\n * Color value that is manually typed by the user\n */\n @Prop({ reflect: true })\n public value: string;\n\n /**\n * Label of the input field\n */\n @Prop({ reflect: true })\n public label: string;\n\n /**\n * Helper text of the input field\n */\n @Prop({ reflect: true })\n public helperText: string;\n\n /**\n * The placeholder text shown inside the input field,\n * when the field is focused and empty.\n */\n @Prop({ reflect: true })\n public placeholder: string;\n\n /**\n * Set to `true` if a value is required\n */\n @Prop({ reflect: true })\n public required: boolean;\n\n /**\n * Set to `true` to indicate that the current value of the input field is\n * invalid.\n */\n @Prop({ reflect: true })\n public invalid = false;\n\n /**\n * Defines the number of columns in the color swatch grid.\n * If not provided, it will default to the number of colors in the palette.\n */\n @Prop({ reflect: true })\n public columnCount?: number;\n\n /**\n * Custom color palette to use instead of Lime palette. Internal prop passed from parent.\n */\n @Prop()\n public palette?: CustomPalette;\n\n /**\n * Emits chosen value to the parent component\n */\n @Event()\n public change: EventEmitter<string>;\n\n public render() {\n const background = this.value ? { '--background': this.value } : {};\n\n return [\n <div\n class=\"color-picker-palette\"\n style={{\n '--color-picker-column-count': `${this.getColumnCount()}`,\n }}\n >\n {this.renderSwatches()}\n </div>,\n <div class=\"chosen-color-name\">\n <limel-input-field\n label={this.label}\n helperText={this.helperText}\n value={this.value}\n onChange={this.handleChange}\n required={this.required}\n invalid={this.invalid}\n placeholder={this.placeholder}\n />\n <div class=\"chosen-color-preview\" style={background} />\n </div>,\n ];\n }\n\n private renderSwatches = () => {\n return this.getPalette().map(this.renderSwatchButton);\n };\n\n private getPalette(): Swatch[] {\n if (this.usesCustomPalette()) {\n return (this.palette || []).map((entry) => {\n const normalized = this.normalizeEntry(entry);\n return {\n name: normalized.name || normalized.value,\n value: normalized.value,\n disabled: normalized.disabled,\n };\n });\n }\n\n // Order default swatches by brightness first, then by color.\n // This gives a more intuitive CSS grid layout logic, and\n // enables adding the `columnCount` prop.\n const swatches: Swatch[] = [];\n for (const b of brightnesses) {\n for (const color of colors) {\n swatches.push(createSwatch(color, b));\n }\n }\n return swatches;\n }\n\n private renderSwatchButton = (swatch: Swatch, index: number) => {\n const isSelected = this.value === swatch.value;\n const classList = {\n swatch: true,\n 'swatch--selected': isSelected,\n 'custom-swatch': this.usesCustomPalette(),\n };\n\n return (\n <button\n class={classList}\n style={{ '--limel-color-picker-swatch-color': swatch.value }}\n title={swatch.name}\n disabled={swatch.disabled}\n data-index={index}\n key={index}\n onClick={this.handleSwatchClick(swatch.value)}\n />\n );\n };\n\n private handleChange = (event: CustomEvent<string>) => {\n event.stopPropagation();\n this.change.emit(event.detail);\n };\n\n private handleSwatchClick = (value: string) => (event: MouseEvent) => {\n event.stopPropagation();\n const newValue = this.value === value ? '' : value;\n this.change.emit(newValue);\n };\n\n private normalizeEntry(\n entry: string | CustomColorSwatch\n ): CustomColorSwatch {\n if (typeof entry === 'string') {\n return { value: entry };\n }\n return entry;\n }\n\n private usesCustomPalette(): boolean {\n return this.palette?.length > 0;\n }\n\n private getColumnCount(): number {\n if (this.columnCount > 0) {\n return this.columnCount;\n }\n\n // Default palette: fixed 20 columns (one per base color)\n if (!this.usesCustomPalette()) {\n return 20;\n }\n\n // Custom palette: span all provided swatches unless empty\n const palette = this.getPalette();\n return palette.length > 0 ? palette.length : 1;\n }\n}\n"],"mappings":"kDAAO,MAAMA,EAAS,CAClB,MACA,OACA,UACA,SACA,SACA,SACA,OACA,MACA,OACA,OACA,QACA,OACA,QACA,SACA,QACA,SACA,QACA,QACA,OACA,YAGG,MAAMC,EAAe,CAAC,UAAW,QAAS,UAAW,OAAQ,U,SAepDC,EAAaC,EAAeC,GACxC,MAAO,WAAWD,KAASC,GAC/B,C,SAOgBC,EAAeF,EAAeC,GAC1C,MAAO,WAAWF,EAAaC,EAAOC,MAC1C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AKC,MAAM,uBAAuBC,MAAOc,K,CAS7CxB,aACJ,GAAIF,KAAKS,oBAAqB,CAC1B,OAAQT,KAAKkC,SAAW,IAAI/B,KAAKgC,IAC7B,MAAMC,EAAapC,KAAKqC,eAAeF,GACvC,MAAO,CACHvC,KAAMwC,EAAWxC,MAAQwC,EAAWvC,MACpCA,MAAOuC,EAAWvC,MAClBiB,SAAUsB,EAAWtB,SACxB,G,CAOT,MAAMwB,EAAqB,GAC3B,IAAK,MAAMC,KAAKlD,EAAc,CAC1B,IAAK,MAAME,KAASH,EAAQ,CACxBkD,EAASE,KAAK7C,EAAaJ,EAAOgD,G,EAG1C,OAAOD,C,CAmCHD,eACJF,GAEA,UAAWA,IAAU,SAAU,CAC3B,MAAO,CAAEtC,MAAOsC,E,CAEpB,OAAOA,C,CAGH1B,oB,MACJ,QAAOgC,EAAAzC,KAAKkC,WAAO,MAAAO,SAAA,SAAAA,EAAEC,QAAS,C,CAG1Bf,iBACJ,GAAI3B,KAAK2C,YAAc,EAAG,CACtB,OAAO3C,KAAK2C,W,CAIhB,IAAK3C,KAAKS,oBAAqB,CAC3B,OAAO,E,CAIX,MAAMyB,EAAUlC,KAAKE,aACrB,OAAOgC,EAAQQ,OAAS,EAAIR,EAAQQ,OAAS,C"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["colorPickerCss","ColorPicker","this","shouldFocus","renderTooltip","readonly","tooltipLabel","h","label","elementId","renderPickerPalette","renderPickerTrigger","open","isOpen","openDirection","onClose","onPopoverClose","ref","setColorPickerPaletteElement","value","helperText","placeholder","invalid","onChange","handleChange","required","palette","columnCount","paletteColumnCount","background","slot","style","role","onClick","openPopover","id","disabled","element","contentElement","event","stopPropagation","change","emit","detail","componentDidRender","_a","focus","render","Host"],"sources":["./src/components/color-picker/color-picker.scss?tag=limel-color-picker&encapsulation=shadow","./src/components/color-picker/color-picker.tsx"],"sourcesContent":["@use '../../style/mixins';\n@use '../../style/internal/shared_input-select-picker';\n@import './partial-styles/lime-admin-hack';\n\n:host(limel-color-picker) {\n display: grid;\n gap: 0.25rem;\n grid-template-columns: auto 1fr;\n}\n\nbutton[slot='trigger'] {\n all: unset;\n box-sizing: border-box;\n position: relative;\n isolation: isolate;\n width: shared_input-select-picker.$height-of-mdc-text-field;\n height: shared_input-select-picker.$height-of-mdc-text-field;\n\n border-radius: 0.5rem;\n\n &:not([disabled]):not([disabled='true']) {\n @include mixins.is-elevated-clickable();\n @include mixins.visualize-keyboard-focus();\n }\n\n &:before,\n &:after {\n content: '';\n position: absolute;\n inset: 0;\n border-radius: inherit;\n }\n\n &:before {\n @include mixins.add-chessboard-background();\n z-index: 0;\n }\n\n &:after {\n z-index: 1;\n box-shadow: 0 0 0 0.25rem rgb(var(--contrast-100)) inset;\n background: var(--background);\n }\n}\n\n:host([readonly]:not([readonly='false'])) {\n limel-input-field {\n transform: translateX(\n calc(\n #{shared_input-select-picker.$height-of-mdc-text-field} /\n 4 * -1\n )\n )\n translateY(\n calc(\n #{shared_input-select-picker.$height-of-mdc-text-field} / 4\n )\n );\n }\n}\n\n:host([readonly]:not([readonly='false'])),\n:host([disabled]:not([disabled='false'])) {\n button[slot='trigger'] {\n border: 1px solid rgba(var(--contrast-700), 0.65);\n }\n}\n","import {\n Component,\n h,\n Prop,\n State,\n Event,\n EventEmitter,\n Host,\n} from '@stencil/core';\nimport { FormComponent } from '../form/form.types';\nimport type { CustomColorSwatch } from './color-picker.types';\n\n/**\n * This component enables you to select a swatch from out color palette, simply\n * by clicking on it. You can then copy the css variable name of the chosen color\n * and use it where desired.\n *\n * The color picker can also show you a preview of any valid color name or color value.\n *\n * :::note\n * Make sure to read our [guidelines about usage of colors](/#/DesignGuidelines/color-system.md/) from our palette.\n * :::\n *\n * @exampleComponent limel-example-color-picker\n * @exampleComponent limel-example-color-picker-readonly\n * @exampleComponent limel-example-color-picker-custom-palette\n */\n@Component({\n tag: 'limel-color-picker',\n shadow: true,\n styleUrl: 'color-picker.scss',\n})\nexport class ColorPicker implements FormComponent {\n /**\n * Name or code of the chosen color\n */\n @Prop({ reflect: true })\n public value: string;\n\n /**\n * The label of the input field\n */\n @Prop({ reflect: true })\n public label: string;\n\n /**\n * Helper text of the input field\n */\n @Prop({ reflect: true })\n public helperText: string;\n\n /**\n * Displayed as tooltips when picker is hovered.\n */\n @Prop({ reflect: true })\n public tooltipLabel: string;\n\n /**\n * Set to `true` if a value is required\n */\n @Prop({ reflect: true })\n public required: boolean;\n\n /**\n * Set to `true` to disable the field.\n * Use `disabled` to indicate that the field can normally be interacted\n * with, but is currently disabled. This tells the user that if certain\n * requirements are met, the field may become enabled again.\n */\n @Prop({ reflect: true })\n public disabled = false;\n\n /**\n * Set to `true` to make the field read-only.\n * Use `readonly` when the field is only there to present the data it holds,\n * and will not become possible for the current user to edit.\n */\n @Prop({ reflect: true })\n public readonly = false;\n\n /**\n * Set to `true` to indicate that the current value of the input field is\n * invalid.\n */\n @Prop({ reflect: true })\n public invalid = false;\n\n /**\n * The placeholder text shown inside the input field,\n * when the field is focused and empty.\n */\n @Prop({ reflect: true })\n public placeholder: string;\n\n /**\n * An array of either color value strings, or objects with a `name` and a `value`,\n * which replaces the default palette. Any valid CSS color format is accepted as value\n * (HEX, RGB/A, HSL, HWB, color-mix(), named colors, etc.).\n */\n @Prop()\n public palette?: Array<string | CustomColorSwatch>;\n\n /**\n * Defines the number of columns in the color swatch grid.\n * If not provided, it will default to the number of colors in the palette;\n * but stops at a maximum of 25 columns.\n */\n @Prop({ reflect: true })\n public paletteColumnCount?: number;\n\n /**\n * Emits chosen value to the parent component\n */\n @Event()\n public change: EventEmitter<string>;\n\n @State()\n private isOpen = false;\n\n public componentDidRender() {\n if (this.shouldFocus && this.isOpen) {\n this.shouldFocus = false;\n this.contentElement?.focus();\n }\n }\n\n private contentElement?: HTMLLimelColorPickerPaletteElement;\n\n private shouldFocus = false;\n\n public render() {\n return (\n <Host>\n {this.renderTooltip()}\n {this.renderPickerPalette()}\n <limel-input-field\n label={this.label}\n helperText={this.helperText}\n value={this.value}\n onChange={this.handleChange}\n required={this.required}\n readonly={this.readonly}\n disabled={this.disabled}\n invalid={this.invalid}\n placeholder={this.placeholder}\n />\n </Host>\n );\n }\n private renderTooltip = () => {\n if (!this.readonly && this.tooltipLabel) {\n return (\n <limel-tooltip\n label={this.tooltipLabel}\n elementId=\"tooltip-button\"\n />\n );\n }\n };\n\n private renderPickerPalette = () => {\n if (this.readonly) {\n return this.renderPickerTrigger();\n }\n\n return (\n <limel-popover\n open={this.isOpen}\n openDirection=\"bottom-start\"\n onClose={this.onPopoverClose}\n >\n {this.renderPickerTrigger()}\n <limel-color-picker-palette\n ref={this.setColorPickerPaletteElement}\n value={this.value}\n label={this.label}\n helperText={this.helperText}\n placeholder={this.placeholder}\n invalid={this.invalid}\n onChange={this.handleChange}\n required={this.required}\n palette={this.palette as any}\n columnCount={this.paletteColumnCount}\n />\n </limel-popover>\n );\n };\n\n private renderPickerTrigger = () => {\n const background = this.value ? { '--background': this.value } : {};\n\n return (\n <button\n slot=\"trigger\"\n style={background}\n role=\"button\"\n onClick={this.openPopover}\n id=\"tooltip-button\"\n disabled={this.readonly || this.disabled}\n />\n );\n };\n\n private setColorPickerPaletteElement = (\n element: HTMLLimelColorPickerPaletteElement\n ) => {\n this.contentElement = element;\n };\n\n private openPopover = (event: MouseEvent) => {\n event.stopPropagation();\n this.isOpen = true;\n\n this.shouldFocus = this.isOpen;\n };\n\n private onPopoverClose = (event: CustomEvent) => {\n event.stopPropagation();\n this.isOpen = false;\n };\n\n private handleChange = (event: CustomEvent<string>) => {\n event.stopPropagation();\n this.change.emit(event.detail);\n };\n}\n"],"mappings":"yDAAA,MAAMA,EAAiB,8uI,MCgCVC,EAAW,M,wDAgGZC,KAAAC,YAAc,MAqBdD,KAAAE,cAAgB,KACpB,IAAKF,KAAKG,UAAYH,KAAKI,aAAc,CACrC,OACIC,EAAA,iBACIC,MAAON,KAAKI,aACZG,UAAU,kB,GAMlBP,KAAAQ,oBAAsB,KAC1B,GAAIR,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