@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
package/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [8.0.0-beta.1](https://github.com/hatiolab/operato/compare/v8.0.0-beta.0...v8.0.0-beta.1) (2025-01-08)
7
+
8
+
9
+ ### :bug: Bug Fix
10
+
11
+ * missing .npmignore ([be05985](https://github.com/hatiolab/operato/commit/be05985abfae4af53501f718dd52932099f7fbcb))
12
+
13
+
14
+
6
15
  ## [8.0.0-beta.0](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.56...v8.0.0-beta.0) (2025-01-07)
7
16
 
8
17
  **Note:** Version bump only for package @operato/input
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/input",
3
3
  "description": "Webcomponents for input following open-wc recommendations",
4
4
  "author": "heartyoh@hatiolab.com",
5
- "version": "8.0.0-beta.0",
5
+ "version": "8.0.0-beta.1",
6
6
  "main": "dist/src/index.js",
7
7
  "module": "dist/src/index.js",
8
8
  "license": "MIT",
@@ -218,11 +218,11 @@
218
218
  "@ctrl/tinycolor": "^4.1.0",
219
219
  "@lit/localize": "^0.12.1",
220
220
  "@material/web": "^2.0.0",
221
- "@operato/color-picker": "^8.0.0-beta.0",
222
- "@operato/i18n": "^8.0.0-beta.0",
223
- "@operato/popup": "^8.0.0-beta.0",
224
- "@operato/styles": "^8.0.0-beta.0",
225
- "@operato/utils": "^8.0.0-beta.0",
221
+ "@operato/color-picker": "^8.0.0-beta.1",
222
+ "@operato/i18n": "^8.0.0-beta.1",
223
+ "@operato/popup": "^8.0.0-beta.1",
224
+ "@operato/styles": "^8.0.0-beta.1",
225
+ "@operato/utils": "^8.0.0-beta.1",
226
226
  "@polymer/paper-dropdown-menu": "^3.2.0",
227
227
  "@polymer/paper-item": "^3.0.1",
228
228
  "@thebespokepixel/es-tinycolor": "^3.1.0",
@@ -266,5 +266,5 @@
266
266
  "prettier --write"
267
267
  ]
268
268
  },
269
- "gitHead": "c4e9cc245659d050a9ffd66542083a6daad4bcb9"
269
+ "gitHead": "d5b28a2e9deb632c0dc80132f6a7196dd6fe4220"
270
270
  }
