{"version":3,"file":"icon-picker-modal.element-BC9hVr63.js","sources":["../../../src/packages/core/modal/common/icon-picker/icon-picker-modal.element.ts"],"sourcesContent":["import { css, customElement, html, nothing, query, repeat, state } from '@umbraco-cms/backoffice/external/lit';\nimport { extractUmbColorVariable, umbracoColors } from '@umbraco-cms/backoffice/resources';\nimport { umbFocus } from '@umbraco-cms/backoffice/lit-element';\nimport { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';\nimport { UmbTextStyles } from '@umbraco-cms/backoffice/style';\nimport { UMB_ICON_REGISTRY_CONTEXT, type UmbIconDefinition } from '@umbraco-cms/backoffice/icon';\nimport type { UmbIconPickerModalData, UmbIconPickerModalValue } from '@umbraco-cms/backoffice/modal';\nimport type { UUIColorSwatchesEvent } from '@umbraco-cms/backoffice/external/uui';\n\n@customElement('umb-icon-picker-modal')\nexport class UmbIconPickerModalElement extends UmbModalBaseElement {\n\t#icons?: Array;\n\n\t@query('#search')\n\tprivate _searchInput?: HTMLInputElement;\n\n\t@state()\n\tprivate _iconsFiltered?: Array;\n\n\t@state()\n\tprivate _colorList = umbracoColors.filter((color) => !color.legacy);\n\n\t@state()\n\tprivate _currentIcon?: string;\n\n\t@state()\n\tprivate _currentColor = 'text';\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.consumeContext(UMB_ICON_REGISTRY_CONTEXT, (context) => {\n\t\t\tthis.observe(context.approvedIcons, (icons) => {\n\t\t\t\tthis.#icons = icons;\n\t\t\t\tthis.#filterIcons();\n\t\t\t});\n\t\t});\n\t}\n\n\t#filterIcons() {\n\t\tif (!this.#icons) return;\n\t\tconst value = this._searchInput?.value;\n\t\tif (value) {\n\t\t\tthis._iconsFiltered = this.#icons.filter((icon) => icon.name.toLowerCase().includes(value.toLowerCase()));\n\t\t} else {\n\t\t\tthis._iconsFiltered = this.#icons;\n\t\t}\n\t}\n\n\toverride connectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis._iconsFiltered = this.#icons;\n\n\t\tif (this.modalContext) {\n\t\t\tthis.observe(\n\t\t\t\tthis.modalContext?.value,\n\t\t\t\t(newValue) => {\n\t\t\t\t\tthis._currentIcon = newValue?.icon;\n\t\t\t\t\tthis._currentColor = newValue?.color ?? 'text';\n\t\t\t\t},\n\t\t\t\t'_observeModalContextValue',\n\t\t\t);\n\t\t}\n\t}\n\n\t#changeIcon(e: InputEvent | KeyboardEvent, iconName: string) {\n\t\tif (e.type == 'click' || (e.type == 'keyup' && (e as KeyboardEvent).key == 'Enter')) {\n\t\t\tthis.modalContext?.updateValue({ icon: iconName });\n\t\t}\n\t}\n\n\t#onColorChange(e: UUIColorSwatchesEvent) {\n\t\tconst colorAlias = e.target.value;\n\t\tthis.modalContext?.updateValue({ color: colorAlias });\n\t\tthis._currentColor = colorAlias;\n\t}\n\n\toverride render() {\n\t\t// TODO: Missing localization in general. [NL]\n\t\treturn html`\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\t${this.renderSearch()}\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t${\n\t\t\t\t\t\t\t// TODO: Missing localization for the color aliases. [NL]\n\t\t\t\t\t\t\tthis._colorList.map(\n\t\t\t\t\t\t\t\t(color) => html`\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t${this.renderIcons()}\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\t\n\t\t\t
\n\t\t`;\n\t}\n\n\trenderSearch() {\n\t\treturn html` \n\t\t\t\n\t\t`;\n\t}\n\n\trenderIcons() {\n\t\treturn this._iconsFiltered\n\t\t\t? repeat(\n\t\t\t\t\tthis._iconsFiltered,\n\t\t\t\t\t(icon) => icon.name,\n\t\t\t\t\t(icon) => html`\n\t\t\t\t\t\t this.#changeIcon(e, icon.name)}\n\t\t\t\t\t\t\t@keyup=${(e: KeyboardEvent) => this.#changeIcon(e, icon.name)}>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t`,\n\t\t\t\t)\n\t\t\t: nothing;\n\t}\n\n\tstatic override styles = [\n\t\tUmbTextStyles,\n\t\tcss`\n\t\t\t:host {\n\t\t\t\tposition: relative;\n\t\t\t}\n\n\t\t\t#container {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\theight: 100%;\n\t\t\t\tbackground-color: var(--uui-color-surface);\n\t\t\t\tbox-shadow: var(--uui-shadow-depth-1, 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24));\n\t\t\t\tborder-radius: var(--uui-border-radius);\n\t\t\t\tpadding: var(--uui-size-space-5);\n\t\t\t\tbox-sizing: border-box;\n\t\t\t}\n\t\t\t#container hr {\n\t\t\t\theight: 1px;\n\t\t\t\tborder: none;\n\t\t\t\tbackground-color: var(--uui-color-divider);\n\t\t\t\tmargin: 20px 0;\n\t\t\t}\n\n\t\t\t#search {\n\t\t\t\twidth: 100%;\n\t\t\t\talign-items: center;\n\t\t\t}\n\t\t\t#search_icon {\n\t\t\t\tpadding-left: var(--uui-size-space-2);\n\t\t\t}\n\n\t\t\t#icons {\n\t\t\t\tline-height: 0;\n\t\t\t\tdisplay: grid;\n\t\t\t\tgrid-template-columns: repeat(auto-fit, minmax(40px, calc((100% / 12) - 10px)));\n\t\t\t\tgap: 10px;\n\t\t\t\toverflow-y: scroll;\n\t\t\t\tmax-height: 100%;\n\t\t\t\tmin-height: 0;\n\t\t\t\tpadding: 2px;\n\t\t\t}\n\n\t\t\t#icons uui-button {\n\t\t\t\tborder-radius: var(--uui-border-radius);\n\t\t\t\tfont-size: 16px; /* specific for icons */\n\t\t\t}\n\t\t\t#icons uui-button:focus,\n\t\t\t#icons uui-button:hover,\n\t\t\t#icons uui-button.selected {\n\t\t\t\toutline: 2px solid var(--uui-color-selected);\n\t\t\t}\n\n\t\t\tuui-button[slot='actions'] {\n\t\t\t\tmargin-left: var(--uui-size-space-4);\n\t\t\t}\n\n\t\t\tuui-color-swatches {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t`,\n\t];\n}\n\nexport default UmbIconPickerModalElement;\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'umb-icon-picker-modal': UmbIconPickerModalElement;\n\t}\n}\n"],"names":["_icons","_UmbIconPickerModalElement_instances","filterIcons_fn","changeIcon_fn","onColorChange_fn","UmbIconPickerModalElement","UmbModalBaseElement","__privateAdd","umbracoColors","color","UMB_ICON_REGISTRY_CONTEXT","context","icons","__privateSet","__privateMethod","__privateGet","newValue","html","umbFocus","repeat","icon","e","extractUmbColorVariable","nothing","value","iconName","colorAlias","UmbTextStyles","css","__decorateClass","query","state","customElement","UmbIconPickerModalElement$1"],"mappings":";;;;;;;;;;;;wYAAAA,GAAAC,GAAAC,GAAAC,GAAAC;AAUa,IAAAC,IAAN,cAAwCC,EAAqE;AAAA,EAkBnH,cAAc;AACP,aAnBDC,EAAA,MAAAN,CAAA,GACNM,EAAA,MAAAP,CAAA,GASA,KAAQ,aAAaQ,EAAc,OAAO,CAACC,MAAU,CAACA,EAAM,MAAM,GAMlE,KAAQ,gBAAgB,QAIlB,KAAA,eAAeC,GAA2B,CAACC,MAAY;AAC3D,WAAK,QAAQA,EAAQ,eAAe,CAACC,MAAU;AAC9C,QAAAC,EAAA,MAAKb,GAASY,CAAA,GACdE,EAAA,MAAKb,GAALC,CAAA,EAAA,KAAA,IAAA;AAAA,MAAA,CACA;AAAA,IAAA,CACD;AAAA,EACF;AAAA,EAYS,oBAAoB;AAC5B,UAAM,kBAAkB,GACxB,KAAK,iBAAiBa,EAAK,MAAAf,CAAA,GAEvB,KAAK,gBACH,KAAA;AAAA,MACJ,KAAK,cAAc;AAAA,MACnB,CAACgB,MAAa;AACb,aAAK,eAAeA,GAAU,MACzB,KAAA,gBAAgBA,GAAU,SAAS;AAAA,MACzC;AAAA,MACA;AAAA,IAAA;AAAA,EAGH;AAAA,EAcS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