@operato/input 1.1.10 → 1.1.13

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 (75) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/src/index.d.ts +3 -0
  3. package/dist/src/index.js +3 -0
  4. package/dist/src/index.js.map +1 -1
  5. package/dist/src/locales/en.d.ts +2 -0
  6. package/dist/src/locales/en.js +17 -15
  7. package/dist/src/locales/en.js.map +1 -1
  8. package/dist/src/locales/ko.d.ts +2 -0
  9. package/dist/src/locales/ko.js +17 -15
  10. package/dist/src/locales/ko.js.map +1 -1
  11. package/dist/src/locales/ms.d.ts +2 -0
  12. package/dist/src/locales/ms.js +2 -0
  13. package/dist/src/locales/ms.js.map +1 -1
  14. package/dist/src/locales/zh.d.ts +2 -0
  15. package/dist/src/locales/zh.js +2 -0
  16. package/dist/src/locales/zh.js.map +1 -1
  17. package/dist/src/ox-checkbox.d.ts +3 -0
  18. package/dist/src/ox-checkbox.js +4 -1
  19. package/dist/src/ox-checkbox.js.map +1 -1
  20. package/dist/src/ox-form-field.d.ts +3 -0
  21. package/dist/src/ox-form-field.js +3 -0
  22. package/dist/src/ox-form-field.js.map +1 -1
  23. package/dist/src/ox-input-3dish.d.ts +3 -0
  24. package/dist/src/ox-input-3dish.js +1 -1
  25. package/dist/src/ox-input-3dish.js.map +1 -1
  26. package/dist/src/ox-input-barcode.d.ts +3 -0
  27. package/dist/src/ox-input-barcode.js +3 -0
  28. package/dist/src/ox-input-barcode.js.map +1 -1
  29. package/dist/src/ox-input-container.d.ts +3 -0
  30. package/dist/src/ox-input-container.js +3 -0
  31. package/dist/src/ox-input-container.js.map +1 -1
  32. package/dist/src/ox-input-crontab.d.ts +3 -0
  33. package/dist/src/ox-input-crontab.js +3 -0
  34. package/dist/src/ox-input-crontab.js.map +1 -1
  35. package/dist/src/ox-input-duration.d.ts +3 -0
  36. package/dist/src/ox-input-duration.js +3 -0
  37. package/dist/src/ox-input-duration.js.map +1 -1
  38. package/dist/src/ox-input-file.d.ts +3 -0
  39. package/dist/src/ox-input-file.js +3 -0
  40. package/dist/src/ox-input-file.js.map +1 -1
  41. package/dist/src/ox-input-hashtags.d.ts +18 -0
  42. package/dist/src/ox-input-hashtags.js +156 -0
  43. package/dist/src/ox-input-hashtags.js.map +1 -0
  44. package/dist/src/ox-input-image.d.ts +3 -0
  45. package/dist/src/ox-input-image.js +3 -0
  46. package/dist/src/ox-input-image.js.map +1 -1
  47. package/dist/src/ox-input-options.js +1 -1
  48. package/dist/src/ox-input-options.js.map +1 -1
  49. package/dist/src/ox-input-scene-component-id.d.ts +3 -0
  50. package/dist/src/ox-input-scene-component-id.js +3 -0
  51. package/dist/src/ox-input-scene-component-id.js.map +1 -1
  52. package/dist/stories/ox-input-hashtags.stories.d.ts +29 -0
  53. package/dist/stories/ox-input-hashtags.stories.js +34 -0
  54. package/dist/stories/ox-input-hashtags.stories.js.map +1 -0
  55. package/dist/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +9 -9
  57. package/src/index.ts +4 -0
  58. package/src/locales/en.ts +23 -26
  59. package/src/locales/ko.ts +23 -26
  60. package/src/locales/ms.ts +2 -0
  61. package/src/locales/zh.ts +2 -0
  62. package/src/ox-checkbox.ts +4 -0
  63. package/src/ox-form-field.ts +4 -0
  64. package/src/ox-input-3dish.ts +1 -0
  65. package/src/ox-input-barcode.ts +4 -0
  66. package/src/ox-input-container.ts +4 -0
  67. package/src/ox-input-crontab.ts +4 -0
  68. package/src/ox-input-duration.ts +4 -0
  69. package/src/ox-input-file.ts +4 -0
  70. package/src/ox-input-hashtags.ts +161 -0
  71. package/src/ox-input-image.ts +4 -0
  72. package/src/ox-input-options.ts +1 -0
  73. package/src/ox-input-scene-component-id.ts +4 -0
  74. package/stories/ox-input-hashtags.stories.ts +49 -0
  75. package/LICENSE +0 -21
