godown 2.6.0 → 2.6.2

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 (133) hide show
  1. package/lib/directives.d.ts +2 -4
  2. package/lib/directives.d.ts.map +1 -1
  3. package/lib/directives.js.map +1 -1
  4. package/lib/event-collection.d.ts +1 -1
  5. package/lib/utils.d.ts +2 -0
  6. package/lib/utils.d.ts.map +1 -1
  7. package/lib/utils.js +11 -0
  8. package/lib/utils.js.map +1 -1
  9. package/package.json +4 -6
  10. package/react/index.d.ts +0 -3
  11. package/react/index.d.ts.map +1 -1
  12. package/react/index.js +0 -9
  13. package/react/index.js.map +1 -1
  14. package/root.d.ts.map +1 -1
  15. package/root.js +1 -0
  16. package/root.js.map +1 -1
  17. package/web-components/a/avatar-a.js +40 -40
  18. package/web-components/a/avatar-a.js.map +1 -1
  19. package/web-components/a/super-a.js +22 -22
  20. package/web-components/a/super-a.js.map +1 -1
  21. package/web-components/button/base-button.js +86 -86
  22. package/web-components/button/base-button.js.map +1 -1
  23. package/web-components/carousel/carousel-slider.d.ts +1 -1
  24. package/web-components/carousel/carousel-slider.d.ts.map +1 -1
  25. package/web-components/carousel/carousel-slider.js +70 -70
  26. package/web-components/carousel/carousel-slider.js.map +1 -1
  27. package/web-components/form/base-form.js +15 -15
  28. package/web-components/form/base-form.js.map +1 -1
  29. package/web-components/group/avatar-group.js +15 -15
  30. package/web-components/group/avatar-group.js.map +1 -1
  31. package/web-components/group/details-group.js +7 -7
  32. package/web-components/group/details-group.js.map +1 -1
  33. package/web-components/group/tab-group.js +45 -45
  34. package/web-components/group/tab-group.js.map +1 -1
  35. package/web-components/index.d.ts +0 -3
  36. package/web-components/index.d.ts.map +1 -1
  37. package/web-components/index.js +0 -3
  38. package/web-components/index.js.map +1 -1
  39. package/web-components/input/base-input.js +73 -73
  40. package/web-components/input/base-input.js.map +1 -1
  41. package/web-components/input/input.js +15 -15
  42. package/web-components/input/input.js.map +1 -1
  43. package/web-components/input/label-input.js +49 -49
  44. package/web-components/input/label-input.js.map +1 -1
  45. package/web-components/input/search-input.js +53 -53
  46. package/web-components/input/search-input.js.map +1 -1
  47. package/web-components/input/select-input.js +88 -88
  48. package/web-components/input/select-input.js.map +1 -1
  49. package/web-components/input/split-input.js +51 -51
  50. package/web-components/input/split-input.js.map +1 -1
  51. package/web-components/input/switch-input.js +36 -36
  52. package/web-components/input/switch-input.js.map +1 -1
  53. package/web-components/items/alert-item.js +32 -33
  54. package/web-components/items/alert-item.js.map +1 -1
  55. package/web-components/items/card-item.js +54 -54
  56. package/web-components/items/card-item.js.map +1 -1
  57. package/web-components/items/drag-box.js +8 -8
  58. package/web-components/items/drag-box.js.map +1 -1
  59. package/web-components/items/time-bar.js +8 -9
  60. package/web-components/items/time-bar.js.map +1 -1
  61. package/web-components/layout/divider-line.js +11 -11
  62. package/web-components/layout/divider-line.js.map +1 -1
  63. package/web-components/layout/flex-flow.js +7 -7
  64. package/web-components/layout/flex-flow.js.map +1 -1
  65. package/web-components/layout/nav-layout.d.ts +10 -3
  66. package/web-components/layout/nav-layout.d.ts.map +1 -1
  67. package/web-components/layout/nav-layout.js +31 -101
  68. package/web-components/layout/nav-layout.js.map +1 -1
  69. package/web-components/loading/loading-progress.d.ts +1 -1
  70. package/web-components/loading/loading-progress.d.ts.map +1 -1
  71. package/web-components/loading/loading-progress.js +28 -28
  72. package/web-components/loading/loading-progress.js.map +1 -1
  73. package/web-components/loading/skeleton-screen.js +19 -19
  74. package/web-components/loading/skeleton-screen.js.map +1 -1
  75. package/web-components/open/open-details.d.ts.map +1 -1
  76. package/web-components/open/open-details.js +73 -22
  77. package/web-components/open/open-details.js.map +1 -1
  78. package/web-components/open/open-dialog.d.ts +5 -16
  79. package/web-components/open/open-dialog.d.ts.map +1 -1
  80. package/web-components/open/open-dialog.js +92 -102
  81. package/web-components/open/open-dialog.js.map +1 -1
  82. package/web-components/open/open-offset.d.ts +0 -1
  83. package/web-components/open/open-offset.d.ts.map +1 -1
  84. package/web-components/open/open-offset.js +50 -53
  85. package/web-components/open/open-offset.js.map +1 -1
  86. package/web-components/open/open-tooltip.d.ts +2 -2
  87. package/web-components/open/open-tooltip.d.ts.map +1 -1
  88. package/web-components/open/open-tooltip.js +14 -15
  89. package/web-components/open/open-tooltip.js.map +1 -1
  90. package/web-components/open/open.d.ts +3 -2
  91. package/web-components/open/open.d.ts.map +1 -1
  92. package/web-components/open/open.js +13 -59
  93. package/web-components/open/open.js.map +1 -1
  94. package/web-components/text/clip-text.js +8 -8
  95. package/web-components/text/clip-text.js.map +1 -1
  96. package/web-components/text/overbreath-text.js +17 -17
  97. package/web-components/text/overbreath-text.js.map +1 -1
  98. package/web-components/text/typewriter-text.js +32 -32
  99. package/web-components/text/typewriter-text.js.map +1 -1
  100. package/web-components/view/route-view.d.ts +2 -2
  101. package/web-components/view/route-view.js +7 -7
  102. package/web-components/view/route-view.js.map +1 -1
  103. package/web-components/view/wrap-view.d.ts +1 -1
  104. package/web-components/view/wrap-view.js +15 -15
  105. package/web-components/view/wrap-view.js.map +1 -1
  106. package/nav-aside.d.ts +0 -2
  107. package/nav-aside.d.ts.map +0 -1
  108. package/nav-aside.js +0 -2
  109. package/nav-aside.js.map +0 -1
  110. package/open-list.d.ts +0 -2
  111. package/open-list.d.ts.map +0 -1
  112. package/open-list.js +0 -2
  113. package/open-list.js.map +0 -1
  114. package/scroll-x.d.ts +0 -2
  115. package/scroll-x.d.ts.map +0 -1
  116. package/scroll-x.js +0 -2
  117. package/scroll-x.js.map +0 -1
  118. package/web-components/layout/index.d.ts +0 -5
  119. package/web-components/layout/index.d.ts.map +0 -1
  120. package/web-components/layout/index.js +0 -6
  121. package/web-components/layout/index.js.map +0 -1
  122. package/web-components/layout/nav-aside.d.ts +0 -25
  123. package/web-components/layout/nav-aside.d.ts.map +0 -1
  124. package/web-components/layout/nav-aside.js +0 -70
  125. package/web-components/layout/nav-aside.js.map +0 -1
  126. package/web-components/open/open-list.d.ts +0 -20
  127. package/web-components/open/open-list.d.ts.map +0 -1
  128. package/web-components/open/open-list.js +0 -71
  129. package/web-components/open/open-list.js.map +0 -1
  130. package/web-components/view/scroll-x.d.ts +0 -25
  131. package/web-components/view/scroll-x.d.ts.map +0 -1
  132. package/web-components/view/scroll-x.js +0 -97
  133. package/web-components/view/scroll-x.js.map +0 -1
