{"version":3,"file":"item-picker-modal.element-DCqPEIst.js","sources":["../../../src/packages/core/modal/common/item-picker/item-picker-modal.element.ts"],"sourcesContent":["import {\n\tcss,\n\thtml,\n\tcustomElement,\n\trepeat,\n\tnothing,\n\twhen,\n\tstate,\n\tifDefined,\n} from '@umbraco-cms/backoffice/external/lit';\nimport { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';\nimport { UmbTextStyles } from '@umbraco-cms/backoffice/style';\nimport type { UmbItemPickerModalData, UmbItemPickerModel } from '@umbraco-cms/backoffice/modal';\nimport { umbFocus } from '@umbraco-cms/backoffice/lit-element';\n\n@customElement('umb-item-picker-modal')\nexport class UmbItemPickerModalElement extends UmbModalBaseElement {\n\t@state()\n\tprivate _filtered: Array = [];\n\n\t#close() {\n\t\tthis.modalContext?.reject();\n\t}\n\n\t#filter(event: { target: HTMLInputElement }) {\n\t\tif (!this.data) return;\n\n\t\tif (event.target.value) {\n\t\t\tconst query = event.target.value.toLowerCase();\n\t\t\tthis._filtered = this.data.items.filter(\n\t\t\t\t(item) => item.label.toLowerCase().includes(query) || item.value.toLowerCase().includes(query),\n\t\t\t);\n\t\t} else {\n\t\t\tthis._filtered = this.data.items;\n\t\t}\n\t}\n\n\t#submit(item: UmbItemPickerModel) {\n\t\tthis.modalContext?.setValue(item);\n\t\tthis.modalContext?.submit();\n\t}\n\n\toverride connectedCallback() {\n\t\tsuper.connectedCallback();\n\n\t\tif (!this.data) return;\n\t\tthis._filtered = this.data.items;\n\t}\n\n\toverride render() {\n\t\tif (!this.data) return nothing;\n\t\tconst items = this._filtered;\n\t\treturn html`\n\t\t\t\n\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\n\t\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t${when(\n\t\t\t\t\t\titems.length,\n\t\t\t\t\t\t() => html`\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t${repeat(\n\t\t\t\t\t\t\t\t\t\titems,\n\t\t\t\t\t\t\t\t\t\t(item) => item.value,\n\t\t\t\t\t\t\t\t\t\t(item) => html`\n\t\t\t\t\t\t\t\t\t\t\t this.#submit(item)}>\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t`,\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\t() => html`

There are no items to select.

`,\n\t\t\t\t\t)}\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t
\n\t\t`;\n\t}\n\n\tstatic override styles = [\n\t\tUmbTextStyles,\n\t\tcss`\n\t\t\t#main {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\tgap: var(--uui-size-space-5);\n\t\t\t}\n\n\t\t\tuui-box > uui-input {\n\t\t\t\twidth: 100%;\n\t\t\t}\n\n\t\t\tuui-box > uui-button {\n\t\t\t\tdisplay: block;\n\t\t\t\t--uui-button-content-align: flex-start;\n\t\t\t}\n\n\t\t\tuui-box > uui-button:not(:last-of-type) {\n\t\t\t\tmargin-bottom: var(--uui-size-space-5);\n\t\t\t}\n\n\t\t\th4 {\n\t\t\t\ttext-align: left;\n\t\t\t\tmargin: 0.5rem 0;\n\t\t\t}\n\n\t\t\tp {\n\t\t\t\ttext-align: left;\n\t\t\t\tmargin: 0 0 0.5rem 0;\n\t\t\t}\n\t\t`,\n\t];\n}\n\nexport default UmbItemPickerModalElement;\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'umb-item-picker-modal': UmbItemPickerModalElement;\n\t}\n}\n"],"names":["_UmbItemPickerModalElement_instances","close_fn","filter_fn","submit_fn","UmbItemPickerModalElement","UmbModalBaseElement","__privateAdd","nothing","items","html","__privateMethod","umbFocus","when","repeat","item","ifDefined","event","query","UmbTextStyles","css","__decorateClass","state","customElement","UmbItemPicker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