@operato/input 9.0.0-beta.11 → 9.0.0-beta.15

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.
@@ -9,6 +9,9 @@ import '@operato/i18n/ox-i18n.js';
9
9
  import './ox-input-color.js';
10
10
  import { css, html } from 'lit';
11
11
  import { customElement, property, query } from 'lit/decorators.js';
12
+ import { PropertyGridStyles } from '@operato/styles/property-grid-styles.js';
13
+ import { TableEventStyles } from '@operato/styles/table-event-styles.js';
14
+ import { LineStyles } from '@operato/styles/line-styles.js';
12
15
  import { OxFormField } from './ox-form-field.js';
13
16
  /**
14
17
  * 테이블 셀의 좌,우,상,하 경계선의 스타일을 편집하는 컴포넌트이다.
@@ -26,6 +29,9 @@ let OxInputTable = class OxInputTable extends OxFormField {
26
29
  }
27
30
  static get styles() {
28
31
  return [
32
+ PropertyGridStyles,
33
+ LineStyles,
34
+ TableEventStyles,
29
35
  css `
30
36
  :host {
31
37
  display: block;
@@ -48,140 +54,45 @@ let OxInputTable = class OxInputTable extends OxFormField {
48
54
  text-transform: capitalize;
49
55
  }
50
56
 
51
- .icon-only-label {
52
- background: url(/assets/images/icon-properties-label.png) no-repeat;
53
- width: 30px;
54
- height: 24px;
55
- }
56
-
57
- .property-grid {
57
+ #border-set {
58
58
  display: grid;
59
- grid-template-columns: repeat(10, 1fr);
59
+ grid-template-columns: repeat(5, 1fr);
60
60
  grid-gap: 5px;
61
- grid-auto-rows: minmax(24px, auto);
62
- margin: 10px 0 0 0;
63
- }
64
-
65
- .property-grid > * {
66
- line-height: 1.5;
61
+ margin: 5px 0;
62
+ place-items: center;
67
63
  }
68
64
 
69
65
  #border-set > md-icon {
70
- grid-column: span 2;
71
66
  margin: 0 0 0 8px;
72
67
  width: 32px;
73
68
  height: 32px;
74
69
  }
75
70
 
76
- .property-grid > label {
77
- grid-column: span 3;
78
- text-align: right;
79
- text-transform: capitalize;
80
- }
81
-
82
- .property-grid > label.icon-only-label {
83
- grid-column: span 1;
84
- }
85
-
86
- .property-grid > ox-input-color,
87
- .property-grid > input[type='number'] {
88
- grid-column: span 4;
89
- padding: 0;
90
- margin: 0;
91
- }
92
-
93
- .property-grid > paper-dropdown-menu {
94
- grid-column: span 7;
95
- padding: 0;
96
- margin: 0;
71
+ #table-event {
72
+ display: grid;
73
+ grid-template-columns: repeat(5, 1fr);
74
+ grid-gap: 5px;
75
+ margin: 5px 0;
76
+ place-items: center;
97
77
  }
98
78
 
99
- [table-event] {
79
+ .table-event {
100
80
  position: relative;
101
- background: url('/assets/images/icon-properties-table.png') no-repeat;
102
- grid-column: span 2;
81
+ width: 100%;
103
82
  min-height: 65px;
83
+ place-items: center;
104
84
  }
105
85
 
106
- [table-event] span {
86
+ .table-event span {
107
87
  position: absolute;
108
88
  bottom: 0;
89
+ width: 100%;
109
90
  font-size: 0.9em;
110
91
  line-height: 1.2;
111
92
  text-transform: capitalize;
112
93
  text-align: center;
113
94
  vertical-align: bottom;
114
95
  }
115
-
116
- #merge-cells {
117
- background-position: 50% 3px;
118
- }
119
-
120
- #split-cells {
121
- background-position: 50% -97px;
122
- }
123
-
124
- #delete-row {
125
- background-position: 50% -197px;
126
- }
127
-
128
- #delete-column {
129
- background-position: 50% -297px;
130
- }
131
-
132
- #insert-above {
133
- background-position: 50% -397px;
134
- }
135
-
136
- #insert-below {
137
- background-position: 50% -497px;
138
- }
139
-
140
- #insert-left {
141
- background-position: 50% -597px;
142
- }
143
-
144
- #insert-right {
145
- background-position: 50% -697px;
146
- }
147
-
148
- #distribute-horizontal {
149
- background-position: 50% -797px;
150
- }
151
-
152
- #distribute-vertical {
153
- background-position: 50% -897px;
154
- }
155
-
156
- .line-type paper-item {
157
- background: no-repeat url(/assets/images/icon-properties-line-type.png);
158
- width: 80px;
159
- min-height: 25px;
160
- }
161
- .line-type paper-item.solid {
162
- background-position: 50% 12px;
163
- }
164
- .line-type paper-item.round-dot {
165
- background-position: 50% -38px;
166
- }
167
- .line-type paper-item.square-dot {
168
- background-position: 50% -88px;
169
- }
170
- .line-type paper-item.dash {
171
- background-position: 50% -138px;
172
- }
173
- .line-type paper-item.dash-dot {
174
- background-position: 50% -188px;
175
- }
176
- .line-type paper-item.long-dash {
177
- background-position: 50% -238px;
178
- }
179
- .line-type paper-item.long-dash-dot {
180
- background-position: 50% -288px;
181
- }
182
- .line-type paper-item.long-dash-dot-dot {
183
- background-position: 50% -338px;
184
- }
185
96
  `
186
97
  ];
187
98
  }
@@ -195,7 +106,6 @@ let OxInputTable = class OxInputTable extends OxFormField {
195
106
 
196
107
  <div
197
108
  id="border-set"
198
- class="property-grid
199
109
  border-style-btn"
200
110
  @click=${(e) => this._onClickType(e)}
201
111
  >
@@ -212,64 +122,64 @@ let OxInputTable = class OxInputTable extends OxFormField {
212
122
  </div>
213
123
 
214
124
  <div class="property-grid">
215
- <label class="icon-only-label linewidth"> </label>
125
+
126
+ <label> <ox-i18n msgid="label.border-type">border type</ox-i18n> </label>
127
+ <ox-select value-key="lineDash" .value=${this.borderStyle} class="custom-editor">
128
+ <div class="line-type ${this.borderStyle}" slot="label"></div>
129
+ <ox-popup-list align-left nowrap>
130
+ <style>
131
+ ${LineStyles.cssText}
132
+ </style>
133
+ <div class="line-type solid" value="solid" option></div>
134
+ <div class="line-type round-dot" value="round-dot" option></div>
135
+ <div class="line-type square-dot" value="square-dot" option></div>
136
+ <div class="line-type dash" value="dash" option></div>
137
+ <div class="line-type dash-dot" value="dash-dot" option></div>
138
+ <div class="line-type long-dash" value="long-dash" option></div>
139
+ <div class="line-type long-dash-dot" value="long-dash-dot" option></div>
140
+ <div class="line-type long-dash-dot-dot" value="long-dash-dot-dot" option></div>
141
+ </ox-popup-list>
142
+ </ox-select>
143
+
144
+ <label class="property-half-label"> <md-icon>line_weight</md-icon></label>
216
145
  <input
217
146
  type="number"
218
147
  id="border-width"
148
+ class="property-half-input"
219
149
  @change=${(e) => (this.borderWidth = Number(e.target.value))}
220
- .value=${this.borderWidth}
150
+ .value=${String(this.borderWidth || '')}
221
151
  />
222
152
 
223
- <label class="icon-only-label color"> </label>
153
+ <label class="property-half-label"> <md-icon>border_color</md-icon></label>
224
154
  <ox-input-color
225
155
  id="border-color"
156
+ class="property-half-input"
226
157
  @change=${(e) => (this.borderColor = e.target.value)}
227
158
  .value=${this.borderColor}
228
159
  >
229
160
  </ox-input-color>
230
-
231
- <label> <ox-i18n msgid="label.border-type">border type</ox-i18n> </label>
232
- <paper-dropdown-menu no-label-float="true" class="line-type solid">
233
- <!-- solid는 선택된 항목 보여주기위한 class로 하위 paper-item의 class와 동일하게 -->
234
- <paper-listbox
235
- id="border-style"
236
- @iron-select=${(e) => (this.borderStyle = e.target.selected)}
237
- slot="dropdown-content"
238
- .selected=${this.borderStyle}
239
- attr-for-selected="name"
240
- >
241
- <paper-item class="solid" name="solid"></paper-item>
242
- <paper-item class="round-dot" name="round-dot"></paper-item>
243
- <paper-item class="square-dot" name="square-dot"></paper-item>
244
- <paper-item class="dash" name="dash"></paper-item>
245
- <paper-item class="dash-dot" name="dash-dot"></paper-item>
246
- <paper-item class="long-dash" name="long-dash"></paper-item>
247
- <paper-item class="long-dash-dot" name="long-dash-dot"></paper-item>
248
- <paper-item class="long-dash-dot-dot" name="long-dash-dot-dot"></paper-item>
249
- </paper-listbox>
250
- </paper-dropdown-menu>
251
161
  </div>
252
162
  </fieldset>
253
163
 
254
164
  <fieldset id="cell-fieldset" @click=${(e) => this._onClickCell(e)}>
255
- <div class="property-grid">
256
- <div id="merge-cells" table-event><span>merge cells</span></div>
257
- <div id="split-cells" table-event><span>split cells</span></div>
258
- <div id="delete-row" table-event><span>delete row</span></div>
259
- <div id="delete-column" table-event><span>delete column</span></div>
260
- <div id="insert-above" table-event><span>insert above</span></div>
261
- <div id="insert-below" table-event><span>insert below</span></div>
262
- <div id="insert-left" table-event><span>insert left</span></div>
263
- <div id="insert-right" table-event><span>insert right</span></div>
264
- <div id="distribute-horizontal" table-event><span>distribute horizontal</span></div>
265
- <div id="distribute-vertical" table-event><span>distribute vertical</span></div>
165
+ <div id="table-event">
166
+ <div name="merge-cells" class="table-event"><span>merge cells</span></div>
167
+ <div name="split-cells" class="table-event"><span>split cells</span></div>
168
+ <div name="delete-row" class="table-event"><span>delete row</span></div>
169
+ <div name="delete-column" class="table-event"><span>delete column</span></div>
170
+ <div name="insert-above" class="table-event"><span>insert above</span></div>
171
+ <div name="insert-below" class="table-event"><span>insert below</span></div>
172
+ <div name="insert-left" class="table-event"><span>insert left</span></div>
173
+ <div name="insert-right" class="table-event"><span>insert right</span></div>
174
+ <div name="distribute-horizontal" class="table-event"><span>distribute horizontal</span></div>
175
+ <div name="distribute-vertical" class="table-event"><span>distribute vertical</span></div>
266
176
  </div>
267
177
  </fieldset>
268
178
  `;
269
179
  }
270
180
  _onClickCell(e) {
271
181
  var target = e.target;
272
- const event = target?.closest('[table-event]')?.getAttribute('id');
182
+ const event = target?.closest('[table-event]')?.getAttribute('name');
273
183
  if (!event) {
274
184
  return;
275
185
  }
@@ -377,4 +287,5 @@ __decorate([
377
287
  OxInputTable = __decorate([
378
288
  customElement('ox-input-table')
379
289
  ], OxInputTable);
290
+ export { OxInputTable };
380
291
  //# sourceMappingURL=ox-input-table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ox-input-table.js","sourceRoot":"","sources":["../../src/ox-input-table.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AACnC,OAAO,qDAAqD,CAAA;AAC5D,OAAO,mCAAmC,CAAA;AAC1C,OAAO,0BAA0B,CAAA;AACjC,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAYhD;;;;;GAKG;AAGH,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ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C;aACF;SACF,CAAC,CACH,CAAA;QAED,IAAI,CAAC,KAAK,GAAG;YACX,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAA;QAED,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;YACxB,MAAM,EAAE,IAAI,CAAC,KAAK;YAClB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAA;QAED,CAAC,CAAC,eAAe,EAAE,CAAA;IACrB,CAAC;CACF,CAAA;AA/M6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAwB;AACvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAA8B;AAC7B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAmC;AAClC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAkB;AAElB;IAA1B,KAAK,CAAC,kBAAkB,CAAC;oDAA6B;AAxKnD,YAAY;IADjB,aAAa,CAAC,gBAAgB,CAAC;GAC1B,YAAY,CAkXjB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/icon/icon.js'\nimport '@polymer/paper-dropdown-menu/paper-dropdown-menu.js'\nimport '@polymer/paper-item/paper-item.js'\nimport '@operato/i18n/ox-i18n.js'\nimport './ox-input-color.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field.js'\n\ntype BorderStyle =\n | 'solid'\n | 'round-dot'\n | 'square-dot'\n | 'dash'\n | 'dash-dot'\n | 'long-dash'\n | 'long-dash-dot'\n | 'long-dash-dot-dot'\n\n/**\n * 테이블 셀의 좌,우,상,하 경계선의 스타일을 편집하는 컴포넌트이다.\n * Example:\n * <ox-input-table value=${border}>\n * </ox-input-table>\n */\n\n@customElement('ox-input-table')\nclass OxInputTable extends OxFormField {\n static get styles() {\n return [\n css`\n :host {\n display: block;\n }\n\n fieldset {\n border: none;\n border-bottom: 1px solid #cfd8dc;\n color: var(--md-sys-color-on-primary-container);\n font-size: 12px;\n padding: 0 0 10px 0;\n margin: 0 0 10px 0;\n }\n\n fieldset legend {\n padding: 5px 0 0 5px;\n font-size: 11px;\n color: #e46c2e;\n font-weight: bold;\n text-transform: capitalize;\n }\n\n .icon-only-label {\n background: url(/assets/images/icon-properties-label.png) no-repeat;\n width: 30px;\n height: 24px;\n }\n\n .property-grid {\n display: grid;\n grid-template-columns: repeat(10, 1fr);\n grid-gap: 5px;\n grid-auto-rows: minmax(24px, auto);\n margin: 10px 0 0 0;\n }\n\n .property-grid > * {\n line-height: 1.5;\n }\n\n #border-set > md-icon {\n grid-column: span 2;\n margin: 0 0 0 8px;\n width: 32px;\n height: 32px;\n }\n\n .property-grid > label {\n grid-column: span 3;\n text-align: right;\n text-transform: capitalize;\n }\n\n .property-grid > label.icon-only-label {\n grid-column: span 1;\n }\n\n .property-grid > ox-input-color,\n .property-grid > input[type='number'] {\n grid-column: span 4;\n padding: 0;\n margin: 0;\n }\n\n .property-grid > paper-dropdown-menu {\n grid-column: span 7;\n padding: 0;\n margin: 0;\n }\n\n [table-event] {\n position: relative;\n background: url('/assets/images/icon-properties-table.png') no-repeat;\n grid-column: span 2;\n min-height: 65px;\n }\n\n [table-event] span {\n position: absolute;\n bottom: 0;\n font-size: 0.9em;\n line-height: 1.2;\n text-transform: capitalize;\n text-align: center;\n vertical-align: bottom;\n }\n\n #merge-cells {\n background-position: 50% 3px;\n }\n\n #split-cells {\n background-position: 50% -97px;\n }\n\n #delete-row {\n background-position: 50% -197px;\n }\n\n #delete-column {\n background-position: 50% -297px;\n }\n\n #insert-above {\n background-position: 50% -397px;\n }\n\n #insert-below {\n background-position: 50% -497px;\n }\n\n #insert-left {\n background-position: 50% -597px;\n }\n\n #insert-right {\n background-position: 50% -697px;\n }\n\n #distribute-horizontal {\n background-position: 50% -797px;\n }\n\n #distribute-vertical {\n background-position: 50% -897px;\n }\n\n .line-type paper-item {\n background: no-repeat url(/assets/images/icon-properties-line-type.png);\n width: 80px;\n min-height: 25px;\n }\n .line-type paper-item.solid {\n background-position: 50% 12px;\n }\n .line-type paper-item.round-dot {\n background-position: 50% -38px;\n }\n .line-type paper-item.square-dot {\n background-position: 50% -88px;\n }\n .line-type paper-item.dash {\n background-position: 50% -138px;\n }\n .line-type paper-item.dash-dot {\n background-position: 50% -188px;\n }\n .line-type paper-item.long-dash {\n background-position: 50% -238px;\n }\n .line-type paper-item.long-dash-dot {\n background-position: 50% -288px;\n }\n .line-type paper-item.long-dash-dot-dot {\n background-position: 50% -338px;\n }\n `\n ]\n }\n\n @property({ type: Number }) borderWidth: number = 1\n @property({ type: String }) borderColor: string = 'black'\n @property({ type: String }) borderStyle: BorderStyle = 'solid'\n @property({ type: Object }) value: any = null\n\n @query('#border-fieldset') borderFieldSet!: HTMLElement\n\n firstUpdated() {\n this.borderFieldSet.addEventListener('change', this._onClickType.bind(this))\n }\n\n render() {\n return html`\n <fieldset id=\"border-fieldset\">\n <legend><ox-i18n msgid=\"label.border-style\">border style</ox-i18n></legend>\n\n <div\n id=\"border-set\"\n class=\"property-grid\n border-style-btn\"\n @click=${(e: Event) => this._onClickType(e)}\n >\n <md-icon data-value=\"out\">border_outer</md-icon>\n <md-icon data-value=\"in\">border_inner</md-icon>\n <md-icon data-value=\"all\">border_all</md-icon>\n <md-icon data-value=\"left\">border_left</md-icon>\n <md-icon data-value=\"center\">border_vertical</md-icon>\n <md-icon data-value=\"right\">border_right</md-icon>\n <md-icon data-value=\"top\">border_top</md-icon>\n <md-icon data-value=\"middle\">border_horizontal</md-icon>\n <md-icon data-value=\"bottom\">border_bottom</md-icon>\n <md-icon data-value=\"clear\">border_clear</md-icon>\n </div>\n\n <div class=\"property-grid\">\n <label class=\"icon-only-label linewidth\"> </label>\n <input\n type=\"number\"\n id=\"border-width\"\n @change=${(e: Event) => (this.borderWidth = Number((e.target as HTMLInputElement).value))}\n .value=${this.borderWidth}\n />\n\n <label class=\"icon-only-label color\"> </label>\n <ox-input-color\n id=\"border-color\"\n @change=${(e: Event) => (this.borderColor = (e.target as any).value)}\n .value=${this.borderColor}\n >\n </ox-input-color>\n\n <label> <ox-i18n msgid=\"label.border-type\">border type</ox-i18n> </label>\n <paper-dropdown-menu no-label-float=\"true\" class=\"line-type solid\">\n <!-- solid는 선택된 항목 보여주기위한 class로 하위 paper-item의 class와 동일하게 -->\n <paper-listbox\n id=\"border-style\"\n @iron-select=${(e: Event) => (this.borderStyle = (e.target as any).selected)}\n slot=\"dropdown-content\"\n .selected=${this.borderStyle}\n attr-for-selected=\"name\"\n >\n <paper-item class=\"solid\" name=\"solid\"></paper-item>\n <paper-item class=\"round-dot\" name=\"round-dot\"></paper-item>\n <paper-item class=\"square-dot\" name=\"square-dot\"></paper-item>\n <paper-item class=\"dash\" name=\"dash\"></paper-item>\n <paper-item class=\"dash-dot\" name=\"dash-dot\"></paper-item>\n <paper-item class=\"long-dash\" name=\"long-dash\"></paper-item>\n <paper-item class=\"long-dash-dot\" name=\"long-dash-dot\"></paper-item>\n <paper-item class=\"long-dash-dot-dot\" name=\"long-dash-dot-dot\"></paper-item>\n </paper-listbox>\n </paper-dropdown-menu>\n </div>\n </fieldset>\n\n <fieldset id=\"cell-fieldset\" @click=${(e: Event) => this._onClickCell(e)}>\n <div class=\"property-grid\">\n <div id=\"merge-cells\" table-event><span>merge cells</span></div>\n <div id=\"split-cells\" table-event><span>split cells</span></div>\n <div id=\"delete-row\" table-event><span>delete row</span></div>\n <div id=\"delete-column\" table-event><span>delete column</span></div>\n <div id=\"insert-above\" table-event><span>insert above</span></div>\n <div id=\"insert-below\" table-event><span>insert below</span></div>\n <div id=\"insert-left\" table-event><span>insert left</span></div>\n <div id=\"insert-right\" table-event><span>insert right</span></div>\n <div id=\"distribute-horizontal\" table-event><span>distribute horizontal</span></div>\n <div id=\"distribute-vertical\" table-event><span>distribute vertical</span></div>\n </div>\n </fieldset>\n `\n }\n\n _onClickCell(e: Event) {\n var target = e.target as HTMLElement\n\n const event = target?.closest('[table-event]')?.getAttribute('id')\n if (!event) {\n return\n }\n\n this.dispatchEvent(\n new CustomEvent('i-need-selected', {\n bubbles: true,\n composed: true,\n detail: {\n callback: (selected: any[]) => {\n const table = selected[0].parent\n\n switch (event) {\n case 'delete-row':\n table.deleteRows(selected)\n break\n case 'delete-column':\n table.deleteColumns(selected)\n break\n case 'insert-above':\n table.insertCellsAbove(selected)\n break\n case 'insert-below':\n table.insertCellsBelow(selected)\n break\n case 'insert-left':\n table.insertCellsLeft(selected)\n break\n case 'insert-right':\n table.insertCellsRight(selected)\n break\n case 'merge-cells':\n table.mergeCells(selected)\n break\n case 'split-cells':\n table.splitCells(selected)\n break\n case 'distribute-horizontal':\n table.distributeHorizontal(selected)\n break\n case 'distribute-vertical':\n table.distributeVertical(selected)\n break\n }\n }\n }\n })\n )\n\n this.value = {\n borderWidth: this.borderWidth,\n borderColor: this.borderColor,\n borderStyle: this.borderStyle\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: this.value,\n bubbles: true,\n composed: true\n })\n )\n\n e.stopPropagation()\n }\n\n _onClickType(e: Event) {\n var target = e.target as HTMLElement\n\n const where = target?.closest('[data-value]')?.getAttribute('data-value')\n if (!where) {\n return\n }\n\n this.dispatchEvent(\n new CustomEvent('i-need-selected', {\n bubbles: true,\n composed: true,\n detail: {\n callback: (selected: any[]) => {\n const table = selected[0].parent\n\n table.setCellsStyle(\n selected,\n {\n strokeStyle: this.borderColor,\n lineDash: this.borderStyle,\n lineWidth: this.borderWidth\n },\n where\n )\n }\n }\n })\n )\n\n this.value = {\n borderWidth: this.borderWidth,\n borderColor: this.borderColor,\n borderStyle: this.borderStyle\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: this.value,\n bubbles: true,\n composed: true\n })\n )\n\n e.stopPropagation()\n }\n}\n"]}