@@ -42,9 +42,54 @@ let LabelInput = class LabelInput extends InputElement {
42
42
  */
43
43
  this.mobile = "540px";
44
44
  }
45
- static { this.styles = [
46
- InputElement.styles,
47
- css `
45
+ render() {
46
+ const result = html `<fieldset>
47
+ <i>${htmlSlot("pre")}</i>
48
+ <input .value="${this.value}" ?autofocus="${this.autofocus}" id="${this.name}" type="${this.type}" placeholder="${this.pla}" class="${this.type}" @input="${this._handleInput}" @change="${this._handleChange}" />
49
+ ${this.renderSuf()}
50
+ </fieldset>`;
51
+ if (this.label) {
52
+ const style = this.mobile && `${styleWithLabel}@media (max-width: ${this.mobile}){${styleInMedia}}`;
53
+ return [
54
+ html `<label for="${this.name}">
55
+ <span>${this.label}${htmlSlot()}</span>
56
+ ${result}
57
+ </label>`,
58
+ htmlStyle(style),
59
+ ];
60
+ }
61
+ return [result, htmlStyle(styleNoLabel.toString())];
62
+ }
63
+ renderSuf() {
64
+ if (this.type === PASSWORD) {
65
+ return html `<i
66
+ @mousedown="${this._passwordSwitcher}"
67
+ @mouseup="${() => {
68
+ this._changeInputType(PASSWORD);
69
+ }}"
70
+ @mouseleave="${() => {
71
+ this._changeInputType(PASSWORD);
72
+ }}"
73
+ >
74
+ ${htmlSlot("suf", svgEye(), this)}
75
+ </i>`;
76
+ }
77
+ else {
78
+ return html `<i>${htmlSlot("suf")}</i>`;
79
+ }
80
+ }
81
+ _passwordSwitcher() {
82
+ if (this._input.type === PASSWORD) {
83
+ this._changeInputType("text");
84
+ }
85
+ else {
86
+ this._changeInputType(PASSWORD);
87
+ }
88
+ }
89
+ };
90
+ LabelInput.styles = [
91
+ InputElement.styles,
92
+ css `
48
93
  :host {
49
94
  margin: var(${cssvarValues.input}--outline-width);
50
95
  border-radius: var(${cssvarValues.input}--radius);
@@ -102,52 +147,7 @@ let LabelInput = class LabelInput extends InputElement {
102
147
  min-width: var(${cssvarValues.input}--width);
103
148
  }
104
149
  `,
105
- ]; }
106
- render() {
107
- const result = html `<fieldset>
108
- <i>${htmlSlot("pre")}</i>
109
- <input .value="${this.value}" ?autofocus="${this.autofocus}" id="${this.name}" type="${this.type}" placeholder="${this.pla}" class="${this.type}" @input="${this._handleInput}" @change="${this._handleChange}" />
110
- ${this.renderSuf()}
111
- </fieldset>`;
112
- if (this.label) {
113
- const style = this.mobile && `${styleWithLabel}@media (max-width: ${this.mobile}){${styleInMedia}}`;
114
- return [
115
- html `<label for="${this.name}">
116
- <span>${this.label}${htmlSlot()}</span>
117
- ${result}
118
- </label>`,
119
- htmlStyle(style),
120
- ];
121
- }
122
- return [result, htmlStyle(styleNoLabel.toString())];
123
- }
124
- renderSuf() {
125
- if (this.type === PASSWORD) {
126
- return html `<i
127
- @mousedown="${this._passwordSwitcher}"
128
- @mouseup="${() => {
129
- this._changeInputType(PASSWORD);
130
- }}"
131
- @mouseleave="${() => {
132
- this._changeInputType(PASSWORD);
133
- }}"
134
- >
135
- ${htmlSlot("suf", svgEye(), this)}
136
- </i>`;
137
- }
138
- else {
139
- return html `<i>${htmlSlot("suf")}</i>`;
140
- }
141
- }
142
- _passwordSwitcher() {
143
- if (this._input.type === PASSWORD) {
144
- this._changeInputType("text");
145
- }
146
- else {
147
- this._changeInputType(PASSWORD);
148
- }
149
- }
150
- };
150
+ ];
151
151
  __decorate([
152
152
  property()
153
153
  ], LabelInput.prototype, "mobile", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"label-input.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/label-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAuB,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC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,CAAC;0CAA0B;AAN9B,UAAU;IADtB,MAAM,CAAC,UAAU,CAAC;GACN,UAAU,CAkHtB;;AAED,eAAe,UAAU,CAAC","sourcesContent":["import { css, type CSSResultGroup, html, property, query } from \"../../deps.js\";\nimport { htmlSlot, htmlStyle, type HTMLTemplate, svgEye } from \"../../lib/templates.js\";\nimport { cssvarValues, define } from \"../../root.js\";\nimport { InputElement } from \"./input.js\";\n\nconst PASSWORD = \"password\";\n\nconst styleInMedia = css`\n label[for] {\n justify-content: flex-start;\n flex-direction: column;\n align-items: inherit;\n width: fit-content;\n }\n :host {\n width: var(${cssvarValues.input}--width);\n margin: auto;\n }\n`;\n\nconst styleNoLabel = css`\n :host {\n width: var(${cssvarValues.input}--width);\n }\n`;\n\nconst styleWithLabel = css`\n :host {\n width: calc(var(${cssvarValues.input}--width) * 2);\n }\n`;\n\nconst defineName = \"label-input\";\n\n/**\n * LabelInput renders label and input.\n *\n * When there is a label, the layout will be adjusted according to the width of the screen.\n *\n * Otherwise it behaves similarly to the `BaseInput`.\n */\n@define(defineName)\nexport class LabelInput extends InputElement {\n /**\n * Conditions for adjust layout.\n */\n @property() mobile = \"540px\";\n\n @query(\"input\") _input: HTMLInputElement;\n\n static styles = [\n InputElement.styles,\n css`\n :host {\n margin: var(${cssvarValues.input}--outline-width);\n border-radius: var(${cssvarValues.input}--radius);\n }\n\n label {\n width: 100%;\n margin: auto;\n box-sizing: border-box;\n height: fit-content;\n display: flex;\n justify-content: space-between;\n align-items: center;\n border-radius: inherit;\n }\n\n span {\n white-space: nowrap;\n }\n\n input {\n padding: 0 0.25em;\n background-color: transparent;\n border-radius: inherit;\n flex: 1;\n width: 100%;\n height: inherit;\n }\n\n fieldset:focus-within {\n outline: var(${cssvarValues.input}--outline);\n }\n\n i {\n margin: auto;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n i > svg {\n height: 1em;\n width: 1em;\n margin: 0.25em;\n }\n\n fieldset {\n position: relative;\n background-color: var(${cssvarValues.input}--background);\n display: flex;\n align-items: center;\n border-radius: inherit;\n height: var(${cssvarValues.input}--height);\n width: var(${cssvarValues.input}--width);\n min-width: var(${cssvarValues.input}--width);\n }\n `,\n ] as CSSResultGroup;\n\n protected render(): HTMLTemplate[] {\n const result = html`<fieldset>\n <i>${htmlSlot(\"pre\")}</i>\n <input .value=\"${this.value}\" ?autofocus=\"${this.autofocus}\" id=\"${this.name}\" type=\"${this.type}\" placeholder=\"${this.pla}\" class=\"${this.type}\" @input=\"${this._handleInput}\" @change=\"${this._handleChange}\" />\n ${this.renderSuf()}\n </fieldset>`;\n if (this.label) {\n const style = this.mobile && `${styleWithLabel}@media (max-width: ${this.mobile}){${styleInMedia}}`;\n return [\n html`<label for=\"${this.name}\">\n <span>${this.label}${htmlSlot()}</span>\n ${result}\n </label>`,\n htmlStyle(style),\n ];\n }\n return [result, htmlStyle(styleNoLabel.toString())];\n }\n\n private renderSuf(): HTMLTemplate {\n if (this.type === PASSWORD) {\n return html`<i\n @mousedown=\"${this._passwordSwitcher}\"\n @mouseup=\"${() => {\n this._changeInputType(PASSWORD);\n }}\"\n @mouseleave=\"${() => {\n this._changeInputType(PASSWORD);\n }}\"\n >\n ${htmlSlot(\"suf\", svgEye(), this)}\n </i>`;\n } else {\n return html`<i>${htmlSlot(\"suf\")}</i>`;\n }\n }\n\n protected _passwordSwitcher() {\n if (this._input.type === PASSWORD) {\n this._changeInputType(\"text\");\n } else {\n this._changeInputType(PASSWORD);\n }\n }\n}\n\nexport default LabelInput;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"label-input\": LabelInput;\n }\n}\n"]}
1
+ {"version":3,"file":"label-input.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/label-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAuB,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAqB,MAAM,EAAE,MA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ACN,UAAU,CAkHtB;;AAED,eAAe,UAAU,CAAC","sourcesContent":["import { css, type CSSResultGroup, html, property, query } from \"../../deps.js\";\nimport { htmlSlot, htmlStyle, type HTMLTemplate, svgEye } from \"../../lib/templates.js\";\nimport { cssvarValues, define } from \"../../root.js\";\nimport { InputElement } from \"./input.js\";\n\nconst PASSWORD = \"password\";\n\nconst styleInMedia = css`\n label[for] {\n justify-content: flex-start;\n flex-direction: column;\n align-items: inherit;\n width: fit-content;\n }\n :host {\n width: var(${cssvarValues.input}--width);\n margin: auto;\n }\n`;\n\nconst styleNoLabel = css`\n :host {\n width: var(${cssvarValues.input}--width);\n }\n`;\n\nconst styleWithLabel = css`\n :host {\n width: calc(var(${cssvarValues.input}--width) * 2);\n }\n`;\n\nconst defineName = \"label-input\";\n\n/**\n * LabelInput renders label and input.\n *\n * When there is a label, the layout will be adjusted according to the width of the screen.\n *\n * Otherwise it behaves similarly to the `BaseInput`.\n */\n@define(defineName)\nexport class LabelInput extends InputElement {\n /**\n * Conditions for adjust layout.\n */\n @property() mobile = \"540px\";\n\n @query(\"input\") _input: HTMLInputElement;\n\n static styles = [\n InputElement.styles,\n css`\n :host {\n margin: var(${cssvarValues.input}--outline-width);\n border-radius: var(${cssvarValues.input}--radius);\n }\n\n label {\n width: 100%;\n margin: auto;\n box-sizing: border-box;\n height: fit-content;\n display: flex;\n justify-content: space-between;\n align-items: center;\n border-radius: inherit;\n }\n\n span {\n white-space: nowrap;\n }\n\n input {\n padding: 0 0.25em;\n background-color: transparent;\n border-radius: inherit;\n flex: 1;\n width: 100%;\n height: inherit;\n }\n\n fieldset:focus-within {\n outline: var(${cssvarValues.input}--outline);\n }\n\n i {\n margin: auto;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n i > svg {\n height: 1em;\n width: 1em;\n margin: 0.25em;\n }\n\n fieldset {\n position: relative;\n background-color: var(${cssvarValues.input}--background);\n display: flex;\n align-items: center;\n border-radius: inherit;\n height: var(${cssvarValues.input}--height);\n width: var(${cssvarValues.input}--width);\n min-width: var(${cssvarValues.input}--width);\n }\n `,\n ] as CSSResultGroup;\n\n protected render(): HTMLTemplate[] {\n const result = html`<fieldset>\n <i>${htmlSlot(\"pre\")}</i>\n <input .value=\"${this.value}\" ?autofocus=\"${this.autofocus}\" id=\"${this.name}\" type=\"${this.type}\" placeholder=\"${this.pla}\" class=\"${this.type}\" @input=\"${this._handleInput}\" @change=\"${this._handleChange}\" />\n ${this.renderSuf()}\n </fieldset>`;\n if (this.label) {\n const style = this.mobile && `${styleWithLabel}@media (max-width: ${this.mobile}){${styleInMedia}}`;\n return [\n html`<label for=\"${this.name}\">\n <span>${this.label}${htmlSlot()}</span>\n ${result}\n </label>`,\n htmlStyle(style),\n ];\n }\n return [result, htmlStyle(styleNoLabel.toString())];\n }\n\n private renderSuf(): HTMLTemplate {\n if (this.type === PASSWORD) {\n return html`<i\n @mousedown=\"${this._passwordSwitcher}\"\n @mouseup=\"${() => {\n this._changeInputType(PASSWORD);\n }}\"\n @mouseleave=\"${() => {\n this._changeInputType(PASSWORD);\n }}\"\n >\n ${htmlSlot(\"suf\", svgEye(), this)}\n </i>`;\n } else {\n return html`<i>${htmlSlot(\"suf\")}</i>`;\n }\n }\n\n protected _passwordSwitcher() {\n if (this._input.type === PASSWORD) {\n this._changeInputType(\"text\");\n } else {\n this._changeInputType(PASSWORD);\n }\n }\n}\n\nexport default LabelInput;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"label-input\": LabelInput;\n }\n}\n"]}
@@ -40,9 +40,58 @@ let SearchInput = class SearchInput extends InputElement {
40
40
  */
41
41
  this.name = "q";
42
42
  }
43
- static { this.styles = [
44
- InputElement.styles,
45
- css `
43
+ render() {
44
+ return html `<form action="${this.action}" method="${this.method}">
45
+ <div>
46
+ <input .value="${this.value}" ?autofocus="${this.autofocus}" name="${this.name}" @focus="${this._handleInput}" @input="${this._handleInput}" title="" placeholder="${this.pla}" />
47
+ <button @click="${this._handleSubmit}">${htmlSlot("search", svgSearch(), this)}</button>
48
+ </div>
49
+ <ul>
50
+ ${htmlSlot()}
51
+ </ul>
52
+ </form>`;
53
+ }
54
+ _handleSubmit(e) {
55
+ if (!this.action) {
56
+ e.preventDefault();
57
+ }
58
+ this.dispatchEvent(new CustomEvent("submit", { detail: this.value }));
59
+ }
60
+ _handleInput(e) {
61
+ e.stopPropagation();
62
+ const value = this.targetValue(e);
63
+ if (value === this.value) {
64
+ return;
65
+ }
66
+ this.value = value;
67
+ if (this.compositing) {
68
+ return;
69
+ }
70
+ if (this.target && this.query) {
71
+ this.searchElements(this.value);
72
+ }
73
+ this.dispatchEvent(new CustomEvent("input", { detail: this.value, bubbles: true, composed: true }));
74
+ this.dispatchEvent(new CustomEvent("change", { detail: this.value, composed: true }));
75
+ }
76
+ searchElements(s) {
77
+ const targetElement = document.body.querySelector(this.target);
78
+ const queryElementsCollection = document.body.querySelectorAll(this.query);
79
+ if (!targetElement) {
80
+ return;
81
+ }
82
+ targetElement.replaceChildren();
83
+ if (s && queryElementsCollection.length) {
84
+ for (const e of queryElementsCollection) {
85
+ if (e.textContent.includes(this.value)) {
86
+ targetElement.appendChild(e.cloneNode(true));
87
+ }
88
+ }
89
+ }
90
+ }
91
+ };
92
+ SearchInput.styles = [
93
+ InputElement.styles,
94
+ css `
46
95
  :host {
47
96
  ${cssScope}--width:var(${cssvarValues.input}--width);
48
97
  ${cssScope}--input-padding: 0 0 0 .35em;
@@ -126,56 +175,7 @@ let SearchInput = class SearchInput extends InputElement {
126
175
  padding: 1px;
127
176
  }
128
177
  `,
129
- ]; }
130
- render() {
131
- return html `<form action="${this.action}" method="${this.method}">
132
- <div>
133
- <input .value="${this.value}" ?autofocus="${this.autofocus}" name="${this.name}" @focus="${this._handleInput}" @input="${this._handleInput}" title="" placeholder="${this.pla}" />
134
- <button @click="${this._handleSubmit}">${htmlSlot("search", svgSearch(), this)}</button>
135
- </div>
136
- <ul>
137
- ${htmlSlot()}
138
- </ul>
139
- </form>`;
140
- }
141
- _handleSubmit(e) {
142
- if (!this.action) {
143
- e.preventDefault();
144
- }
145
- this.dispatchEvent(new CustomEvent("submit", { detail: this.value }));
146
- }
147
- _handleInput(e) {
148
- e.stopPropagation();
149
- const value = this.targetValue(e);
150
- if (value === this.value) {
151
- return;
152
- }
153
- this.value = value;
154
- if (this.compositing) {
155
- return;
156
- }
157
- if (this.target && this.query) {
158
- this.searchElements(this.value);
159
- }
160
- this.dispatchEvent(new CustomEvent("input", { detail: this.value, bubbles: true, composed: true }));
161
- this.dispatchEvent(new CustomEvent("change", { detail: this.value, composed: true }));
162
- }
163
- searchElements(s) {
164
- const targetElement = document.body.querySelector(this.target);
165
- const queryElementsCollection = document.body.querySelectorAll(this.query);
166
- if (!targetElement) {
167
- return;
168
- }
169
- targetElement.replaceChildren();
170
- if (s && queryElementsCollection.length) {
171
- for (const e of queryElementsCollection) {
172
- if (e.textContent.includes(this.value)) {
173
- targetElement.appendChild(e.cloneNode(true));
174
- }
175
- }
176
- }
177
- }
178
- };
178
+ ];
179
179
  __decorate([
180
180
  property()
181
181
  ], SearchInput.prototype, "query", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"search-input.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/search-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAuB,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAqB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,UAAU,GAAG,cAAc,CAAC;AAElC,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;AAEzC;;GAEG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,YAAY;IAAtC;;QACL;;W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QAChC,IAAI,CAAC,IAAI,uBAAuB,CAAC,MAAM,EAAE,CAAC;YACxC,KAAK,MAAM,CAAC,IAAI,uBAAuB,EAAE,CAAC;gBACxC,IAAI,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;oBACvC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC/C,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;;AAtKW;IAAX,QAAQ,EAAE;0CAAY;AAIX;IAAX,QAAQ,EAAE;2CAAa;AAIK;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAe;AAIC;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAe;AAI9C;IAAX,QAAQ,EAAE;2CAAa;AAIZ;IAAX,QAAQ,EAAE;2CAAgC;AAI/B;IAAX,QAAQ,EAAE;yCAAY;AAEP;IAAf,KAAK,CAAC,OAAO,CAAC;2CAA2B;AA9B/B,WAAW;IADvB,MAAM,CAAC,UAAU,CAAC;GACN,WAAW,CA2KvB;;AAED,eAAe,WAAW,CAAC","sourcesContent":["import { css, type CSSResultGroup, html, property, query } from \"../../deps.js\";\nimport { htmlSlot, type HTMLTemplate, svgSearch } from \"../../lib/templates.js\";\nimport { createScope, cssvarValues, define } from \"../../root.js\";\nimport { InputElement } from \"./input.js\";\n\nconst defineName = \"search-input\";\n\nconst cssScope = createScope(defineName);\n\n/**\n * SearchInput used for search behavior.\n */\n@define(defineName)\nexport class SearchInput extends InputElement {\n /**\n * Query selectors.\n */\n @property() query = \"\";\n /**\n * Target selectors.\n */\n @property() target = \"\";\n /**\n * Enable infer.\n */\n @property({ type: Boolean }) infer = false;\n /**\n * Float result.\n */\n @property({ type: Boolean, reflect: true }) float = false;\n /**\n * Form action.\n */\n @property() action = \"\";\n /**\n * Form method.\n */\n @property() method: \"get\" | \"post\" = \"get\";\n /**\n * Form name.\n */\n @property() name = \"q\";\n\n @query(\"input\") _input!: HTMLInputElement;\n\n static styles = [\n InputElement.styles,\n css`\n :host {\n ${cssScope}--width:var(${cssvarValues.input}--width);\n ${cssScope}--input-padding: 0 0 0 .35em;\n width: var(${cssvarValues.input}--width);\n margin: var(${cssvarValues.input}-outline-width);\n border-radius: var(${cssvarValues.input}--radius);\n background: var(${cssvarValues.input}--background);\n }\n\n div {\n padding: var(${cssScope}--input-padding);\n height: var(${cssvarValues.input}--height);\n flex: 1;\n display: flex;\n z-index: 2;\n }\n\n form {\n min-height: 100%;\n outline: 0.145em solid transparent;\n display: flex;\n flex-direction: column;\n border-radius: inherit;\n padding: 0;\n width: 100%;\n margin: 0;\n position: relative;\n overflow: hidden;\n }\n\n :host([float]) form {\n overflow: visible;\n }\n\n :host(:focus) form {\n outline: var(${cssvarValues.input}--outline);\n }\n\n ul {\n list-style: none;\n width: 100%;\n pointer-events: none;\n border-radius: inherit;\n z-index: 2;\n }\n\n :host([float]) ul {\n background: var(${cssvarValues.input}--background);\n padding-top: 1.5em;\n position: absolute;\n z-index: 1;\n top: 0;\n }\n\n :host([float]:focus) form {\n outline: none;\n }\n\n :host([float]:focus) ul {\n outline: var(${cssvarValues.input}--outline);\n }\n\n button,\n input {\n background: none;\n }\n\n button {\n width: 1.8em;\n height: inherit;\n }\n\n input {\n flex: 1;\n min-width: 0;\n box-sizing: border-box;\n }\n\n svg {\n height: 100%;\n padding: 1px;\n }\n `,\n ] as CSSResultGroup;\n\n protected render(): HTMLTemplate {\n return html`<form action=\"${this.action}\" method=\"${this.method}\">\n <div>\n <input .value=\"${this.value}\" ?autofocus=\"${this.autofocus}\" name=\"${this.name}\" @focus=\"${this._handleInput}\" @input=\"${this._handleInput}\" title=\"\" placeholder=\"${this.pla}\" />\n <button @click=\"${this._handleSubmit}\">${htmlSlot(\"search\", svgSearch(), this)}</button>\n </div>\n <ul>\n ${htmlSlot()}\n </ul>\n </form>`;\n }\n\n protected _handleSubmit(e: Event) {\n if (!this.action) {\n e.preventDefault();\n }\n this.dispatchEvent(new CustomEvent(\"submit\", { detail: this.value }));\n }\n\n protected _handleInput(e: Event) {\n e.stopPropagation();\n const value: string = this.targetValue(e);\n if (value === this.value) {\n return;\n }\n this.value = value;\n if (this.compositing) {\n return;\n }\n if (this.target && this.query) {\n this.searchElements(this.value);\n }\n this.dispatchEvent(new CustomEvent(\"input\", { detail: this.value, bubbles: true, composed: true }));\n this.dispatchEvent(new CustomEvent(\"change\", { detail: this.value, composed: true }));\n }\n\n searchElements(s: string) {\n const targetElement = document.body.querySelector(this.target);\n const queryElementsCollection = document.body.querySelectorAll(this.query);\n if (!targetElement) {\n return;\n }\n targetElement.replaceChildren();\n if (s && queryElementsCollection.length) {\n for (const e of queryElementsCollection) {\n if (e.textContent.includes(this.value)) {\n targetElement.appendChild(e.cloneNode(true));\n }\n }\n }\n }\n}\n\nexport default SearchInput;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"search-input\": SearchInput;\n }\n}\n"]}
1
+ {"version":3,"file":"search-input.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/search-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAuB,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAqB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,UAAU,GAAG,cAAc,CAAC;AAElC,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;AAEzC;;GAEG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,YAAY;IAAtC;;QACL;;WAEG;QACS,UAAK,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sBACjB,YAAY,CAAC,KAAK;6BACX,YAAY,CAAC,KAAK;0BACrB,YAAY,CAAC,KAAK;;;;uBAIrB,QAAQ;sBACT,YAAY,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;uBAwBjB,YAAY,CAAC,KAAK;;;;;;;;;;;;0BAYf,YAAY,CAAC,KAAK;;;;;;;;;;;;uBAYrB,YAAY,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;KAuBpC;CACgB,AAtFN,CAsFO;AAlHR;IAAX,QAAQ,EAAE;0CAAY;AAIX;IAAX,QAAQ,EAAE;2CAAa;AAIK;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAe;AAIC;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAe;AAI9C;IAAX,QAAQ,EAAE;2CAAa;AAIZ;IAAX,QAAQ,EAAE;2CAAgC;AAI/B;IAAX,QAAQ,EAAE;yCAAY;AAEP;IAAf,KAAK,CAAC,OAAO,CAAC;2CAA2B;AA9B/B,WAAW;IADvB,MAAM,CAAC,UAAU,CAAC;GACN,WAAW,CA2KvB;;AAED,eAAe,WAAW,CAAC","sourcesContent":["import { css, type CSSResultGroup, html, property, query } from \"../../deps.js\";\nimport { htmlSlot, type HTMLTemplate, svgSearch } from \"../../lib/templates.js\";\nimport { createScope, cssvarValues, define } from \"../../root.js\";\nimport { InputElement } from \"./input.js\";\n\nconst defineName = \"search-input\";\n\nconst cssScope = createScope(defineName);\n\n/**\n * SearchInput used for search behavior.\n */\n@define(defineName)\nexport class SearchInput extends InputElement {\n /**\n * Query selectors.\n */\n @property() query = \"\";\n /**\n * Target selectors.\n */\n @property() target = \"\";\n /**\n * Enable infer.\n */\n @property({ type: Boolean }) infer = false;\n /**\n * Float result.\n */\n @property({ type: Boolean, reflect: true }) float = false;\n /**\n * Form action.\n */\n @property() action = \"\";\n /**\n * Form method.\n */\n @property() method: \"get\" | \"post\" = \"get\";\n /**\n * Form name.\n */\n @property() name = \"q\";\n\n @query(\"input\") _input!: HTMLInputElement;\n\n static styles = [\n InputElement.styles,\n css`\n :host {\n ${cssScope}--width:var(${cssvarValues.input}--width);\n ${cssScope}--input-padding: 0 0 0 .35em;\n width: var(${cssvarValues.input}--width);\n margin: var(${cssvarValues.input}-outline-width);\n border-radius: var(${cssvarValues.input}--radius);\n background: var(${cssvarValues.input}--background);\n }\n\n div {\n padding: var(${cssScope}--input-padding);\n height: var(${cssvarValues.input}--height);\n flex: 1;\n display: flex;\n z-index: 2;\n }\n\n form {\n min-height: 100%;\n outline: 0.145em solid transparent;\n display: flex;\n flex-direction: column;\n border-radius: inherit;\n padding: 0;\n width: 100%;\n margin: 0;\n position: relative;\n overflow: hidden;\n }\n\n :host([float]) form {\n overflow: visible;\n }\n\n :host(:focus) form {\n outline: var(${cssvarValues.input}--outline);\n }\n\n ul {\n list-style: none;\n width: 100%;\n pointer-events: none;\n border-radius: inherit;\n z-index: 2;\n }\n\n :host([float]) ul {\n background: var(${cssvarValues.input}--background);\n padding-top: 1.5em;\n position: absolute;\n z-index: 1;\n top: 0;\n }\n\n :host([float]:focus) form {\n outline: none;\n }\n\n :host([float]:focus) ul {\n outline: var(${cssvarValues.input}--outline);\n }\n\n button,\n input {\n background: none;\n }\n\n button {\n width: 1.8em;\n height: inherit;\n }\n\n input {\n flex: 1;\n min-width: 0;\n box-sizing: border-box;\n }\n\n svg {\n height: 100%;\n padding: 1px;\n }\n `,\n ] as CSSResultGroup;\n\n protected render(): HTMLTemplate {\n return html`<form action=\"${this.action}\" method=\"${this.method}\">\n <div>\n <input .value=\"${this.value}\" ?autofocus=\"${this.autofocus}\" name=\"${this.name}\" @focus=\"${this._handleInput}\" @input=\"${this._handleInput}\" title=\"\" placeholder=\"${this.pla}\" />\n <button @click=\"${this._handleSubmit}\">${htmlSlot(\"search\", svgSearch(), this)}</button>\n </div>\n <ul>\n ${htmlSlot()}\n </ul>\n </form>`;\n }\n\n protected _handleSubmit(e: Event) {\n if (!this.action) {\n e.preventDefault();\n }\n this.dispatchEvent(new CustomEvent(\"submit\", { detail: this.value }));\n }\n\n protected _handleInput(e: Event) {\n e.stopPropagation();\n const value: string = this.targetValue(e);\n if (value === this.value) {\n return;\n }\n this.value = value;\n if (this.compositing) {\n return;\n }\n if (this.target && this.query) {\n this.searchElements(this.value);\n }\n this.dispatchEvent(new CustomEvent(\"input\", { detail: this.value, bubbles: true, composed: true }));\n this.dispatchEvent(new CustomEvent(\"change\", { detail: this.value, composed: true }));\n }\n\n searchElements(s: string) {\n const targetElement = document.body.querySelector(this.target);\n const queryElementsCollection = document.body.querySelectorAll(this.query);\n if (!targetElement) {\n return;\n }\n targetElement.replaceChildren();\n if (s && queryElementsCollection.length) {\n for (const e of queryElementsCollection) {\n if (e.textContent.includes(this.value)) {\n targetElement.appendChild(e.cloneNode(true));\n }\n }\n }\n }\n}\n\nexport default SearchInput;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"search-input\": SearchInput;\n }\n}\n"]}
@@ -32,94 +32,6 @@ let SelectInput = class SelectInput extends InputElement {
32
32
  */
33
33
  this.text = [];
34
34
  }
35
- static { this.styles = [
36
- InputElement.styles,
37
- css `
38
- :host {
39
- background: var(${cssvarValues.input}--background);
40
- margin: var(${cssvarValues.input}--outline-width);
41
- outline: var(${cssvarValues.input}--outline-width) solid transparent;
42
- height: var(${cssvarValues.input}--height);
43
- width: var(${cssvarValues.input}--width);
44
- border-radius: var(${cssvarValues.input}--radius);
45
- }
46
-
47
- :host([open]) {
48
- outline-color: var(${cssvarValues.input}--outline-color);
49
- }
50
-
51
- input {
52
- padding: 0 0 0 0.25em;
53
- background: none;
54
- cursor: inherit;
55
- height: 100%;
56
- width: 100%;
57
- box-sizing: border-box;
58
- border: inherit;
59
- outline: none;
60
- border-radius: inherit;
61
- flex: 1;
62
- }
63
-
64
- div {
65
- display: inline-flex;
66
- position: relative;
67
- width: 100%;
68
- border-radius: inherit;
69
- z-index: inherit;
70
- }
71
-
72
- label svg {
73
- height: 100%;
74
- }
75
-
76
- aside {
77
- margin-top: 1px;
78
- position: absolute;
79
- top: 100%;
80
- width: 100%;
81
- visibility: hidden;
82
- z-index: 1;
83
- border-radius: inherit;
84
- }
85
-
86
- section {
87
- max-width: calc(100% - 1.2em);
88
- height: 100%;
89
- overflow: hidden;
90
- pointer-events: none;
91
- border-radius: inherit;
92
- z-index: inherit;
93
- }
94
-
95
- i.selected-item {
96
- background: var(${cssvarValues.input}--true);
97
- border-radius: inherit;
98
- height: 100%;
99
- float: left;
100
- display: inline-flex;
101
- font-style: normal;
102
- align-items: center;
103
- padding-left: 0.1em;
104
- margin-left: 0.065em;
105
- }
106
-
107
- i:first-child {
108
- margin-left: 0;
109
- }
110
-
111
- i.selected-item svg {
112
- width: 1em;
113
- padding: 0 0.12em;
114
- height: 0.8em;
115
- pointer-events: all;
116
- }
117
-
118
- aside[open] {
119
- visibility: visible;
120
- }
121
- `,
122
- ]; }
123
35
  get assigned() {
124
36
  return super.assigned;
125
37
  }
@@ -309,6 +221,94 @@ let SelectInput = class SelectInput extends InputElement {
309
221
  }
310
222
  }
311
223
  };