package/src/locales/en.ts CHANGED
@@ -1,28 +1,25 @@
1
+ // Do not modify this file by hand!
2
+ // Re-generate this file by running lit-localize
1
3
 
2
- // Do not modify this file by hand!
3
- // Re-generate this file by running lit-localize
4
+ /* eslint-disable no-irregular-whitespace */
5
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4
6
 
5
-
6
-
7
-
8
- /* eslint-disable no-irregular-whitespace */
9
- /* eslint-disable @typescript-eslint/no-explicit-any */
10
-
11
- export const templates = {
12
- 'sf9b52aece5aed0f7': `x-axes`,
13
- 's9f41d726ecec72c2': `y-axes`,
14
- 's31be7a0b4a5853dd': `z-axes`,
15
- 'sd793f87f18747a63': `dimension`,
16
- 'sf95fdd7da4fc2295': `translate`,
17
- 's6aacb9fbb71a1d91': `scale`,
18
- 's075cb2f53173bd8a': `rotate`,
19
- 'sc4bcadba8e631b86': `name`,
20
- 's63c6e58ec805a9eb': `from date`,
21
- 'sfcc01216c601ec9e': `from time`,
22
- 's685db98545dc9448': `to date`,
23
- 's77c8560cf63a372d': `to time`,
24
- 's42670fc325584e15': `The day before`,
25
- 's29ec9210c8a8222e': `The day`,
26
- 'scff69aa7239287b0': `The day after`,
27
- };
28
-
7
+ export const templates = {
8
+ sf9b52aece5aed0f7: `x-axes`,
9
+ s9f41d726ecec72c2: `y-axes`,
10
+ s31be7a0b4a5853dd: `z-axes`,
11
+ sd793f87f18747a63: `dimension`,
12
+ sf95fdd7da4fc2295: `translate`,
13
+ s6aacb9fbb71a1d91: `scale`,
14
+ s075cb2f53173bd8a: `rotate`,
15
+ sb9874d345b5e590a: `tag duplicated`,
16
+ s5191b91c637d7da1: `special characters not allowed`,
17
+ sc4bcadba8e631b86: `name`,
18
+ s63c6e58ec805a9eb: `from date`,
19
+ sfcc01216c601ec9e: `from time`,
20
+ s685db98545dc9448: `to date`,
21
+ s77c8560cf63a372d: `to time`,
22
+ s42670fc325584e15: `The day before`,
23
+ s29ec9210c8a8222e: `The day`,
24
+ scff69aa7239287b0: `The day after`
25
+ }
package/src/locales/ko.ts CHANGED
@@ -1,28 +1,25 @@
1
+ // Do not modify this file by hand!
2
+ // Re-generate this file by running lit-localize
1
3
 
2
- // Do not modify this file by hand!
3
- // Re-generate this file by running lit-localize
4
+ /* eslint-disable no-irregular-whitespace */
5
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4
6
 
5
-
6
-
7
-
8
- /* eslint-disable no-irregular-whitespace */
9
- /* eslint-disable @typescript-eslint/no-explicit-any */
10
-
11
- export const templates = {
12
- 's075cb2f53173bd8a': `회전`,
13
- 's29ec9210c8a8222e': `당일`,
14
- 's31be7a0b4a5853dd': `z 축`,
15
- 's42670fc325584e15': `전날`,
16
- 's63c6e58ec805a9eb': `시작일`,
17
- 's685db98545dc9448': `완료일`,
18
- 's6aacb9fbb71a1d91': `스케일`,
19
- 's77c8560cf63a372d': `완료시간`,
20
- 's9f41d726ecec72c2': `y 축`,
21
- 'sc4bcadba8e631b86': `이름`,
22
- 'scff69aa7239287b0': `다음날`,
23
- 'sd793f87f18747a63': `체적`,
24
- 'sf95fdd7da4fc2295': `변환`,
25
- 'sf9b52aece5aed0f7': `x 축`,
26
- 'sfcc01216c601ec9e': `시작시간`,
27
- };
28
-
7
+ export const templates = {
8
+ s075cb2f53173bd8a: `회전`,
9
+ s29ec9210c8a8222e: `당일`,
10
+ s31be7a0b4a5853dd: `z 축`,
11
+ s42670fc325584e15: `전날`,
12
+ s63c6e58ec805a9eb: `시작일`,
13
+ s685db98545dc9448: `완료일`,
14
+ s6aacb9fbb71a1d91: `스케일`,
15
+ s77c8560cf63a372d: `완료시간`,
16
+ s9f41d726ecec72c2: `y 축`,
17
+ sc4bcadba8e631b86: `이름`,
18
+ scff69aa7239287b0: `다음날`,
19
+ sd793f87f18747a63: `체적`,
20
+ sf95fdd7da4fc2295: `변환`,
21
+ sf9b52aece5aed0f7: `x 축`,
22
+ sfcc01216c601ec9e: `시작시간`,
23
+ sb9874d345b5e590a: `태그가 중복되었습니다.`,
24
+ s5191b91c637d7da1: `특수문자는 사용할 수 없습니다.`
25
+ }
package/src/locales/ms.ts CHANGED
@@ -16,6 +16,8 @@
16
16
  'sf95fdd7da4fc2295': `translate`,