1
+ {"version":3,"file":"ox-input-table.js","sourceRoot":"","sources":["../../src/ox-input-table.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AACnC,OAAO,qDAAqD,CAAA;AAC5D,OAAO,mCAAmC,CAAA;AAC1C,OAAO,0BAA0B,CAAA;AACjC,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAYhD;;;;;GAKG;AAGI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,WAAW;IAAtC;;QAuEuB,gBAAW,GAAW,CAAC,CAAA;QACvB,gBAAW,GAAW,OAAO,CAAA;QAC7B,gBAAW,GAAgB,OAAO,CAAA;QAClC,UAAK,GAAQ,IAAI,CAAA;IA2M/C,CAAC;IApRC,MAAM,KAAK,MAAM;QACf,OAAO;YACL,kBAAkB;YAClB,UAAU;YACV,gBAAgB;YAChB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6DF;SACF,CAAA;IACH,CAAC;IASD,YAAY;QACV,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9E,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;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A3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAkB;AAElB;IAA1B,KAAK,CAAC,kBAAkB,CAAC;oDAA6B;AA5E5C,YAAY;IADxB,aAAa,CAAC,gBAAgB,CAAC;GACnB,YAAY,CAqRxB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/icon/icon.js'\nimport '@polymer/paper-dropdown-menu/paper-dropdown-menu.js'\nimport '@polymer/paper-item/paper-item.js'\nimport '@operato/i18n/ox-i18n.js'\nimport './ox-input-color.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { PropertyGridStyles } from '@operato/styles/property-grid-styles.js'\nimport { TableEventStyles } from '@operato/styles/table-event-styles.js'\nimport { LineStyles } from '@operato/styles/line-styles.js'\n\nimport { OxFormField } from './ox-form-field.js'\n\ntype BorderStyle =\n | 'solid'\n | 'round-dot'\n | 'square-dot'\n | 'dash'\n | 'dash-dot'\n | 'long-dash'\n | 'long-dash-dot'\n | 'long-dash-dot-dot'\n\n/**\n * 테이블 셀의 좌,우,상,하 경계선의 스타일을 편집하는 컴포넌트이다.\n * Example:\n * <ox-input-table value=${border}>\n * </ox-input-table>\n */\n\n@customElement('ox-input-table')\nexport class OxInputTable extends OxFormField {\n static get styles() {\n return [\n PropertyGridStyles,\n LineStyles,\n TableEventStyles,\n css`\n :host {\n display: block;\n }\n\n fieldset {\n border: none;\n border-bottom: 1px solid #cfd8dc;\n color: var(--md-sys-color-on-primary-container);\n font-size: 12px;\n padding: 0 0 10px 0;\n margin: 0 0 10px 0;\n }\n\n fieldset legend {\n padding: 5px 0 0 5px;\n font-size: 11px;\n color: #e46c2e;\n font-weight: bold;\n text-transform: capitalize;\n }\n\n #border-set {\n display: grid;\n grid-template-columns: repeat(5, 1fr);\n grid-gap: 5px;\n margin: 5px 0;\n place-items: center;\n }\n\n #border-set > md-icon {\n margin: 0 0 0 8px;\n width: 32px;\n height: 32px;\n }\n\n #table-event {\n display: grid;\n grid-template-columns: repeat(5, 1fr);\n grid-gap: 5px;\n margin: 5px 0;\n place-items: center;\n }\n\n .table-event {\n position: relative;\n width: 100%;\n min-height: 65px;\n place-items: center;\n }\n\n .table-event span {\n position: absolute;\n bottom: 0;\n width: 100%;\n font-size: 0.9em;\n line-height: 1.2;\n text-transform: capitalize;\n text-align: center;\n vertical-align: bottom;\n }\n `\n ]\n }\n\n @property({ type: Number }) borderWidth: number = 1\n @property({ type: String }) borderColor: string = 'black'\n @property({ type: String }) borderStyle: BorderStyle = 'solid'\n @property({ type: Object }) value: any = null\n\n @query('#border-fieldset') borderFieldSet!: HTMLElement\n\n firstUpdated() {\n this.borderFieldSet.addEventListener('change', this._onClickType.bind(this))\n }\n\n render() {\n return html`\n <fieldset id=\"border-fieldset\">\n <legend><ox-i18n msgid=\"label.border-style\">border style</ox-i18n></legend>\n\n <div\n id=\"border-set\"\n border-style-btn\"\n @click=${(e: Event) => this._onClickType(e)}\n >\n <md-icon data-value=\"out\">border_outer</md-icon>\n <md-icon data-value=\"in\">border_inner</md-icon>\n <md-icon data-value=\"all\">border_all</md-icon>\n <md-icon data-value=\"left\">border_left</md-icon>\n <md-icon data-value=\"center\">border_vertical</md-icon>\n <md-icon data-value=\"right\">border_right</md-icon>\n <md-icon data-value=\"top\">border_top</md-icon>\n <md-icon data-value=\"middle\">border_horizontal</md-icon>\n <md-icon data-value=\"bottom\">border_bottom</md-icon>\n <md-icon data-value=\"clear\">border_clear</md-icon>\n </div>\n\n <div class=\"property-grid\">\n\n <label> <ox-i18n msgid=\"label.border-type\">border type</ox-i18n> </label>\n <ox-select value-key=\"lineDash\" .value=${this.borderStyle} class=\"custom-editor\">\n <div class=\"line-type ${this.borderStyle}\" slot=\"label\"></div>\n <ox-popup-list align-left nowrap>\n <style>\n ${LineStyles.cssText}\n </style>\n <div class=\"line-type solid\" value=\"solid\" option></div>\n <div class=\"line-type round-dot\" value=\"round-dot\" option></div>\n <div class=\"line-type square-dot\" value=\"square-dot\" option></div>\n <div class=\"line-type dash\" value=\"dash\" option></div>\n <div class=\"line-type dash-dot\" value=\"dash-dot\" option></div>\n <div class=\"line-type long-dash\" value=\"long-dash\" option></div>\n <div class=\"line-type long-dash-dot\" value=\"long-dash-dot\" option></div>\n <div class=\"line-type long-dash-dot-dot\" value=\"long-dash-dot-dot\" option></div>\n </ox-popup-list>\n </ox-select>\n\n <label class=\"property-half-label\"> <md-icon>line_weight</md-icon></label>\n <input\n type=\"number\"\n id=\"border-width\"\n class=\"property-half-input\"\n @change=${(e: Event) => (this.borderWidth = Number((e.target as HTMLInputElement).value))}\n .value=${String(this.borderWidth || '')}\n />\n\n <label class=\"property-half-label\"> <md-icon>border_color</md-icon></label>\n <ox-input-color\n id=\"border-color\"\n class=\"property-half-input\"\n @change=${(e: Event) => (this.borderColor = (e.target as any).value)}\n .value=${this.borderColor}\n >\n </ox-input-color>\n </div>\n </fieldset>\n\n <fieldset id=\"cell-fieldset\" @click=${(e: Event) => this._onClickCell(e)}>\n <div id=\"table-event\">\n <div name=\"merge-cells\" class=\"table-event\"><span>merge cells</span></div>\n <div name=\"split-cells\" class=\"table-event\"><span>split cells</span></div>\n <div name=\"delete-row\" class=\"table-event\"><span>delete row</span></div>\n <div name=\"delete-column\" class=\"table-event\"><span>delete column</span></div>\n <div name=\"insert-above\" class=\"table-event\"><span>insert above</span></div>\n <div name=\"insert-below\" class=\"table-event\"><span>insert below</span></div>\n <div name=\"insert-left\" class=\"table-event\"><span>insert left</span></div>\n <div name=\"insert-right\" class=\"table-event\"><span>insert right</span></div>\n <div name=\"distribute-horizontal\" class=\"table-event\"><span>distribute horizontal</span></div>\n <div name=\"distribute-vertical\" class=\"table-event\"><span>distribute vertical</span></div>\n </div>\n </fieldset>\n `\n }\n\n _onClickCell(e: Event) {\n var target = e.target as HTMLElement\n\n const event = target?.closest('[table-event]')?.getAttribute('name')\n if (!event) {\n return\n }\n\n this.dispatchEvent(\n new CustomEvent('i-need-selected', {\n bubbles: true,\n composed: true,\n detail: {\n callback: (selected: any[]) => {\n const table = selected[0].parent\n\n switch (event) {\n case 'delete-row':\n table.deleteRows(selected)\n break\n case 'delete-column':\n table.deleteColumns(selected)\n break\n case 'insert-above':\n table.insertCellsAbove(selected)\n break\n case 'insert-below':\n table.insertCellsBelow(selected)\n break\n case 'insert-left':\n table.insertCellsLeft(selected)\n break\n case 'insert-right':\n table.insertCellsRight(selected)\n break\n case 'merge-cells':\n table.mergeCells(selected)\n break\n case 'split-cells':\n table.splitCells(selected)\n break\n case 'distribute-horizontal':\n table.distributeHorizontal(selected)\n break\n case 'distribute-vertical':\n table.distributeVertical(selected)\n break\n }\n }\n }\n })\n )\n\n this.value = {\n borderWidth: this.borderWidth,\n borderColor: this.borderColor,\n borderStyle: this.borderStyle\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: this.value,\n bubbles: true,\n composed: true\n })\n )\n\n e.stopPropagation()\n }\n\n _onClickType(e: Event) {\n var target = e.target as HTMLElement\n\n const where = target?.closest('[data-value]')?.getAttribute('data-value')\n if (!where) {\n return\n }\n\n this.dispatchEvent(\n new CustomEvent('i-need-selected', {\n bubbles: true,\n composed: true,\n detail: {\n callback: (selected: any[]) => {\n const table = selected[0].parent\n\n table.setCellsStyle(\n selected,\n {\n strokeStyle: this.borderColor,\n lineDash: this.borderStyle,\n lineWidth: this.borderWidth\n },\n where\n )\n }\n }\n })\n )\n\n this.value = {\n borderWidth: this.borderWidth,\n borderColor: this.borderColor,\n borderStyle: this.borderStyle\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: this.value,\n bubbles: true,\n composed: true\n })\n )\n\n e.stopPropagation()\n }\n}\n"]}
@@ -13,8 +13,11 @@ export declare class OxSelect extends OxFormField {
13
13
  label: string | string[];
14
14
  popupContainer: HTMLElement | null;
15
15
  observer: MutationObserver | null;
16
+ hasLabelSlot: boolean;
16
17
  render(): import("lit-html").TemplateResult<1>;
17
18
  connectedCallback(): void;
19
+ disconnectedCallback(): void;
20
+ handleKeyDown(e: KeyboardEvent): void;
18
21
  updated(changes: PropertyValues<this>): Promise<void>;
19
22
  setOptions(options: string[] | {
20
23
  display: string;
@@ -17,6 +17,7 @@ let OxSelect = class OxSelect extends OxFormField {
17
17
  this.label = '';
18
18
  this.popupContainer = null;
19
19
  this.observer = null;
20
+ this.hasLabelSlot = false;
20
21
  }
21
22
  static { this.styles = [
22
23
  css `
@@ -74,7 +75,7 @@ let OxSelect = class OxSelect extends OxFormField {
74
75
  '';
75
76
  return html `
76
77
  <div @click=${this.expand}>
77
- <span data-reactive-tooltip>${label}</span>
78
+ <span data-reactive-tooltip> <slot name="label">${label}</slot> </span>
78
79
  <md-icon>expand_more</md-icon>
79
80
  </div>
80
81
 
@@ -84,13 +85,19 @@ let OxSelect = class OxSelect extends OxFormField {
84
85
  connectedCallback() {
85
86
  super.connectedCallback();
86
87
  this.setAttribute('tabindex', '0');
87
- this.addEventListener('keydown', (e) => {
88
- e.preventDefault();
89
- if (e.key === ' ' || e.key === 'Spacebar' || e.key === 'ArrowDown') {
90
- this.expand();
91
- }
92
- });
93
- this.addEventListener('click', () => this.expand());
88
+ this.addEventListener('keydown', this.handleKeyDown);
89
+ this.addEventListener('click', this.expand);
90
+ }
91
+ disconnectedCallback() {
92
+ super.disconnectedCallback();
93
+ this.removeEventListener('keydown', this.handleKeyDown);
94
+ this.removeEventListener('click', this.expand);
95
+ }
96
+ handleKeyDown(e) {
97
+ e.preventDefault();
98
+ if (e.key === ' ' || e.key === 'Spacebar' || e.key === 'ArrowDown') {
99
+ this.expand();
100
+ }
94
101
  }
95
102
  async updated(changes) {
96
103
  if (changes.has('value')) {
@@ -138,7 +145,7 @@ let OxSelect = class OxSelect extends OxFormField {
138
145
  if (this.disabled) {
139
146
  return;
140
147
  }
141
- const slotContent = this.renderRoot.querySelector('slot')?.assignedNodes() || [];
148
+ const slotContent = this.renderRoot.querySelector('slot:not([name])')?.assignedNodes() || [];
142
149
  if (slotContent.length > 0) {
143
150
  const popupList = slotContent.find(content => content instanceof OxPopupList);
144
151
  if (popupList) {
@@ -190,6 +197,9 @@ __decorate([
190
197
  __decorate([
191
198
  state()
192
199
  ], OxSelect.prototype, "observer", void 0);
200
+ __decorate([
201
+ state()
202
+ ], OxSelect.prototype, "hasLabelSlot", void 0);
193
203
  OxSelect = __decorate([
194
204
  customElement('ox-select')
195
205
  ], OxSelect);
@@ -1 +1 @@
1
- {"version":3,"file":"ox-select.js","sourceRoot":"","sources":["../../src/ox-select.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AACnC,OAAO,iCAAiC,CAAA;AACxC,OAAO,kBAAkB,CAAA;AAEzB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAkB,MAAM,KAAK,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGzC,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,WAAW;IAAlC;;QAmDuB,SAAI,GAAW,EAAE,CAAA;QACjB,gBAAW,GAAW,EAAE,CAAA;QAE3C,UAAK,GAAsB,EAAE,CAAA;QAC7B,mBAAc,GAAuB,IAAI,CAAA;QACzC,aAAQ,GAA4B,IAAI,CAAA;IAkJnD,CAAC;aAzMQ,WAAM,GAAG;QACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8CF;KACF,AAhDY,CAgDZ;IASD,MAAM;QACJ,MAAM,KAAK,GACT,CAAC,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAA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.js'\nimport '@operato/popup/ox-popup-list.js'\nimport './ox-checkbox.js'\n\nimport { css, html, render, PropertyValues } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { OxPopupList } from '@operato/popup'\n\nimport { OxFormField } from './ox-form-field.js'\n\n@customElement('ox-select')\nexport class OxSelect extends OxFormField {\n static styles = [\n css`\n :host {\n display: block;\n position: relative;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15);\n\n --ox-select-padding: var(--spacing-tiny);\n --ox-select-font: var(--input-font);\n --ox-select-color: var(--input-color, var(--md-sys-color-on-surface-variant));\n --ox-select-icon-color: var(--theme-primary-text-color, var(--md-sys-color-on-surface-variant));\n --ox-select-icon-hover-color: var(--md-sys-color-on-primary-container, #3c3938);\n }\n\n div {\n width: 100%;\n box-sizing: border-box;\n\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n padding: var(--ox-select-padding);\n font: var(--ox-select-font);\n color: var(--ox-select-color);\n }\n\n span {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n gap: 4px;\n }\n\n md-icon {\n --md-icon-size: 16px;\n display: block;\n text-align: right;\n color: var(--ox-select-icon-color);\n opacity: 0.7;\n }\n\n div:hover md-icon {\n color: var(--md-sys-color-on-primary-container);\n }\n `\n ]\n\n @property({ type: String }) name: string = ''\n @property({ type: String }) placeholder: string = ''\n\n @state() label: string | string[] = ''\n @state() popupContainer: HTMLElement | null = null\n @state() observer: MutationObserver | null = null\n\n render() {\n const label =\n (this.label instanceof Array ? this.label.join(', ') : this.label?.trim()) ||\n (this.value instanceof Array ? this.value.join(', ') : this.value?.trim()) ||\n this.placeholder ||\n ''\n\n return html`\n <div @click=${this.expand}>\n <span data-reactive-tooltip>${label}</span>\n <md-icon>expand_more</md-icon>\n </div>\n\n <slot></slot>\n `\n }\n\n connectedCallback() {\n super.connectedCallback()\n\n this.setAttribute('tabindex', '0')\n\n this.addEventListener('keydown', (e: KeyboardEvent) => {\n e.preventDefault()\n\n if (e.key === ' ' || e.key === 'Spacebar' || e.key === 'ArrowDown') {\n this.expand()\n }\n })\n\n this.addEventListener('click', () => this.expand())\n }\n\n async updated(changes: PropertyValues<this>) {\n if (changes.has('value')) {\n const popupList = (this.popupContainer?.querySelector('ox-popup-list') ||\n this.querySelector('ox-popup-list')) as OxPopupList\n\n if (popupList) {\n popupList.value = this.value\n await this.requestUpdate()\n\n this.label = popupList.getSelectedLabels()\n }\n }\n }\n\n setOptions(\n options: string[] | { display: string; value: string }[],\n opt: { multiple?: boolean; withSearch?: boolean } = {}\n ) {\n const objOptions = options.map(option => {\n return typeof option == 'string' ? { display: option, value: option } : option\n })\n\n const { multiple, withSearch } = opt || {}\n\n const template = html`\n <ox-popup-list\n align-left\n nowrap\n ?multiple=${multiple}\n attr-selected=${multiple ? 'checked' : ''}\n ?with-search=${withSearch}\n >\n ${multiple\n ? html`<ox-checkbox\n @change=${(e: Event) => {\n const target = e.target as HTMLInputElement\n const options = Array.from(target.parentElement!.querySelectorAll('[option]')).filter(\n option => !option.hasAttribute('hidden')\n )\n options.forEach(option => ((option as HTMLInputElement).checked = target.checked))\n\n this.value = options\n .map(option =>\n (option as HTMLInputElement).checked ? (option as HTMLInputElement).value : undefined\n )\n .filter(Boolean)\n }}\n >set all</ox-checkbox\n >\n ${objOptions.map(\n option => html` <ox-checkbox option value=${option.value}>${option.display}</ox-checkbox> `\n )}`\n : html`${objOptions.map(option => html` <div option value=${option.value}>${option.display}</div> `)}`}\n </ox-popup-list>\n `\n\n render(template, this)\n }\n\n expand() {\n if (this.disabled) {\n return\n }\n\n const slotContent = this.renderRoot.querySelector('slot')?.assignedNodes() || []\n\n if (slotContent.length > 0) {\n const popupList = slotContent.find(content => content instanceof OxPopupList) as OxPopupList\n\n if (popupList) {\n const { left, bottom } = this.getBoundingClientRect()\n\n popupList.value = this.value\n popupList.style.width = `${this.offsetWidth}px`\n popupList.style.textWrap = 'nowrap'\n\n const selectHandler = async (e: Event) => {\n this.value = (e as CustomEvent).detail\n\n if (popupList) {\n await this.requestUpdate()\n this.label = popupList.getSelectedLabels()\n }\n }\n popupList.addEventListener('select', selectHandler)\n\n const closeHandler = (e: Event) => {\n /* popup이 close될 때 change 이벤트를 발생시킨다. */\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n popupList.removeEventListener('select', selectHandler)\n popupList.removeEventListener('close', closeHandler)\n\n this.appendChild(popupList)\n }\n popupList.addEventListener('close', closeHandler, { once: true })\n\n document.body.appendChild(popupList)\n\n popupList.open({\n left,\n top: bottom\n })\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ox-select.js","sourceRoot":"","sources":["../../src/ox-select.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AACnC,OAAO,iCAAiC,CAAA;AACxC,OAAO,kBAAkB,CAAA;AAEzB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAkB,MAAM,KAAK,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGzC,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,WAAW;IAAlC;;QAmDuB,SAAI,GAAW,EAAE,CAAA;QACjB,gBAAW,GAAW,EAAE,CAAA;QAE3C,UAAK,GAAsB,EAAE,CAAA;QAC7B,mBAAc,GAAuB,IAAI,CAAA;QACzC,aAAQ,GAA4B,IAAI,CAAA;QACxC,iBAAY,GAAY,KAAK,CAAA;IAuJxC,CAAC;aA/MQ,WAAM,GAAG;QACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8CF;KACF,AAhDY,CAgDZ;IAUD,MAAM;QACJ,M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AC;;AA5J2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAyB;AAE3C;IAAR,KAAK,EAAE;uCAA8B;AAC7B;IAAR,KAAK,EAAE;gDAA0C;AACzC;IAAR,KAAK,EAAE;0CAAyC;AACxC;IAAR,KAAK,EAAE;8CAA8B;AAzD3B,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAgNpB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/icon/icon.js'\nimport '@operato/popup/ox-popup-list.js'\nimport './ox-checkbox.js'\n\nimport { css, html, render, PropertyValues } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { OxPopupList } from '@operato/popup'\n\nimport { OxFormField } from './ox-form-field.js'\n\n@customElement('ox-select')\nexport class OxSelect extends OxFormField {\n static styles = [\n css`\n :host {\n display: block;\n position: relative;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15);\n\n --ox-select-padding: var(--spacing-tiny);\n --ox-select-font: var(--input-font);\n --ox-select-color: var(--input-color, var(--md-sys-color-on-surface-variant));\n --ox-select-icon-color: var(--theme-primary-text-color, var(--md-sys-color-on-surface-variant));\n --ox-select-icon-hover-color: var(--md-sys-color-on-primary-container, #3c3938);\n }\n\n div {\n width: 100%;\n box-sizing: border-box;\n\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n padding: var(--ox-select-padding);\n font: var(--ox-select-font);\n color: var(--ox-select-color);\n }\n\n span {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n gap: 4px;\n }\n\n md-icon {\n --md-icon-size: 16px;\n display: block;\n text-align: right;\n color: var(--ox-select-icon-color);\n opacity: 0.7;\n }\n\n div:hover md-icon {\n color: var(--md-sys-color-on-primary-container);\n }\n `\n ]\n\n @property({ type: String }) name: string = ''\n @property({ type: String }) placeholder: string = ''\n\n @state() label: string | string[] = ''\n @state() popupContainer: HTMLElement | null = null\n @state() observer: MutationObserver | null = null\n @state() hasLabelSlot: boolean = false\n\n render() {\n const label =\n (this.label instanceof Array ? this.label.join(', ') : this.label?.trim()) ||\n (this.value instanceof Array ? this.value.join(', ') : this.value?.trim()) ||\n this.placeholder ||\n ''\n\n return html`\n <div @click=${this.expand}>\n <span data-reactive-tooltip> <slot name=\"label\">${label}</slot> </span>\n <md-icon>expand_more</md-icon>\n </div>\n\n <slot></slot>\n `\n }\n\n connectedCallback() {\n super.connectedCallback()\n\n this.setAttribute('tabindex', '0')\n this.addEventListener('keydown', this.handleKeyDown)\n this.addEventListener('click', this.expand)\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n\n this.removeEventListener('keydown', this.handleKeyDown)\n this.removeEventListener('click', this.expand)\n }\n\n handleKeyDown(e: KeyboardEvent) {\n e.preventDefault()\n if (e.key === ' ' || e.key === 'Spacebar' || e.key === 'ArrowDown') {\n this.expand()\n }\n }\n\n async updated(changes: PropertyValues<this>) {\n if (changes.has('value')) {\n const popupList = (this.popupContainer?.querySelector('ox-popup-list') ||\n this.querySelector('ox-popup-list')) as OxPopupList\n\n if (popupList) {\n popupList.value = this.value\n await this.requestUpdate()\n this.label = popupList.getSelectedLabels()\n }\n }\n }\n\n setOptions(\n options: string[] | { display: string; value: string }[],\n opt: { multiple?: boolean; withSearch?: boolean } = {}\n ) {\n const objOptions = options.map(option => {\n return typeof option == 'string' ? { display: option, value: option } : option\n })\n\n const { multiple, withSearch } = opt || {}\n\n const template = html`\n <ox-popup-list\n align-left\n nowrap\n ?multiple=${multiple}\n attr-selected=${multiple ? 'checked' : ''}\n ?with-search=${withSearch}\n >\n ${multiple\n ? html`<ox-checkbox\n @change=${(e: Event) => {\n const target = e.target as HTMLInputElement\n const options = Array.from(target.parentElement!.querySelectorAll('[option]')).filter(\n option => !option.hasAttribute('hidden')\n )\n options.forEach(option => ((option as HTMLInputElement).checked = target.checked))\n\n this.value = options\n .map(option =>\n (option as HTMLInputElement).checked ? (option as HTMLInputElement).value : undefined\n )\n .filter(Boolean)\n }}\n >set all</ox-checkbox\n >\n ${objOptions.map(\n option => html` <ox-checkbox option value=${option.value}>${option.display}</ox-checkbox> `\n )}`\n : html`${objOptions.map(option => html` <div option value=${option.value}>${option.display}</div> `)}`}\n </ox-popup-list>\n `\n\n render(template, this)\n }\n\n expand() {\n if (this.disabled) {\n return\n }\n\n const slotContent = (this.renderRoot.querySelector('slot:not([name])') as HTMLSlotElement)?.assignedNodes() || []\n\n if (slotContent.length > 0) {\n const popupList = slotContent.find(content => content instanceof OxPopupList) as OxPopupList\n\n if (popupList) {\n const { left, bottom } = this.getBoundingClientRect()\n\n popupList.value = this.value\n popupList.style.width = `${this.offsetWidth}px`\n popupList.style.textWrap = 'nowrap'\n\n const selectHandler = async (e: Event) => {\n this.value = (e as CustomEvent).detail\n\n if (popupList) {\n await this.requestUpdate()\n this.label = popupList.getSelectedLabels()\n }\n }\n popupList.addEventListener('select', selectHandler)\n\n const closeHandler = (e: Event) => {\n /* popup이 close될 때 change 이벤트를 발생시킨다. */\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n popupList.removeEventListener('select', selectHandler)\n popupList.removeEventListener('close', closeHandler)\n\n this.appendChild(popupList)\n }\n popupList.addEventListener('close', closeHandler, { once: true })\n\n document.body.appendChild(popupList)\n\n popupList.open({\n left,\n top: bottom\n })\n }\n }\n }\n}\n"]}
@@ -0,0 +1,32 @@
1
+ import '../src/ox-select.js';
2
+ import '../src/ox-checkbox.js';
3
+ import { TemplateResult } from 'lit';
4
+ declare const _default: {
5
+ title: string;
6
+ component: string;
7
+ argTypes: {
8
+ placeholder: {
9
+ control: string;
10
+ };
11
+ name: {
12
+ control: string;
13
+ };
14
+ disabled: {
15
+ control: string;
16
+ };
17
+ };
18
+ };
19
+ export default _default;
20
+ interface Story<T> {
21
+ (args: T): TemplateResult;
22
+ args?: Partial<T>;
23
+ argTypes?: Record<string, unknown>;
24
+ }
25
+ interface ArgTypes {
26
+ placeholder?: string;
27
+ name?: string;
28
+ value?: object | string;
29
+ slot?: TemplateResult;
30
+ disabled?: boolean;
31
+ }
32
+ export declare const Regular: Story<ArgTypes>;