224
+ SelectInput.styles = [
225
+ InputElement.styles,
226
+ css `
227
+ :host {
228
+ background: var(${cssvarValues.input}--background);
229
+ margin: var(${cssvarValues.input}--outline-width);
230
+ outline: var(${cssvarValues.input}--outline-width) solid transparent;
231
+ height: var(${cssvarValues.input}--height);
232
+ width: var(${cssvarValues.input}--width);
233
+ border-radius: var(${cssvarValues.input}--radius);
234
+ }
235
+
236
+ :host([open]) {
237
+ outline-color: var(${cssvarValues.input}--outline-color);
238
+ }
239
+
240
+ input {
241
+ padding: 0 0 0 0.25em;
242
+ background: none;
243
+ cursor: inherit;
244
+ height: 100%;
245
+ width: 100%;
246
+ box-sizing: border-box;
247
+ border: inherit;
248
+ outline: none;
249
+ border-radius: inherit;
250
+ flex: 1;
251
+ }
252
+
253
+ div {
254
+ display: inline-flex;
255
+ position: relative;
256
+ width: 100%;
257
+ border-radius: inherit;
258
+ z-index: inherit;
259
+ }
260
+
261
+ label svg {
262
+ height: 100%;
263
+ }
264
+
265
+ aside {
266
+ margin-top: 1px;
267
+ position: absolute;
268
+ top: 100%;
269
+ width: 100%;
270
+ visibility: hidden;
271
+ z-index: 1;
272
+ border-radius: inherit;
273
+ }
274
+
275
+ section {
276
+ max-width: calc(100% - 1.2em);
277
+ height: 100%;
278
+ overflow: hidden;
279
+ pointer-events: none;
280
+ border-radius: inherit;
281
+ z-index: inherit;
282
+ }
283
+
284
+ i.selected-item {
285
+ background: var(${cssvarValues.input}--true);
286
+ border-radius: inherit;
287
+ height: 100%;
288
+ float: left;
289
+ display: inline-flex;
290
+ font-style: normal;
291
+ align-items: center;
292
+ padding-left: 0.1em;
293
+ margin-left: 0.065em;
294
+ }
295
+
296
+ i:first-child {
297
+ margin-left: 0;
298
+ }
299
+
300
+ i.selected-item svg {
301
+ width: 1em;
302
+ padding: 0 0.12em;
303
+ height: 0.8em;
304
+ pointer-events: all;
305
+ }
306
+
307
+ aside[open] {
308
+ visibility: visible;
309
+ }
310
+ `,
311
+ ];
312
312
  __decorate([
313
313
  property({ type: Boolean, reflect: true })
314
314
  ], SelectInput.prototype, "open", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"select-input.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/select-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAuB,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAqB,QAAQ,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA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;IACH,CAAC;;AAhT2C;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAc;AAIb;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAc;AAI9B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;0CAAY;AAI1B;IAAX,QAAQ,EAAE;yCAAiB;AAID;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;yCAAqB;AA+F/B;IAAf,KAAK,CAAC,OAAO,CAAC;2CAA0B;AACzB;IAAf,KAAK,CAAC,OAAO,CAAC;2CAA0B;AApH9B,WAAW;IADvB,MAAM,CAAC,UAAU,CAAC;GACN,WAAW,CAqTvB;;AAED,eAAe,WAAW,CAAC;AAE3B,SAAS,kBAAkB,CAAC,CAAS,EAAE,CAAS;IAC9C,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import { css, type CSSResultGroup, html, property, query } from \"../../deps.js\";\nimport { ifValue } from \"../../lib/directives.js\";\nimport { htmlSlot, type HTMLTemplate, svgDelta, svgX } from \"../../lib/templates.js\";\nimport { cssvarValues, define, GodownElement } from \"../../root.js\";\nimport { InputElement } from \"./input.js\";\n\nconst defineName = \"select-input\";\n\n/**\n * SelectInput select matched elements.\n */\n@define(defineName)\nexport class SelectInput extends InputElement {\n /**\n * Open content.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n /**\n * Only a single option is allowed.\n */\n @property({ type: Boolean, reflect: true }) only = false;\n /**\n * Selected values.\n */\n @property({ type: Array }) value = [];\n /**\n * Input name.\n */\n @property() name = \"select\";\n /**\n * Selected texts.\n */\n @property({ type: Array }) text: string[] = [];\n\n static styles = [\n InputElement.styles,\n css`\n :host {\n background: var(${cssvarValues.input}--background);\n margin: var(${cssvarValues.input}--outline-width);\n outline: var(${cssvarValues.input}--outline-width) solid transparent;\n height: var(${cssvarValues.input}--height);\n width: var(${cssvarValues.input}--width);\n border-radius: var(${cssvarValues.input}--radius);\n }\n\n :host([open]) {\n outline-color: var(${cssvarValues.input}--outline-color);\n }\n\n input {\n padding: 0 0 0 0.25em;\n background: none;\n cursor: inherit;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n border: inherit;\n outline: none;\n border-radius: inherit;\n flex: 1;\n }\n\n div {\n display: inline-flex;\n position: relative;\n width: 100%;\n border-radius: inherit;\n z-index: inherit;\n }\n\n label svg {\n height: 100%;\n }\n\n aside {\n margin-top: 1px;\n position: absolute;\n top: 100%;\n width: 100%;\n visibility: hidden;\n z-index: 1;\n border-radius: inherit;\n }\n\n section {\n max-width: calc(100% - 1.2em);\n height: 100%;\n overflow: hidden;\n pointer-events: none;\n border-radius: inherit;\n z-index: inherit;\n }\n\n i.selected-item {\n background: var(${cssvarValues.input}--true);\n border-radius: inherit;\n height: 100%;\n float: left;\n display: inline-flex;\n font-style: normal;\n align-items: center;\n padding-left: 0.1em;\n margin-left: 0.065em;\n }\n\n i:first-child {\n margin-left: 0;\n }\n\n i.selected-item svg {\n width: 1em;\n padding: 0 0.12em;\n height: 0.8em;\n pointer-events: all;\n }\n\n aside[open] {\n visibility: visible;\n }\n `,\n ] as CSSResultGroup;\n\n get assigned() {\n return super.assigned as any;\n }\n\n @query(\"input\") _input: HTMLInputElement;\n @query(\"aside\") _aside: HTMLInputElement;\n\n protected render(): HTMLTemplate {\n return html` <div>\n <section>${this.renderList()}</section>\n <input\n ?autofocus=\"${this.autofocus}\"\n id=\"input\"\n @focus=\"${() => {\n this.open = true;\n }}\"\n @input=\"${this._handleInput}\"\n placeholder=\"${this.pla}\"\n />\n <label for=\"input\"> ${ifValue(this.children.length > 0, svgDelta())}</label>\n <aside ?open=\"${this.open}\">${htmlSlot()}</aside>\n </div>`;\n }\n\n private renderList(): HTMLTemplate[] {\n const itemTemplates = [];\n if (this.value.length) {\n for (const i in this.value) {\n itemTemplates.push(\n html`<i class=\"selected-item\">\n ${this.text[i] || this.value[i]}\n <div\n @click=\"${() => {\n this.select(this.value[i]);\n }}\"\n >\n ${svgX()}\n </div>\n </i>`,\n );\n }\n }\n return itemTemplates;\n }\n\n protected _focusCheck() {\n if (this.autofocus) {\n this._input?.focus();\n this.open = true;\n }\n }\n\n focus(options?: FocusOptions) {\n this._input?.focus(options);\n this.open = true;\n }\n\n connectedCallback() {\n GodownElement.prototype.connectedCallback.call(this);\n }\n\n getOptionValue(option: Element) {\n return (option as HTMLOptionElement).value || option.getAttribute(\"value\");\n }\n\n protected firstUpdated() {\n const defs = this.def.split(\";\");\n defs\n .filter((i) => i.trim())\n .forEach((i) => {\n this.select(i);\n });\n this._focusCheck();\n const CLICK = \"click\";\n (this.assigned as HTMLElement[]).forEach((option: HTMLElement) => {\n if (this.getOptionValue(option)) {\n this.addEvent(option, CLICK, () => {\n this.select(this.getOptionValue(option), option.textContent);\n });\n } else if (option.children) {\n [...option.children].forEach((option: HTMLElement) => {\n this.addEvent(option, CLICK, () => {\n this.select(this.getOptionValue(option), option.textContent);\n });\n });\n }\n });\n this.addEvent(this, \"change\", () => {\n this.open = !this.only;\n });\n this.addEvent(document, CLICK, (e) => {\n if (!this.contains(e.target as Node)) {\n this.open = false;\n }\n });\n }\n\n select(value: string, text?: string) {\n if (text === undefined || text === null) {\n this.assigned.some((option: HTMLElement) => {\n const optionValue = this.getOptionValue(option);\n if (optionValue) {\n if (optionValue === value) {\n text = option.textContent;\n return true;\n }\n } else if (option.children) {\n return [...option.children].some((subOption) => {\n const subOptionValue = this.getOptionValue(subOption);\n if (subOptionValue === value) {\n text = subOption.textContent;\n return true;\n }\n return false;\n });\n }\n return false;\n });\n }\n if (this.value.includes(value)) {\n if (!this.only) {\n this.value = this.value.filter((v) => v !== value);\n this.text = this.text.filter((v) => v !== text);\n } else {\n this.value = [];\n this.text = [];\n }\n } else {\n if (!this.only) {\n this.value.push(value);\n this.text.push(text);\n } else {\n this.value = [value];\n this.text = [text];\n }\n }\n this._input.value = \"\";\n this.dispatchEvent(new CustomEvent(\"change\", { detail: this.namevalue() }));\n this.requestUpdate();\n }\n\n protected _handleInput() {\n const BLOCK = \"block\";\n const NONE = \"none\";\n let value = this._input.value.trim();\n if (!this.only && value.includes(\";\")) {\n value = value.split(\";\").pop().trim();\n }\n this.assigned.forEach((option) => {\n if (this.getOptionValue(option)) {\n option.style.display = BLOCK;\n }\n if (option.children) {\n option.style.display = BLOCK;\n [...option.children].forEach((subOption) => {\n subOption.style.display = BLOCK;\n });\n }\n });\n if (value) {\n this.assigned.forEach((option) => {\n const optionValue = this.getOptionValue(option);\n if (optionValue) {\n const isMatch = includesIgnoreCase(optionValue, value) || includesIgnoreCase(option.innerText, value);\n option.style.display = isMatch ? BLOCK : NONE;\n } else if (option.children) {\n [...option.children].forEach((subOption) => {\n const subOptionValue = this.getOptionValue(subOption);\n const isSubMatch = includesIgnoreCase(subOptionValue, value) || includesIgnoreCase(subOption.innerText, value);\n subOption.style.display = isSubMatch ? BLOCK : NONE;\n });\n if ([...option.children].filter((option) => option.style.display === BLOCK).length === 0) {\n option.style.display = NONE;\n }\n }\n });\n }\n this.dispatchEvent(new CustomEvent(\"input\", { detail: this.namevalue() }));\n }\n\n namevalue(): [string, any[]] | [string, any] {\n return [this.name, this.only ? this.value[0] : this.value];\n }\n\n reset() {\n this.value = [];\n this.text = [];\n this._input.value = \"\";\n if (this.def) {\n const defs = this.def.split(\";\");\n const defToSelect = this.only ? [defs[0]] : defs;\n defToSelect\n .filter((def) => def.trim())\n .forEach((def) => {\n this.select(def.trim(), null);\n });\n }\n }\n}\n\nexport default SelectInput;\n\nfunction includesIgnoreCase(a: string, b: string): boolean {\n return a.toLowerCase().includes(b.toLowerCase());\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"select-input\": SelectInput;\n }\n}\n"]}
