@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,185 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { css, html } from 'lit'
6
- import { customElement, property, query, state } from 'lit/decorators.js'
7
- import { when } from 'lit/directives/when.js'
8
- import { repeat } from 'lit/directives/repeat.js'
9
- import { localized, msg } from '@lit/localize'
10
-
11
- import { OxFormField } from './ox-form-field.js'
12
-
13
- @localized()
14
- @customElement('ox-input-hashtags')
15
- export class OxInputHashtags extends OxFormField {
16
- static styles = css`
17
- #editor {
18
- display: flex;
19
- gap: var(--spacing-medium);
20
- align-items: center;
21
- }
22
-
23
- .tags {
24
- display: flex;
25
- gap: var(--spacing-medium);
26
- align-items: center;
27
- }
28
-
29
- .tag {
30
- display: flex;
31
- gap: var(--spacing-small);
32
-
33
- font: var(--input-font);
34
- cursor: pointer;
35
- }
36
-
37
- .tag:hover {
38
- font-weight: bold;
39
- }
40
-
41
- .closer {
42
- opacity: 0.3;
43
- }
44
- .tag:hover .closer {
45
- opacity: 0.3;
46
- }
47
-
48
- .input {
49
- display: inline-block;
50
- }
51
-
52
- .input::before {
53
- display: inline;
54
- position: relative;
55
- opacity: 0.5;
56
- top: -1px;
57
- content: '#';
58
- vertical-align: middle;
59
- }
60
-
61
- input {
62
- vertical-align: middle;
63
- -webkit-appearance: none;
64
- -webkit-text-size-adjust: none;
65
- border: 0;
66
- border-bottom: 1px solid rgba(0, 0, 0, 0.15);
67
- outline: none;
68
- font-weight: bold;
69
- }
70
-
71
- input:focus {
72
- outline: none;
73
- border-bottom: 1px solid var(--md-sys-color-primary);
74
- }
75
-
76
- .error {
77
- margin: var(--spacing-small);
78
- color: var(--md-sys-color-error);
79
- font: var(--input-font);
80
- text-align: left;
81
- }
82
- `
83
-
84
- @property({ type: Array }) value: string[] = []
85
- @property({ type: String }) placeholder: string = 'tag'
86
- @query('input') input!: HTMLInputElement
87
-
88
- @state() errors?: string | null
89
-
90
- render() {
91
- return html`
92
- <div id="editor" @click=${this.setHashtags}>
93
- <div class="tags">
94
- ${repeat(
95
- this.value,
96
- tag => tag,
97
- (tag, index) => html`
98
- <span class="tag"
99
- >#${tag} <span @click=${() => !this.disabled && this.removeHashtag(index)} class="closer">x</span></span
100
- >
101
- `
102
- )}
103
- </div>
104
-
105
- <div class="input">
106
- <input
107
- type="text"
108
- @keyup=${this.onInputKeyup}
109
- @blur=${this.onBlur}
110
- placeholder="태그입력"
111
- ?disabled=${this.disabled}
112
- />
113
- </div>
114
- </div>
115
-
116
- ${when(this.errors, () => html`<p class="error">${this.errors}</p>`)}
117
- `
118
- }
119
-
120
- private onInputKeyup(e: KeyboardEvent) {
121
- e.stopPropagation()
122
-
123
- const tag = this.input.value.trim()
124
-
125
- switch (e.key) {
126
- case 'Enter':
127
- case 'Spacebar':
128
- this.addHashtag(tag)
129
- break
130
- default:
131
- this.errors = this.validate(tag)
132
- }
133
- }
134
-
135
- private onBlur() {
136
- const tag = this.input.value.trim()
137
- this.addHashtag(tag)
138
- }
139
-
140
- async setHashtags() {
141
- this.input.focus()
142
- }
143
-
144
- initErrors() {
145
- this.errors = null
146
- }
147
-
148
- validate(newtag: string) {
149
- if (this.value.some(tag => tag === newtag)) {
150
- return msg('tag duplicated')
151
- }
152
-
153
- const regex = /[~!@#$%^&*()+|<>?:{},.="':;/-]/
154
- if (regex.test(newtag)) {
155
- return msg('special characters not allowed')
156
- }
157
- }
158
-
159
- async addHashtag(tag: string) {
160
- if (!tag) {
161
- this.initErrors()
162
- this.input.focus()
163
- return
164
- }
165
-
166
- this.errors = this.validate(tag)
167
- if (this.errors) {
168
- this.input.focus()
169
- return
170
- }
171
-
172
- this.value = [...this.value, tag]
173
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
174
-
175
- this.errors = null
176
- this.input.value = ''
177
- this.input.focus()
178
- }
179
-
180
- removeHashtag(idx: number) {
181
- this.value.splice(idx, 1)
182
- this.value = [...this.value]
183
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
184
- }
185
- }
@@ -1,140 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import '@material/web/icon/icon.js'
6
-
7
- import { css, html } from 'lit'
8
- import { customElement, property, queryAll } from 'lit/decorators.js'
9
-
10
- import { OxFormField } from './ox-form-field'
11
-
12
- type I18nLabel = { [code: string]: string }
13
-
14
- const LANGUAGES = [
15
- {
16
- code: 'en',
17
- display: 'English'
18
- }
19
- ]
20
-
21
- /**
22
- input component for i18n labels
23
-
24
- Example:
25
-
26
- <ox-input-i18n-label
27
- value=${map}
28
- languages=${languages}
29
- </ox-input-i18n-label>
30
- */
31
- @customElement('ox-input-i18n-label')
32
- export class OxInputI18nLabels extends OxFormField {
33
- static styles = css`
34
- :host {
35
- display: flex;
36
- flex-direction: column;
37
- overflow: hidden;
38
- gap: 10px;
39
- }
40
-
41
- [data-record] {
42
- display: flex;
43
- flex-direction: row;
44
- align-items: center;
45
- gap: 10px;
46
- }
47
-
48
- label {
49
- width: 80px;
50
- text-align: end;
51
- }
52
-
53
- input {
54
- flex: 1;
55
- border: 0;
56
- border-bottom: 1px solid rgba(0, 0, 0, 0.15);
57
- padding: var(--spacing-tiny);
58
- font: var(--input-font);
59
- color: var(--md-sys-color-on-primary-container);
60
- min-width: 100px;
61
- }
62
-
63
- input:focus {
64
- outline: none;
65
- border-bottom: 1px solid var(--md-sys-color-on-primary-container);
66
- }
67
-
68
- input[type='hidden'] {
69
- flex: 0;
70
- }
71
- `
72
-
73
- @property({ type: Object }) value: I18nLabel = {}
74
- @property({ type: Array }) languages: { display: string; code: string }[] = LANGUAGES
75
-
76
- @queryAll('[data-record]') records!: NodeListOf<HTMLElement>
77
-
78
- private changing: boolean = false
79
-
80
- firstUpdated() {
81
- this.renderRoot.addEventListener('change', this.onChange.bind(this))
82
- }
83
-
84
- render() {
85
- const value = !this.value || typeof this.value !== 'object' ? {} : this.value
86
- const languages = (this.languages && this.languages.length > 0 && this.languages) || LANGUAGES
87
-
88
- return html`
89
- ${languages.map(
90
- ({ display, code }) => html`
91
- <div data-record>
92
- <label>${display}</label>
93
- <input type="hidden" data-code value=${code} />
94
- <input
95
- type="text"
96
- data-label
97
- placeholder="label"
98
- .value=${value?.[code] || ''}
99
- ?disabled=${this.disabled}
100
- />
101
- </div>
102
- `
103
- )}
104
- `
105
- }
106
-
107
- private onChange(e: Event) {
108
- e.stopPropagation()
109
-
110
- if (this.changing) {
111
- return
112
- }
113
-
114
- this.changing = true
115
-
116
- this.build()
117
-
118
- this.changing = false
119
- }
120
-
121
- private build() {
122
- var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>
123
-
124
- var newmap: I18nLabel = {}
125
-
126
- for (var i = 0; i < records.length; i++) {
127
- var record = records[i]
128
-
129
- const code = (record.querySelector('[data-code]') as HTMLInputElement).value
130
- const label = (record.querySelector('[data-label]') as HTMLInputElement).value
131
-
132
- if (code) {
133
- newmap[code] = label || ''
134
- }
135
- }
136
-
137
- this.value = { ...this.value, ...newmap }
138
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
139
- }
140
- }
@@ -1,168 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import '@material/web/icon/icon.js'
6
-
7
- import { css, html } from 'lit'
8
- import { customElement, query } from 'lit/decorators.js'
9
-
10
- import { ScrollbarStyles } from '@operato/styles'
11
- import { FileDropHelper } from '@operato/utils'
12
-
13
- import { OxFormField } from './ox-form-field.js'
14
-
15
- const IMAGE_FALLBACK = new URL('../../assets/images/no-image.png', import.meta.url).href
16
-
17
- @customElement('ox-input-image')
18
- export class OxInputImage extends OxFormField {
19
- static styles = [
20
- ScrollbarStyles,
21
- css`
22
- :host {
23
- position: relative;
24
- box-sizing: border-box;
25
-
26
- display: flex;
27
- flex-direction: column;
28
- place-content: center;
29
- border-radius: var(--border-radius);
30
- padding: var(--padding-default, 9px);
31
- min-height: 100px;
32
- text-transform: capitalize;
33
-
34
- border: var(--file-uploader-border);
35
- background-color: var(--md-sys-color-background);
36
- font: var(--file-uploader-font) !important;
37
- color: var(--file-uploader-color);
38
-
39
- overflow: hidden;
40
- }
41
-
42
- :host(.candrop) {
43
- background-color: var(--file-uploader-candrop-background-color);
44
- }
45
-
46
- img {
47
- min-height: 100%;
48
- margin: auto;
49
- }
50
-
51
- [overlay] {
52
- position: absolute;
53
- left: 0;
54
- top: 0;
55
- width: 100%;
56
- height: 100%;
57
- opacity: 0%;
58
- background-color: var(--md-sys-color-surface);
59
-
60
- display: flex;
61
- place-content: center;
62
- }
63
-
64
- [overlay]:hover {
65
- opacity: 50%;
66
- }
67
-
68
- #input-file {
69
- display: none;
70
- }
71
-
72
- label {
73
- border: none;
74
- flex: 1;
75
- display: flex;
76
- place-content: center;
77
- }
78
-
79
- md-icon {
80
- align-self: center;
81
-
82
- color: var(--file-uploader-icon-color, black);
83
- --md-icon-size: var(--file-uploader-icon-size, 36px);
84
- }
85
- `
86
- ]
87
-
88
- @query('#input-file') fileInput!: HTMLInputElement
89
-
90
- render() {
91
- var value = this.value
92
- var src: string
93
-
94
- if (!value) {
95
- src = IMAGE_FALLBACK
96
- } else if (typeof value === 'string') {
97
- src = value
98
- } else {
99
- src = URL.createObjectURL(value)
100
- requestAnimationFrame(() => URL.revokeObjectURL(src))
101
- }
102
-
103
- return html`
104
- <img
105
- src=${src}
106
- style="max-width: 100%;"
107
- onerror="this.src !== '${IMAGE_FALLBACK}' && (this.src = '${IMAGE_FALLBACK}')"
108
- />
109
-
110
- <div overlay>
111
- <label>
112
- <input
113
- id="input-file"
114
- type="file"
115
- accept="image/*"
116
- hidden
117
- capture="environment"
118
- @change=${(e: Event) => this._onChangeValue(e)}
119
- ?disabled=${this.disabled}
120
- />
121
- <md-icon>upload</md-icon>
122
- </label>
123
- </div>
124
- `
125
- }
126
-
127
- firstUpdated() {
128
- FileDropHelper.set(this)
129
-
130
- this.addEventListener('file-drop', (e: Event) => {
131
- const detail = (e as CustomEvent).detail
132
- this.value = detail[0]
133
-
134
- this._notifyChange()
135
- })
136
- }
137
-
138
- get file() {
139
- return this.value
140
- }
141
-
142
- reset() {
143
- this.fileInput.value = ''
144
- this.value = []
145
-
146
- this._notifyChange()
147
- }
148
-
149
- _onChangeValue(e: Event) {
150
- const fileInput = e.currentTarget as HTMLInputElement
151
-
152
- this.value = [...Array.from(fileInput.files as FileList)][0]
153
-
154
- fileInput.files = null
155
-
156
- this._notifyChange()
157
- }
158
-
159
- _notifyChange() {
160
- this.dispatchEvent(
161
- new CustomEvent('change', {
162
- bubbles: true,
163
- composed: true,
164
- detail: this.value
165
- })
166
- )
167
- }
168
- }