@operato/input 8.0.0-beta.0 → 8.0.0-beta.1

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 (98) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/package.json +7 -7
  3. package/.editorconfig +0 -29
  4. package/.storybook/main.js +0 -3
  5. package/.storybook/preview.js +0 -52
  6. package/.storybook/server.mjs +0 -8
  7. package/src/index.ts +0 -35
  8. package/src/locale/locale-codes.ts +0 -18
  9. package/src/locale/locale-picker.ts +0 -43
  10. package/src/locale/localization.ts +0 -15
  11. package/src/locales/en.ts +0 -30
  12. package/src/locales/ko.ts +0 -30
  13. package/src/locales/ms.ts +0 -30
  14. package/src/locales/zh.ts +0 -30
  15. package/src/ox-buttons-radio.ts +0 -140
  16. package/src/ox-checkbox.ts +0 -181
  17. package/src/ox-form-field.ts +0 -53
  18. package/src/ox-input-3axis.ts +0 -77
  19. package/src/ox-input-3dish.ts +0 -211
  20. package/src/ox-input-angle.ts +0 -73
  21. package/src/ox-input-barcode.ts +0 -318
  22. package/src/ox-input-code.ts +0 -139
  23. package/src/ox-input-color-gradient.ts +0 -349
  24. package/src/ox-input-color-stops.ts +0 -525
  25. package/src/ox-input-color.ts +0 -338
  26. package/src/ox-input-container.ts +0 -32
  27. package/src/ox-input-crontab.ts +0 -595
  28. package/src/ox-input-data.ts +0 -219
  29. package/src/ox-input-direction.ts +0 -92
  30. package/src/ox-input-duration.ts +0 -175
  31. package/src/ox-input-file.ts +0 -209
  32. package/src/ox-input-hashtags.ts +0 -185
  33. package/src/ox-input-i18n-label.ts +0 -140
  34. package/src/ox-input-image.ts +0 -168
  35. package/src/ox-input-key-values.ts +0 -301
  36. package/src/ox-input-layout/ox-input-card-layout.ts +0 -58
  37. package/src/ox-input-layout/ox-input-grid-layout.ts +0 -64
  38. package/src/ox-input-layout/ox-input-layout.ts +0 -77
  39. package/src/ox-input-mass-fraction.ts +0 -437
  40. package/src/ox-input-multiple-colors.ts +0 -135
  41. package/src/ox-input-options.ts +0 -216
  42. package/src/ox-input-partition-keys.ts +0 -303
  43. package/src/ox-input-privilege.ts +0 -163
  44. package/src/ox-input-quantifier.ts +0 -62
  45. package/src/ox-input-range.ts +0 -146
  46. package/src/ox-input-scene-component-id.ts +0 -73
  47. package/src/ox-input-search.ts +0 -126
  48. package/src/ox-input-select-buttons.ts +0 -75
  49. package/src/ox-input-signature.ts +0 -208
  50. package/src/ox-input-stack.ts +0 -136
  51. package/src/ox-input-switch.ts +0 -117
  52. package/src/ox-input-table-column-config.ts +0 -211
  53. package/src/ox-input-table.ts +0 -404
  54. package/src/ox-input-textarea.ts +0 -86
  55. package/src/ox-input-unit-number.ts +0 -354
  56. package/src/ox-input-value-map.ts +0 -342
  57. package/src/ox-input-value-ranges.ts +0 -363
  58. package/src/ox-input-work-shift.ts +0 -290
  59. package/src/ox-select-floor.ts +0 -246
  60. package/src/ox-select.ts +0 -219
  61. package/stories/image-for-select-floor.ts +0 -2
  62. package/stories/ox-buttons-radio.stories.ts +0 -89
  63. package/stories/ox-checkbox.stories.ts +0 -111
  64. package/stories/ox-input-3axis.stories.ts +0 -77
  65. package/stories/ox-input-3dish.stories.ts +0 -106
  66. package/stories/ox-input-angle.stories.ts +0 -84
  67. package/stories/ox-input-barcode.stories.ts +0 -117
  68. package/stories/ox-input-code.stories.ts +0 -99
  69. package/stories/ox-input-crontab.stories.ts +0 -82
  70. package/stories/ox-input-data.stories.ts +0 -82
  71. package/stories/ox-input-direction.stories.ts +0 -91
  72. package/stories/ox-input-duration.stories.ts +0 -84
  73. package/stories/ox-input-file.stories.ts +0 -111
  74. package/stories/ox-input-hashtags.stories.ts +0 -82
  75. package/stories/ox-input-i18n-label.stories.ts +0 -103
  76. package/stories/ox-input-key-values.stories.ts +0 -97
  77. package/stories/ox-input-mass-fraction.stories.ts +0 -102
  78. package/stories/ox-input-multiple-colors.stories.ts +0 -72
  79. package/stories/ox-input-options.stories.ts +0 -80
  80. package/stories/ox-input-partition-keys.stories.ts +0 -84
  81. package/stories/ox-input-privilege.stories.ts +0 -108
  82. package/stories/ox-input-quantifier.stories.ts +0 -80
  83. package/stories/ox-input-range.stories.ts +0 -89
  84. package/stories/ox-input-search.stories.ts +0 -91
  85. package/stories/ox-input-select-buttons.stories.ts +0 -118
  86. package/stories/ox-input-signature.stories.ts +0 -75
  87. package/stories/ox-input-switch.stories.ts +0 -91
  88. package/stories/ox-input-table-column-config.stories.ts +0 -109
  89. package/stories/ox-input-unit.stories.ts +0 -151
  90. package/stories/ox-input-value-map.stories.ts +0 -92
  91. package/stories/ox-input-value-ranges.stories.ts +0 -92
  92. package/stories/ox-input-work-shift.stories.ts +0 -106
  93. package/stories/ox-select-floor.stories.ts +0 -197
  94. package/stories/ox-select-set-options.stories.ts +0 -208
  95. package/stories/ox-select.stories.ts +0 -181
  96. package/tsconfig.json +0 -25
  97. package/web-dev-server.config.mjs +0 -27
  98. package/web-test-runner.config.mjs +0 -41