1
+ {"version":3,"file":"select-input.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/select-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAuB,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAqB,QAAQ,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,UAAU,GAAG,cAAc,CAAC;AAElC;;GAEG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,YAAY;IAAtC;;QACL;;WAEG;QACyC,SAAI,GAAG,KAAK,CAAC;QACzD;;WAEG;QACyC,SAAI,GAAG,KAAK,CAAC;QACzD;;WAEG;QACwB,UAAK,GAAG,EAAE,CAAC;QACtC;;WAEG;QACS,SAAI,GAAG,QAAQ,CAAC;QAC5B;;WAEG;QACwB,SAAI,GAAa,EAAE,CAAC;IAiSjD,CAAC;IAtMC,IAAI,QAAQ;QACV,OAAO,KAAK,CAAC,QAAe,CAAC;IAC/B,CAAC;IAKS,MAAM;QACd,OAAO,IAAI,CAAA;iBACE,IAAI,CAAC,UAAU,EAAE;;sBAEZ,IAAI,CAAC,SAAS;;kBAElB,GAAG,EAAE;YACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;kBACS,IAAI,CAAC,YAAY;uBACZ,IAAI,CAAC,GAAG;;4BAEH,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC;sBACnD,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;WACnC,CAAC;IACV,CAAC;IAEO,UAAU;QAChB,MAAM,aAAa,GAAG,E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C,CAAC,CAAC,CAAC;QACP,CAAC;IACH,CAAC;;AA9RM,kBAAM,GAAG;IACd,YAAY,CAAC,MAAM;IACnB,GAAG,CAAA;;0BAEmB,YAAY,CAAC,KAAK;sBACtB,YAAY,CAAC,KAAK;uBACjB,YAAY,CAAC,KAAK;sBACnB,YAAY,CAAC,KAAK;qBACnB,YAAY,CAAC,KAAK;6BACV,YAAY,CAAC,KAAK;;;;6BAIlB,YAAY,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAgDrB,YAAY,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;KAyBvC;CACgB,AAvFN,CAuFO;AAzGwB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAc;AAIb;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAc;AAI9B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;0CAAY;AAI1B;IAAX,QAAQ,EAAE;yCAAiB;AAID;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;yCAAqB;AA+F/B;IAAf,KAAK,CAAC,OAAO,CAAC;2CAA0B;AACzB;IAAf,KAAK,CAAC,OAAO,CAAC;2CAA0B;AApH9B,WAAW;IADvB,MAAM,CAAC,UAAU,CAAC;GACN,WAAW,CAqTvB;;AAED,eAAe,WAAW,CAAC;AAE3B,SAAS,kBAAkB,CAAC,CAAS,EAAE,CAAS;IAC9C,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import { css, type CSSResultGroup, html, property, query } from \"../../deps.js\";\nimport { ifValue } from \"../../lib/directives.js\";\nimport { htmlSlot, type HTMLTemplate, svgDelta, svgX } from \"../../lib/templates.js\";\nimport { cssvarValues, define, GodownElement } from \"../../root.js\";\nimport { InputElement } from \"./input.js\";\n\nconst defineName = \"select-input\";\n\n/**\n * SelectInput select matched elements.\n */\n@define(defineName)\nexport class SelectInput extends InputElement {\n /**\n * Open content.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n /**\n * Only a single option is allowed.\n */\n @property({ type: Boolean, reflect: true }) only = false;\n /**\n * Selected values.\n */\n @property({ type: Array }) value = [];\n /**\n * Input name.\n */\n @property() name = \"select\";\n /**\n * Selected texts.\n */\n @property({ type: Array }) text: string[] = [];\n\n static styles = [\n InputElement.styles,\n css`\n :host {\n background: var(${cssvarValues.input}--background);\n margin: var(${cssvarValues.input}--outline-width);\n outline: var(${cssvarValues.input}--outline-width) solid transparent;\n height: var(${cssvarValues.input}--height);\n width: var(${cssvarValues.input}--width);\n border-radius: var(${cssvarValues.input}--radius);\n }\n\n :host([open]) {\n outline-color: var(${cssvarValues.input}--outline-color);\n }\n\n input {\n padding: 0 0 0 0.25em;\n background: none;\n cursor: inherit;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n border: inherit;\n outline: none;\n border-radius: inherit;\n flex: 1;\n }\n\n div {\n display: inline-flex;\n position: relative;\n width: 100%;\n border-radius: inherit;\n z-index: inherit;\n }\n\n label svg {\n height: 100%;\n }\n\n aside {\n margin-top: 1px;\n position: absolute;\n top: 100%;\n width: 100%;\n visibility: hidden;\n z-index: 1;\n border-radius: inherit;\n }\n\n section {\n max-width: calc(100% - 1.2em);\n height: 100%;\n overflow: hidden;\n pointer-events: none;\n border-radius: inherit;\n z-index: inherit;\n }\n\n i.selected-item {\n background: var(${cssvarValues.input}--true);\n border-radius: inherit;\n height: 100%;\n float: left;\n display: inline-flex;\n font-style: normal;\n align-items: center;\n padding-left: 0.1em;\n margin-left: 0.065em;\n }\n\n i:first-child {\n margin-left: 0;\n }\n\n i.selected-item svg {\n width: 1em;\n padding: 0 0.12em;\n height: 0.8em;\n pointer-events: all;\n }\n\n aside[open] {\n visibility: visible;\n }\n `,\n ] as CSSResultGroup;\n\n get assigned() {\n return super.assigned as any;\n }\n\n @query(\"input\") _input: HTMLInputElement;\n @query(\"aside\") _aside: HTMLInputElement;\n\n protected render(): HTMLTemplate {\n return html` <div>\n <section>${this.renderList()}</section>\n <input\n ?autofocus=\"${this.autofocus}\"\n id=\"input\"\n @focus=\"${() => {\n this.open = true;\n }}\"\n @input=\"${this._handleInput}\"\n placeholder=\"${this.pla}\"\n />\n <label for=\"input\"> ${ifValue(this.children.length > 0, svgDelta())}</label>\n <aside ?open=\"${this.open}\">${htmlSlot()}</aside>\n </div>`;\n }\n\n private renderList(): HTMLTemplate[] {\n const itemTemplates = [];\n if (this.value.length) {\n for (const i in this.value) {\n itemTemplates.push(\n html`<i class=\"selected-item\">\n ${this.text[i] || this.value[i]}\n <div\n @click=\"${() => {\n this.select(this.value[i]);\n }}\"\n >\n ${svgX()}\n </div>\n </i>`,\n );\n }\n }\n return itemTemplates;\n }\n\n protected _focusCheck() {\n if (this.autofocus) {\n this._input?.focus();\n this.open = true;\n }\n }\n\n focus(options?: FocusOptions) {\n this._input?.focus(options);\n this.open = true;\n }\n\n connectedCallback() {\n GodownElement.prototype.connectedCallback.call(this);\n }\n\n getOptionValue(option: Element) {\n return (option as HTMLOptionElement).value || option.getAttribute(\"value\");\n }\n\n protected firstUpdated() {\n const defs = this.def.split(\";\");\n defs\n .filter((i) => i.trim())\n .forEach((i) => {\n this.select(i);\n });\n this._focusCheck();\n const CLICK = \"click\";\n (this.assigned as HTMLElement[]).forEach((option: HTMLElement) => {\n if (this.getOptionValue(option)) {\n this.addEvent(option, CLICK, () => {\n this.select(this.getOptionValue(option), option.textContent);\n });\n } else if (option.children) {\n [...option.children].forEach((option: HTMLElement) => {\n this.addEvent(option, CLICK, () => {\n this.select(this.getOptionValue(option), option.textContent);\n });\n });\n }\n });\n this.addEvent(this, \"change\", () => {\n this.open = !this.only;\n });\n this.addEvent(document, CLICK, (e) => {\n if (!this.contains(e.target as Node)) {\n this.open = false;\n }\n });\n }\n\n select(value: string, text?: string) {\n if (text === undefined || text === null) {\n this.assigned.some((option: HTMLElement) => {\n const optionValue = this.getOptionValue(option);\n if (optionValue) {\n if (optionValue === value) {\n text = option.textContent;\n return true;\n }\n } else if (option.children) {\n return [...option.children].some((subOption) => {\n const subOptionValue = this.getOptionValue(subOption);\n if (subOptionValue === value) {\n text = subOption.textContent;\n return true;\n }\n return false;\n });\n }\n return false;\n });\n }\n if (this.value.includes(value)) {\n if (!this.only) {\n this.value = this.value.filter((v) => v !== value);\n this.text = this.text.filter((v) => v !== text);\n } else {\n this.value = [];\n this.text = [];\n }\n } else {\n if (!this.only) {\n this.value.push(value);\n this.text.push(text);\n } else {\n this.value = [value];\n this.text = [text];\n }\n }\n this._input.value = \"\";\n this.dispatchEvent(new CustomEvent(\"change\", { detail: this.namevalue() }));\n this.requestUpdate();\n }\n\n protected _handleInput() {\n const BLOCK = \"block\";\n const NONE = \"none\";\n let value = this._input.value.trim();\n if (!this.only && value.includes(\";\")) {\n value = value.split(\";\").pop().trim();\n }\n this.assigned.forEach((option) => {\n if (this.getOptionValue(option)) {\n option.style.display = BLOCK;\n }\n if (option.children) {\n option.style.display = BLOCK;\n [...option.children].forEach((subOption) => {\n subOption.style.display = BLOCK;\n });\n }\n });\n if (value) {\n this.assigned.forEach((option) => {\n const optionValue = this.getOptionValue(option);\n if (optionValue) {\n const isMatch = includesIgnoreCase(optionValue, value) || includesIgnoreCase(option.innerText, value);\n option.style.display = isMatch ? BLOCK : NONE;\n } else if (option.children) {\n [...option.children].forEach((subOption) => {\n const subOptionValue = this.getOptionValue(subOption);\n const isSubMatch = includesIgnoreCase(subOptionValue, value) || includesIgnoreCase(subOption.innerText, value);\n subOption.style.display = isSubMatch ? BLOCK : NONE;\n });\n if ([...option.children].filter((option) => option.style.display === BLOCK).length === 0) {\n option.style.display = NONE;\n }\n }\n });\n }\n this.dispatchEvent(new CustomEvent(\"input\", { detail: this.namevalue() }));\n }\n\n namevalue(): [string, any[]] | [string, any] {\n return [this.name, this.only ? this.value[0] : this.value];\n }\n\n reset() {\n this.value = [];\n this.text = [];\n this._input.value = \"\";\n if (this.def) {\n const defs = this.def.split(\";\");\n const defToSelect = this.only ? [defs[0]] : defs;\n defToSelect\n .filter((def) => def.trim())\n .forEach((def) => {\n this.select(def.trim(), null);\n });\n }\n }\n}\n\nexport default SelectInput;\n\nfunction includesIgnoreCase(a: string, b: string): boolean {\n return a.toLowerCase().includes(b.toLowerCase());\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"select-input\": SelectInput;\n }\n}\n"]}