17
17
  's6aacb9fbb71a1d91': `scale`,
18
18
  's075cb2f53173bd8a': `rotate`,
19
+ 'sb9874d345b5e590a': `tag duplicated`,
20
+ 's5191b91c637d7da1': `special characters not allowed`,
19
21
  'sc4bcadba8e631b86': `name`,
20
22
  's63c6e58ec805a9eb': `from date`,
21
23
  'sfcc01216c601ec9e': `from time`,
package/src/locales/zh.ts CHANGED
@@ -16,6 +16,8 @@
16
16
  'sf95fdd7da4fc2295': `translate`,
17
17
  's6aacb9fbb71a1d91': `scale`,
18
18
  's075cb2f53173bd8a': `rotate`,
19
+ 'sb9874d345b5e590a': `tag duplicated`,
20
+ 's5191b91c637d7da1': `special characters not allowed`,
19
21
  'sc4bcadba8e631b86': `name`,
20
22
  's63c6e58ec805a9eb': `from date`,
21
23
  'sfcc01216c601ec9e': `from time`,
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
1
5
  /*
2
6
  This component is inspired by https://github.com/Polydile/dile-components, thanks Dile.
3
7
  */
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
1
5
  import { LitElement } from 'lit'
2
6
  import { property } from 'lit/decorators.js'
3
7
 
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
+
4
5
  import { css, html } from 'lit'
5
6
  import { customElement, property } from 'lit/decorators.js'
6
7
 
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
1
5
  import '@operato/popup/ox-popup.js'
2
6
 
3
7
  import { css, html } from 'lit'
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
1
5
  import '@material/mwc-icon'
2
6
  import '@operato/popup/ox-popup-list.js'
3
7
 
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
1
5
  import '@material/mwc-button'
2
6
 
3
7
  import { css, html, PropertyValues } from 'lit'
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
1
5
  import '@material/mwc-button'
2
6
 
3
7
  import { css, html } from 'lit'
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
1
5
  import '@material/mwc-icon'
2
6
 
3
7
  import { css, html, PropertyValues } from 'lit'