@@ -1,246 +0,0 @@
1
- import { css, html, PropertyValues } from 'lit'
2
- import { customElement, property, query, state } from 'lit/decorators.js'
3
- import { OxFormField } from './ox-form-field'
4
-
5
- type Card = {
6
- name: string
7
- image: string
8
- }
9
-
10
- @customElement('ox-select-floor')
11
- export class OxSelectFloor extends OxFormField {
12
- static styles = [
13
- css`
14
- :host {
15
- display: block;
16
- position: relative;
17
- overflow: hidden;
18
- height: 100%;
19
-
20
- --ox-select-floor-rotate-x: 60deg;
21
- --ox-select-floor-rotate-x-active: 40deg;
22
- --ox-select-floor-perspective: 1200px;
23
- }
24
-
25
- .carousel-container {
26
- position: relative;
27
- width: 100%;
28
- overflow: hidden;
29
- user-select: none;
30
- }
31
-
32
- .card {
33
- position: absolute;
34
- bottom: 0;
35
- width: 100%;
36
- background-color: white;
37
- transition:
38
- transform 0.3s ease,
39
- opacity 0.3s ease,
40
- box-shadow 0.3s ease,
41
- border 0.3s ease;
42
- transform-origin: bottom;
43
- transform: perspective(var(--ox-select-floor-perspective)) rotateX(var(--ox-select-floor-rotate-x));
44
- opacity: 0.5;
45
- border: 2px solid transparent;
46
- border-radius: 12px;
47
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
48
- }
49
-
50
- .card img {
51
- width: 100%;
52
- height: auto;
53
- display: block;
54
- pointer-events: none;
55
- border-radius: 12px;
56
- }
57
-
58
- .selected {
59
- opacity: 0.8;
60
- z-index: 1;
61
- border: 4px solid #3b82f6;
62
- box-shadow: 0 8px 16px rgba(59, 130, 246, 0.4);
63
- }
64
-
65
- .selected.active {
66
- opacity: 1;
67
- z-index: 2;
68
- transform: perspective(var(--ox-select-floor-perspective)) rotateX(var(--ox-select-floor-rotate-x-active));
69
- box-shadow: 0 12px 24px rgba(59, 130, 246, 0.4);
70
- }
71
-
72
- [template-container] {
73
- position: absolute;
74
- right: 10px;
75
- z-index: 1;
76
- }
77
- `
78
- ]
79
-
80
- @property({ type: Array }) cards: Card[] = []
81
- @property({ type: String }) value?: string
82
- @property({ type: Number }) bottomLimit = 70
83
- @property({ type: Number }) interval = 0
84
-
85
- @state() private selectedIndex = -1
86
- @state() private activeIndex: number | null = null
87
- @query('.carousel-container') private carouselContainer!: HTMLDivElement
88
-
89
- private isDragging = false
90
- private lastMouseY = 0
91
-
92
- render() {
93
- const length = this.cards.length
94
- const cards = this.cards
95
- const interval = this.interval
96
-
97
- return html`
98
- <div
99
- class="carousel-container"
100
- @wheel=${interval ? () => {} : this.handleWheel}
101
- @pointerdown=${this.handlePointerDown}
102
- @pointermove=${this.handlePointerMove}
103
- @pointerup=${this.handlePointerUp}
104
- @pointerleave=${this.handlePointerLeave}
105
- style=${interval ? `height: ${interval * length + 200}px;` : 'height: 100%;'}
106
- >
107
- ${cards.map(({ image, name }, index) => {
108
- return html`
109
- <div
110
- class="card ${this.getClassForCard(index)} ${this.isActive(index) ? 'active' : ''}"
111
- style=${`bottom: ${interval ? interval * index + 'px' : (this.bottomLimit * index) / length + '%'};`}
112
- @click=${() => {
113
- this.selectCard(index)
114
- this.toggleActiveCard(index)
115
- }}
116
- >
117
- <img src="${image}" @load=${(e: Event) => this.adjustCardHeight(e, index)} />
118
- </div>
119
- `
120
- })}
121
- ${cards.map(({ image, name }, index) => {
122
- return html`
123
- <div
124
- style=${`bottom: ${interval ? interval * index + 'px' : (this.bottomLimit * index) / length + '%'};`}
125
- @click=${() => this.selectCard(index)}
126
- template-container
127
- >
128
- <slot name="template-${index}"></slot>
129
- </div>
130
- `
131
- })}
132
- </div>
133
- `
134
- }
135
-
136
- updated(changes: PropertyValues<this>) {
137
- if (changes.has('value')) {
138
- if (this.value) {
139
- this.selectedIndex = this.cards.findIndex(card => card.name == this.value)
140
- } else {
141
- this.selectedIndex = -1
142
- }
143
- }
144
- }
145
-
146
- firstUpdated() {
147
- this.scrollToSelectedCard()
148
- }
149
-
150
- getClassForCard(index: number) {
151
- return index === this.selectedIndex ? 'selected' : 'compressed'
152
- }
153
-
154
- isActive(index: number): boolean {
155
- return this.activeIndex === index
156
- }
157
-
158
- handleWheel(event: WheelEvent) {
159
- event.preventDefault()
160
- const delta = Math.sign(event.deltaY)
161
- this.updateSelectedIndex(this.selectedIndex + delta)
162
- }
163
-
164
- handlePointerDown(event: PointerEvent) {
165
- event.preventDefault()
166
-
167
- this.isDragging = true
168
- this.lastMouseY = event.clientY
169
- }
170
-
171
- handlePointerMove(event: PointerEvent) {
172
- if (!this.isDragging) {
173
- return
174
- }
175
-
176
- event.preventDefault()
177
-
178
- const deltaY = event.clientY - this.lastMouseY
179
-
180
- if (!this.lastMouseY) {
181
- this.lastMouseY = event.clientY
182
- }
183
-
184
- if (Math.abs(deltaY) > 30) {
185
- this.lastMouseY = event.clientY
186
- const direction = deltaY > 0 ? -1 : 1
187
- this.updateSelectedIndex(this.selectedIndex + direction)
188
- }
189
- }
190
-
191
- handlePointerUp(event: PointerEvent) {
192
- event.preventDefault()
193
- this.isDragging = false
194
- }
195
-
196
- handlePointerLeave(event: PointerEvent) {
197
- event.preventDefault()
198
-
199
- this.isDragging = false
200
- }
201
-
202
- private toggleActiveCard(index: number) {
203
- if (this.activeIndex === index) {
204
- this.activeIndex = null
205
- } else {
206
- this.activeIndex = index
207
- }
208
- }
209
-
210
- private updateSelectedIndex(newIndex: number) {
211
- this.activeIndex = null
212
-
213
- this.selectedIndex = Math.max(-1, Math.min(newIndex, this.cards.length - 1))
214
- this.scrollToSelectedCard()
215
- }
216
-
217
- private scrollToSelectedCard() {
218
- const cardHeight = 320
219
- const targetScrollTop = this.selectedIndex * cardHeight - (window.innerHeight / 2 - cardHeight / 2)
220
-
221
- this.carouselContainer.scrollTo({ top: targetScrollTop, behavior: 'smooth' })
222
- }
223
-
224
- private selectCard(index: number) {
225
- this.selectedIndex = index
226
- this.notifySelection()
227
- this.scrollToSelectedCard()
228
- }
229
-
230
- private notifySelection() {
231
- this.value = this.selectedIndex !== -1 ? this.cards[this.selectedIndex]?.name : undefined
232
-
233
- this.dispatchEvent(
234
- new CustomEvent('change', {
235
- detail: this.value
236
- })
237
- )
238
- }
239
-
240
- private adjustCardHeight(e: Event, index: number) {
241
- const imgElement = e.target as HTMLImageElement
242
- const aspectRatio = imgElement.naturalWidth / imgElement.naturalHeight
243
- const newHeight = imgElement.offsetWidth / aspectRatio
244
- imgElement.style.height = `${newHeight}px`
245
- }
246
- }
package/src/ox-select.ts DELETED
@@ -1,219 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import '@material/web/icon/icon.js'
6
- import '@operato/popup/ox-popup-list.js'
7
- import './ox-checkbox.js'
8
-
9
- import { css, html, render, PropertyValues } from 'lit'
10
- import { customElement, property, query, state } from 'lit/decorators.js'
11
-
12
- import { OxPopupList } from '@operato/popup'
13
-
14
- import { OxFormField } from './ox-form-field.js'
15
-
16
- @customElement('ox-select')
17
- export class OxSelect extends OxFormField {
18
- static styles = [
19
- css`
20
- :host {
21
- display: block;
22
- position: relative;
23
- border-bottom: 1px solid rgba(0, 0, 0, 0.15);
24
-
25
- --ox-select-padding: var(--spacing-tiny);
26
- --ox-select-font: var(--input-font);
27
- --ox-select-color: var(--input-color, var(--md-sys-color-on-surface-variant));
28
- --ox-select-icon-color: var(--theme-primary-text-color, var(--md-sys-color-on-surface-variant));
29
- --ox-select-icon-hover-color: var(--md-sys-color-on-primary-container, #3c3938);
30
- }
31
-
32
- div {
33
- width: 100%;
34
- box-sizing: border-box;
35
-
36
- display: flex;
37
- flex-direction: row;
38
- align-items: center;
39
- justify-content: center;
40
- cursor: pointer;
41
- padding: var(--ox-select-padding);
42
- font: var(--ox-select-font);
43
- color: var(--ox-select-color);
44
- }
45
-
46
- span {
47
- flex: 1;
48
- overflow: hidden;
49
- text-overflow: ellipsis;
50
- white-space: nowrap;
51
- gap: 4px;
52
- }
53
-
54
- md-icon {
55
- --md-icon-size: 16px;
56
- display: block;
57
- text-align: right;
58
- color: var(--ox-select-icon-color);
59
- opacity: 0.7;
60
- }
61
-
62
- div:hover md-icon {
63
- color: var(--md-sys-color-on-primary-container);
64
- }
65
- `
66
- ]
67
-
68
- @property({ type: String }) name: string = ''
69
- @property({ type: String }) placeholder: string = ''
70
-
71
- @state() label: string | string[] = ''
72
- @state() popupContainer: HTMLElement | null = null
73
- @state() observer: MutationObserver | null = null
74
-
75
- render() {
76
- const label =
77
- (this.label instanceof Array ? this.label.join(', ') : this.label?.trim()) ||
78
- (this.value instanceof Array ? this.value.join(', ') : this.value?.trim()) ||
79
- this.placeholder ||
80
- ''
81
-
82
- return html`
83
- <div @click=${this.expand}>
84
- <span data-reactive-tooltip>${label}</span>
85
- <md-icon>expand_more</md-icon>
86
- </div>
87
-
88
- <slot></slot>
89
- `
90
- }
91
-
92
- connectedCallback() {
93
- super.connectedCallback()
94
-
95
- this.setAttribute('tabindex', '0')
96
-
97
- this.addEventListener('keydown', (e: KeyboardEvent) => {
98
- e.preventDefault()
99
-
100
- if (e.key === ' ' || e.key === 'Spacebar' || e.key === 'ArrowDown') {
101
- this.expand()
102
- }
103
- })
104
-
105
- this.addEventListener('click', () => this.expand())
106
- }
107
-
108
- async updated(changes: PropertyValues<this>) {
109
- if (changes.has('value')) {
110
- const popupList = (this.popupContainer?.querySelector('ox-popup-list') ||
111
- this.querySelector('ox-popup-list')) as OxPopupList
112
-
113
- if (popupList) {
114
- popupList.value = this.value
115
- await this.requestUpdate()
116
-
117
- this.label = popupList.getSelectedLabels()
118
- }
119
- }
120
- }
121
-
122
- setOptions(
123
- options: string[] | { display: string; value: string }[],
124
- opt: { multiple?: boolean; withSearch?: boolean } = {}
125
- ) {
126
- const objOptions = options.map(option => {
127
- return typeof option == 'string' ? { display: option, value: option } : option
128
- })
129
-
130
- const { multiple, withSearch } = opt || {}
131
-
132
- const template = html`
133
- <ox-popup-list
134
- align-left
135
- nowrap
136
- ?multiple=${multiple}
137
- attr-selected=${multiple ? 'checked' : ''}
138
- ?with-search=${withSearch}
139
- >
140
- ${multiple
141
- ? html`<ox-checkbox
142
- @change=${(e: Event) => {
143
- const target = e.target as HTMLInputElement
144
- const options = Array.from(target.parentElement!.querySelectorAll('[option]')).filter(
145
- option => !option.hasAttribute('hidden')
146
- )
147
- options.forEach(option => ((option as HTMLInputElement).checked = target.checked))
148
-
149
- this.value = options
150
- .map(option =>
151
- (option as HTMLInputElement).checked ? (option as HTMLInputElement).value : undefined
152
- )
153
- .filter(Boolean)
154
- }}
155
- >set all</ox-checkbox
156
- >
157
- ${objOptions.map(
158
- option => html` <ox-checkbox option value=${option.value}>${option.display}</ox-checkbox> `
159
- )}`
160
- : html`${objOptions.map(option => html` <div option value=${option.value}>${option.display}</div> `)}`}
161
- </ox-popup-list>
162
- `
163
-
164
- render(template, this)
165
- }
166
-
167
- expand() {
168
- if (this.disabled) {
169
- return
170
- }
171
-
172
- const slotContent = this.renderRoot.querySelector('slot')?.assignedNodes() || []
173
-
174
- if (slotContent.length > 0) {
175
- const popupList = slotContent.find(content => content instanceof OxPopupList) as OxPopupList
176
-
177
- if (popupList) {
178
- const { left, bottom } = this.getBoundingClientRect()
179
-
180
- popupList.value = this.value
181
- popupList.style.width = `${this.offsetWidth}px`
182
- popupList.style.textWrap = 'nowrap'
183
-
184
- const selectHandler = async (e: Event) => {
185
- this.value = (e as CustomEvent).detail
186
-
187
- if (popupList) {
188
- await this.requestUpdate()
189
- this.label = popupList.getSelectedLabels()
190
- }
191
- }
192
- popupList.addEventListener('select', selectHandler)
193
-
194
- const closeHandler = (e: Event) => {
195
- /* popup이 close될 때 change 이벤트를 발생시킨다. */
196
- this.dispatchEvent(
197
- new CustomEvent('change', {
198
- bubbles: true,
199
- composed: true,
200
- detail: this.value
201
- })
202
- )
203
- popupList.removeEventListener('select', selectHandler)
204
- popupList.removeEventListener('close', closeHandler)
205
-
206
- this.appendChild(popupList)
207
- }
208
- popupList.addEventListener('close', closeHandler, { once: true })
209
-
210
- document.body.appendChild(popupList)
211
-
212
- popupList.open({
213
- left,
214
- top: bottom
215
- })
216
- }
217
- }
218
- }
219
- }