package/.editorconfig DELETED
@@ -1,29 +0,0 @@
1
- # EditorConfig helps developers define and maintain consistent
2
- # coding styles between different editors and IDEs
3
- # editorconfig.org
4
-
5
- root = true
6
-
7
-
8
- [*]
9
-
10
- # Change these settings to your own preference
11
- indent_style = space
12
- indent_size = 2
13
-
14
- # We recommend you to keep these unchanged
15
- end_of_line = lf
16
- charset = utf-8
17
- trim_trailing_whitespace = true
18
- insert_final_newline = true
19
-
20
- [*.md]
21
- trim_trailing_whitespace = false
22
-
23
- [*.json]
24
- indent_size = 2
25
-
26
- [*.{html,js,md}]
27
- block_comment_start = /**
28
- block_comment = *
29
- block_comment_end = */
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- stories: ['../dist/stories/**/*.stories.{js,md,mdx}']
3
- }
@@ -1,52 +0,0 @@
1
- import { i18next } from '@operato/i18n'
2
-
3
- export const globalTypes = {
4
- locale: {
5
- name: 'Locale',
6
- description: 'Internationalization locale',
7
- toolbar: {
8
- icon: 'globe',
9
- items: [
10
- { value: 'en', right: '🇺🇸', title: 'English' },
11
- { value: 'ko', right: '🇰🇷', title: '한국어' },
12
- { value: 'zh', right: '🇨🇳', title: '中文' },
13
- { value: 'ja', right: '🇯🇵', title: '日本語' },
14
- { value: 'ms', right: '🇲🇾', title: 'Bahasa Melayu' }
15
- ],
16
- showName: true
17
- }
18
- },
19
- theme: {
20
- name: 'Theme',
21
- description: 'Global theme for components',
22
- toolbar: {
23
- icon: 'paintbrush',
24
- items: [
25
- { value: 'light', title: 'Light' },
26
- { value: 'dark', title: 'Dark' }
27
- ],
28
- showName: true
29
- }
30
- }
31
- }
32
-
33
- export const decorators = [
34
- (Story, context) => {
35
- const { locale, theme } = context.globals
36
-
37
- if (locale) {
38
- i18next.changeLanguage(locale)
39
- }
40
-
41
- // Set the theme class for the document
42
- if (theme === 'dark') {
43
- document.documentElement.classList.add('dark')
44
- document.documentElement.classList.remove('light')
45
- } else {
46
- document.documentElement.classList.add('light')
47
- document.documentElement.classList.remove('dark')
48
- }
49
-
50
- return Story()
51
- }
52
- ]
@@ -1,8 +0,0 @@
1
- import { storybookPlugin } from '@web/dev-server-storybook'
2
- import baseConfig from '../web-dev-server.config.mjs'
3
-
4
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
5
- ...baseConfig,
6
- open: '/',
7
- plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins]
8
- })
package/src/index.ts DELETED
@@ -1,35 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- export * from './ox-form-field.js'
6
- export * from './ox-buttons-radio.js'
7
- export * from './ox-checkbox.js'
8
- export * from './ox-select.js'
9
- export * from './ox-input-switch.js'
10
- export * from './ox-input-angle.js'
11
- export * from './ox-input-3dish.js'
12
- export * from './ox-input-3axis.js'
13
- export * from './ox-input-stack.js'
14
- export * from './ox-input-barcode.js'
15
- export * from './ox-input-code.js'
16
- export * from './ox-input-color.js'
17
- export * from './ox-input-multiple-colors.js'
18
- export * from './ox-input-color-stops.js'
19
- export * from './ox-input-color-gradient.js'
20
- export * from './ox-input-file.js'
21
- export * from './ox-input-image.js'
22
- export * from './ox-input-value-ranges.js'
23
- export * from './ox-input-value-map.js'
24
- export * from './ox-input-table.js'
25
- export * from './ox-input-scene-component-id.js'
26
- export * from './ox-input-crontab.js'
27
- export * from './ox-input-partition-keys.js'
28
- export * from './ox-input-duration.js'
29
- export * from './ox-input-quantifier.js'
30
- export * from './ox-input-select-buttons.js'
31
- export * from './ox-input-textarea.js'
32
- export * from './ox-input-direction.js'
33
- export * from './ox-input-table-column-config.js'
34
- export * from './ox-input-search.js'
35
- export * from './ox-input-signature.js'
@@ -1,18 +0,0 @@
1
- // Do not modify this file by hand!
2
- // Re-generate this file by running lit-localize.
3
-
4
- /**
5
- * The locale code that templates in this source code are written in.
6
- */
7
- export const sourceLocale = `en`
8
-
9
- /**
10
- * The other locale codes that this application is localized into. Sorted
11
- * lexicographically.
12
- */
13
- export const targetLocales = [`ko`, `zh`, `ms`] as const
14
-
15
- /**
16
- * All valid project locale codes. Sorted lexicographically.
17
- */
18
- export const allLocales = [`en`, `ko`, `zh`, `ms`] as const
@@ -1,43 +0,0 @@
1
- import { html, LitElement } from 'lit'
2
- import { customElement } from 'lit/decorators.js'
3
-
4
- import { localized } from '@lit/localize'
5
-
6
- import { allLocales } from './locale-codes.js'
7
- import { getLocale, setLocaleFromUrl } from './localization.js'
8
-
9
- const localeNames: {
10
- [L in typeof allLocales[number]]: string
11
- } = {
12
- en: 'English',
13
- ko: '한국어',
14
- zh: '中文 (简体)',
15
- ms: 'Malay'
16
- }
17
-
18
- // Note we use updateWhenLocaleChanges here so that we're always up to date with
19
- // the active locale (the result of getLocale()) when the locale changes via a
20
- // history navigation.
21
- @localized()
22
- @customElement('locale-picker')
23
- export class LocalePicker extends LitElement {
24
- render() {
25
- return html`
26
- <select @change=${this.localeChanged}>
27
- ${allLocales.map(
28
- locale => html`<option value=${locale} ?selected=${locale === getLocale()}>${localeNames[locale]}</option>`
29
- )}
30
- </select>
31
- `
32
- }
33
-
34
- localeChanged(event: Event) {
35
- const newLocale = (event.target as HTMLSelectElement).value
36
- if (newLocale !== getLocale()) {
37
- const url = new URL(window.location.href)
38
- url.searchParams.set('locale', newLocale)
39
- window.history.pushState(null, '', url.toString())
40
- setLocaleFromUrl()
41
- }
42
- }
43
- }
@@ -1,15 +0,0 @@
1
- import { configureLocalization } from '@lit/localize'
2
-
3
- import { sourceLocale, targetLocales } from './locale-codes.js'
4
-
5
- export const { getLocale, setLocale } = configureLocalization({
6
- sourceLocale,
7
- targetLocales,
8
- loadLocale: (locale: string) => import(`../locales/${locale}.js`)
9
- })
10
-
11
- export const setLocaleFromUrl = async () => {
12
- const url = new URL(window.location.href)
13
- const locale = url.searchParams.get('locale') || sourceLocale
14
- await setLocale(locale)
15
- }
package/src/locales/en.ts DELETED
@@ -1,30 +0,0 @@
1
-
2
- // Do not modify this file by hand!
3
- // Re-generate this file by running lit-localize
4
-
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
- 's4cbf3a26fca1d74a': `position`,
17
- 's6aacb9fbb71a1d91': `scale`,
18
- 's075cb2f53173bd8a': `rotate`,
19
- 'sb9874d345b5e590a': `tag duplicated`,
20
- 's5191b91c637d7da1': `special characters not allowed`,
21
- 'sc4bcadba8e631b86': `name`,
22
- 's63c6e58ec805a9eb': `from date`,
23
- 'sfcc01216c601ec9e': `from time`,
24
- 's685db98545dc9448': `to date`,
25
- 's77c8560cf63a372d': `to time`,
26
- 's42670fc325584e15': `The day before`,
27
- 's29ec9210c8a8222e': `The day`,
28
- 'scff69aa7239287b0': `The day after`,
29
- };
30
-
package/src/locales/ko.ts DELETED
@@ -1,30 +0,0 @@
1
-
2
- // Do not modify this file by hand!
3
- // Re-generate this file by running lit-localize
4
-
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
- 's4cbf3a26fca1d74a': `위치`,
17
- 's5191b91c637d7da1': `특수문자는 허용되지 않습니다`,
18
- 's63c6e58ec805a9eb': `시작일`,
19
- 's685db98545dc9448': `완료일`,
20
- 's6aacb9fbb71a1d91': `스케일`,
21
- 's77c8560cf63a372d': `완료시간`,
22
- 's9f41d726ecec72c2': `y 축`,
23
- 'sb9874d345b5e590a': `태그가 중복되었습니다`,
24
- 'sc4bcadba8e631b86': `이름`,
25
- 'scff69aa7239287b0': `다음날`,
26
- 'sd793f87f18747a63': `체적`,
27
- 'sf9b52aece5aed0f7': `x 축`,
28
- 'sfcc01216c601ec9e': `시작시간`,
29
- };
30
-
package/src/locales/ms.ts DELETED
@@ -1,30 +0,0 @@
1
-
2
- // Do not modify this file by hand!
3
- // Re-generate this file by running lit-localize
4
-
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
- 's4cbf3a26fca1d74a': `position`,
17
- 's6aacb9fbb71a1d91': `scale`,
18
- 's075cb2f53173bd8a': `rotate`,
19
- 'sb9874d345b5e590a': `tag duplicated`,
20
- 's5191b91c637d7da1': `special characters not allowed`,
21
- 'sc4bcadba8e631b86': `name`,
22
- 's63c6e58ec805a9eb': `from date`,
23
- 'sfcc01216c601ec9e': `from time`,
24
- 's685db98545dc9448': `to date`,
25
- 's77c8560cf63a372d': `to time`,
26
- 's42670fc325584e15': `The day before`,
27
- 's29ec9210c8a8222e': `The day`,
28
- 'scff69aa7239287b0': `The day after`,
29
- };
30
-
package/src/locales/zh.ts DELETED
@@ -1,30 +0,0 @@
1
-
2
- // Do not modify this file by hand!
3
- // Re-generate this file by running lit-localize
4
-
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
- 's4cbf3a26fca1d74a': `position`,
17
- 's6aacb9fbb71a1d91': `scale`,
18
- 's075cb2f53173bd8a': `rotate`,
19
- 'sb9874d345b5e590a': `tag duplicated`,
20
- 's5191b91c637d7da1': `special characters not allowed`,
21
- 'sc4bcadba8e631b86': `name`,
22
- 's63c6e58ec805a9eb': `from date`,
23
- 'sfcc01216c601ec9e': `from time`,
24
- 's685db98545dc9448': `to date`,
25
- 's77c8560cf63a372d': `to time`,
26
- 's42670fc325584e15': `The day before`,
27
- 's29ec9210c8a8222e': `The day`,
28
- 'scff69aa7239287b0': `The day after`,
29
- };
30
-
@@ -1,140 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { css, html, PropertyValues } from 'lit'
6
- import { customElement, property, state } from 'lit/decorators.js'
7
-
8
- import { OxFormField } from './ox-form-field'
9
-
10
- /**
11
- 여러 버튼 중에서 하나만 눌리거나, 모두 눌리지 않은 상태만을 갖는 라디오 형태의 버튼이다.
12
-
13
- Example:
14
-
15
- <ox-buttons-radio
16
- class="light"
17
- @change=${(e: CustomEvent) => console.log(e.detail)}
18
- value="1"
19
- >
20
- <md-outlined-button data-value="1" ?active=${value == '1'}>Option 1</md-outlined-button>
21
- <md-outlined-button data-value="2" ?active=${value == '2'}>Option 2</md-outlined-button>
22
- <md-outlined-button data-value="3" ?active=${value == '3'}>Option 3</md-outlined-button>
23
- </ox-buttons-radio>
24
- */
25
- @customElement('ox-buttons-radio')
26
- export class OxButtonsRadio extends OxFormField {
27
- static styles = [
28
- css`
29
- :host {
30
- display: inline-block;
31
- background-color: var(--ox-buttons-radio-background-color, var(--md-sys-color-surface));
32
-
33
- --md-outlined-button-label-text-color: var(--md-sys-color-on-surface-variant);
34
- --md-outlined-button-label-text-size: var(--md-sys-typescale-label-large-size, 0.875rem);
35
- --md-outlined-button-container-height: var(--form-element-height-medium);
36
- --md-outlined-button-container-shape: var(--md-sys-shape-corner-small);
37
- --md-outlined-button-leading-space: var(--spacing-large);
38
- --md-outlined-button-trailing-space: var(--spacing-large);
39
- --md-outlined-button-hover-label-text-color: var(--md-sys-color-primary);
40
- --md-outlined-button-pressed-outline-color: var(--md-sys-color-primary);
41
- --md-outlined-button-pressed-label-text-color: var(--md-sys-color-primary);
42
-
43
- --md-filled-button-container-color: var(--md-sys-color-primary);
44
- --md-filled-button-label-text-color: var(--md-sys-color-primary-container);
45
- --md-filled-button-label-text-size: var(--md-sys-typescale-label-large-size, 0.875rem);
46
- --md-filled-button-container-height: var(--form-element-height-medium);
47
- --md-filled-button-container-shape: var(--md-sys-shape-corner-small);
48
- --md-filled-button-leading-space: var(--spacing-large);
49
- --md-filled-button-trailing-space: var(--spacing-large);
50
- --md-filled-button-hover-label-text-color: var(--md-sys-color-secondary-container);
51
- --md-filled-button-pressed-label-text-color: var(--md-sys-color-secondary-container);
52
- --md-filled-button-focus-label-text-color: var(--md-sys-color-secondary-container);
53
-
54
- --md-text-button-container-height: var(--form-element-height-medium);
55
- --md-text-button-container-shape: var(--md-sys-shape-corner-small);
56
-
57
- --md-elevated-button-container-height: var(--form-element-height-medium);
58
- --md-elevated-button-container-shape: var(--md-sys-shape-corner-small);
59
- }
60
- `
61
- ]
62
-
63
- /**
64
- * `value`는 버튼의 눌린 상태를 값으로 갖는 속성이다.
65
- */
66
- @property({ type: Object }) value: Object | null = null
67
- @property({ type: Boolean }) mandatory!: boolean
68
-
69
- @state() _slotObserver: MutationObserver = new MutationObserver(mutations => {
70
- this._onChanged()
71
- })
72
-
73
- render() {
74
- return html` <slot @click=${(e: Event) => this._onTapButton(e)}></slot> `
75
- }
76
-
77
- connectedCallback() {
78
- super.connectedCallback()
79
-
80
- this._slotObserver?.observe(this, { childList: true })
81
- }
82
-
83
- disconnectedCallback() {
84
- super.disconnectedCallback()
85
-
86
- this._slotObserver?.disconnect()
87
- }
88
-
89
- updated(changes: PropertyValues<this>) {
90
- changes.has('value') && this._onChanged()
91
- }
92
-
93
- get buttons() {
94
- return Array.from(this.querySelectorAll('*'))
95
- }
96
-
97
- _onChanged() {
98
- this.buttons.forEach(button => {
99
- if (this.value === button.getAttribute('data-value')) {
100
- button.setAttribute('active', '')
101
- } else {
102
- button.removeAttribute('active')
103
- }
104
- })
105
- }
106
-
107
- _onTapButton(e: Event) {
108
- var target = e.target as HTMLElement
109
- target = target.closest('[data-value]') as HTMLElement
110
-
111
- if (!target || target === this) {
112
- return
113
- }
114
-
115
- var old = this.value
116
-
117
- if (!this.mandatory) {
118
- if (!target.getAttribute('active')) {
119
- this.value = target.getAttribute('data-value')
120
- target.setAttribute('active', '')
121
- } else {
122
- this.value = null
123
- target.removeAttribute('active')
124
- }
125
- } else {
126
- this.value = target.getAttribute('data-value')
127
- target.setAttribute('active', '')
128
- }
129
-
130
- if (old !== this.value) {
131
- this.dispatchEvent(
132
- new CustomEvent('change', {
133
- bubbles: true,
134
- composed: true,
135
- detail: this.value
136
- })
137
- )
138
- }
139
- }
140
- }