@@ -0,0 +1,161 @@
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: block;
19
+ box-sizing: border-box;
20
+ }
21
+
22
+ .tags {
23
+ display: inline-block;
24
+ }
25
+
26
+ .tag {
27
+ border-radius: 5px;
28
+ background-color: cyan;
29
+ color: #3e3e3e;
30
+ }
31
+
32
+ .closer {
33
+ color: red;
34
+ }
35
+
36
+ .input {
37
+ display: inline-block;
38
+ }
39
+
40
+ .input:before {
41
+ display: inline;
42
+ position: relative;
43
+ top: -1px;
44
+ content: '#';
45
+ color: #3e3e3e;
46
+ margin-right: 2px;
47
+ vertical-align: middle;
48
+ }
49
+
50
+ input {
51
+ vertical-align: middle;
52
+ -webkit-appearance: none;
53
+ -webkit-text-size-adjust: none;
54
+ padding: 0;
55
+ border: 0;
56
+ outline: none;
57
+ color: #3e3e3e;
58
+ }
59
+
60
+ input:focus {
61
+ outline: none;
62
+ opacity: 1;
63
+ }
64
+
65
+ .error {
66
+ padding: 0 5px;
67
+ color: #ea2136;
68
+ text-align: left;
69
+ }
70
+ `
71
+
72
+ @property({ type: Array }) value: string[] = []
73
+ @property({ type: String }) placeholder: string = 'tag'
74
+ @query('input') input!: HTMLInputElement
75
+
76
+ @state() errors?: string | null
77
+
78
+ render() {
79
+ return html`
80
+ <div id="editor" @click=${this.setHashtags}>
81
+ <div class="tags">
82
+ ${repeat(
83
+ this.value,
84
+ tag => tag,
85
+ (tag, index) =>
86
+ html`
87
+ <span class="tag">#${tag} <span @click=${() => this.removeHashtag(index)} class="closer">x</span></span>
88
+ `
89
+ )}
90
+ </div>
91
+
92
+ <div class="input">
93
+ <input type="text" @keyup=${this.onInputKeyup} placeholder="태그입력" />
94
+ </div>
95
+ </div>
96
+
97
+ ${when(this.errors, () => html`<p class="error">${this.errors}</p>`)}
98
+ `
99
+ }
100
+
101
+ private onInputKeyup(e: KeyboardEvent) {
102
+ e.stopPropagation()
103
+
104
+ const tag = this.input.value.trim()
105
+
106
+ switch (e.key) {
107
+ case 'Enter':
108
+ case 'Spacebar':
109
+ this.addHashtag(tag)
110
+ break
111
+ default:
112
+ this.errors = this.validate(tag)
113
+ }
114
+ }
115
+
116
+ async setHashtags() {
117
+ this.input.focus()
118
+ }
119
+
120
+ initErrors() {
121
+ this.errors = null
122
+ }
123
+
124
+ validate(newtag: string) {
125
+ if (this.value.some(tag => tag === newtag)) {
126
+ return msg('tag duplicated')
127
+ }
128
+
129
+ const regex = /[~!@#$%^&*()+|<>?:{},.="':;/-]/
130
+ if (regex.test(newtag)) {
131
+ return msg('special characters not allowed')
132
+ }
133
+ }
134
+
135
+ async addHashtag(tag: string) {
136
+ if (!tag) {
137
+ this.initErrors()
138
+ this.input.focus()
139
+ return
140
+ }
141
+
142
+ this.errors = this.validate(tag)
143
+ if (this.errors) {
144
+ this.input.focus()
145
+ return
146
+ }
147
+
148
+ this.value = [...this.value, tag]
149
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
150
+
151
+ this.errors = null
152
+ this.input.value = ''
153
+ this.input.focus()
154
+ }
155
+
156
+ removeHashtag(idx: number) {
157
+ this.value.splice(idx, 1)
158
+ this.value = [...this.value]
159
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
160
+ }
161
+ }
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
1
5
  import '@material/mwc-icon'
2
6
 
3
7
  import { css, html } from 'lit'
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
+
4
5
  import '@material/mwc-icon'
5
6
 
6
7
  import { css, html } from 'lit'
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
1
5
  import { css, html } from 'lit'
2
6
  import { customElement, property, state } from 'lit/decorators.js'
3
7
 
@@ -0,0 +1,49 @@
1
+ import '../src/ox-input-hashtags.js'
2
+
3
+ import { html, TemplateResult } from 'lit'
4
+
5
+ export default {
6
+ title: 'ox-input-hashtags',
7
+ component: 'ox-input-hashtags',
8
+ argTypes: {
9
+ placeholder: { control: 'text' },
10
+ name: { control: 'text' },
11
+ value: { control: 'array' }
12
+ }
13
+ }
14
+
15
+ interface Story<T> {
16
+ (args: T): TemplateResult
17
+ args?: Partial<T>
18
+ argTypes?: Record<string, unknown>
19
+ }
20
+
21
+ interface ArgTypes {
22
+ placeholder?: string
23
+ name?: string
24
+ value?: string[]
25
+ }
26
+
27
+ const Template: Story<ArgTypes> = ({ placeholder = 'hashtag', name = 'hello', value = [] }: ArgTypes) => html`
28
+ <link href="/themes/app-theme.css" rel="stylesheet" />
29
+ <link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
30
+ <style>
31
+ body {
32
+ }
33
+ </style>
34
+
35
+ <ox-input-hashtags
36
+ @change=${(e: Event) => console.log('changed', (e.target as HTMLInputElement).value)}
37
+ name=${name}
38
+ placeholder=${placeholder}
39
+ .value=${value}
40
+ >
41
+ </ox-input-hashtags>
42
+ `
43
+
44
+ export const Regular = Template.bind({})
45
+ Regular.args = {
46
+ placeholder: 'hashtag',
47
+ name: 'hashtag',
48
+ value: ['abc', 'def']
49
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) hatiolab.com
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.