@operato/input 8.0.0-alpha.1 → 8.0.0-alpha.19

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 (33) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/src/ox-input-file.js +3 -2
  3. package/dist/src/ox-input-file.js.map +1 -1
  4. package/dist/src/ox-input-signature.d.ts +6 -3
  5. package/dist/src/ox-input-signature.js +73 -48
  6. package/dist/src/ox-input-signature.js.map +1 -1
  7. package/dist/src/ox-select-floor.d.ts +38 -0
  8. package/dist/src/ox-select-floor.js +246 -0
  9. package/dist/src/ox-select-floor.js.map +1 -0
  10. package/dist/stories/image-for-select-floor.d.ts +1 -0
  11. package/dist/stories/image-for-select-floor.js +2 -0
  12. package/dist/stories/image-for-select-floor.js.map +1 -0
  13. package/dist/stories/{ox-input-/bsignature.stories.d.ts → ox-input-signature.stories.d.ts} +4 -2
  14. package/dist/stories/ox-input-signature.stories.js +60 -0
  15. package/dist/stories/ox-input-signature.stories.js.map +1 -0
  16. package/dist/stories/ox-select-floor.stories.d.ts +41 -0
  17. package/dist/stories/ox-select-floor.stories.js +140 -0
  18. package/dist/stories/ox-select-floor.stories.js.map +1 -0
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/package.json +8 -4
  21. package/src/ox-input-file.ts +3 -2
  22. package/src/ox-input-signature.ts +72 -46
  23. package/src/ox-select-floor.ts +257 -0
  24. package/stories/image-for-select-floor.ts +2 -0
  25. package/stories/ox-input-signature.stories.ts +75 -0
  26. package/stories/ox-select-floor.stories.ts +169 -0
  27. package/assets/images/icon-editor-gradient-direction.png +0 -0
  28. package/assets/images/icon-properties-label.png +0 -0
  29. package/assets/images/icon-properties-line-type.png +0 -0
  30. package/assets/images/icon-properties-table.png +0 -0
  31. package/dist/stories/ox-input-/bsignature.stories.js +0 -56
  32. package/dist/stories/ox-input-/bsignature.stories.js.map +0 -1
  33. package/stories/ox-input-/bsignature.stories.ts +0 -71
package/CHANGELOG.md CHANGED
@@ -3,6 +3,54 @@
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-alpha.19](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.18...v8.0.0-alpha.19) (2024-10-04)
7
+
8
+
9
+ ### :rocket: New Features
10
+
11
+ * ox-select-floor input component ([3d5c53e](https://github.com/hatiolab/operato/commit/3d5c53e8ecac718b3713fc244c36739c977f5dcf))
12
+
13
+
14
+
15
+ ## [8.0.0-alpha.10](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.9...v8.0.0-alpha.10) (2024-09-18)
16
+
17
+
18
+ ### :bug: Bug Fix
19
+
20
+ * remove unused files ([7c84a82](https://github.com/hatiolab/operato/commit/7c84a82e62897f0844423f6e2cb27d8f4ef0942f))
21
+
22
+
23
+
24
+ ## [8.0.0-alpha.4](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.3...v8.0.0-alpha.4) (2024-09-07)
25
+
26
+
27
+ ### :bug: Bug Fix
28
+
29
+ * dataset components & styles ([be44acd](https://github.com/hatiolab/operato/commit/be44acde8f25980e5b27afc481a2c149f8c23dbd))
30
+ * style for ox-data-sample-view ([8facbab](https://github.com/hatiolab/operato/commit/8facbaba683accc6e4cf2375902a0b25cde31c49))
31
+
32
+
33
+
34
+ ## [8.0.0-alpha.3](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.2...v8.0.0-alpha.3) (2024-09-06)
35
+
36
+
37
+ ### :bug: Bug Fix
38
+
39
+ * add ox-grist-editor/renderer-signature for dataset signature item ([b5dda5e](https://github.com/hatiolab/operato/commit/b5dda5ebe0afc8c9a3af73d9475bba160893155a))
40
+ * style for ox-data-sample-view ([f2a1266](https://github.com/hatiolab/operato/commit/f2a1266d9355b78a389e998129e16b8fba5ab480))
41
+
42
+
43
+
44
+ ## [8.0.0-alpha.2](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.1...v8.0.0-alpha.2) (2024-09-05)
45
+
46
+
47
+ ### :bug: Bug Fix
48
+
49
+ * use dialog in ox-input-signature ([103cee4](https://github.com/hatiolab/operato/commit/103cee48ac07217d83e2629416cf336238a9dc4a))
50
+ * use dialog in ox-input-signature ([b7304b8](https://github.com/hatiolab/operato/commit/b7304b8364a4f75a28106c1ef2de1be7a5d1b9ef))
51
+
52
+
53
+
6
54
  ## [8.0.0-alpha.1](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.0...v8.0.0-alpha.1) (2024-09-04)
7
55
 
8
56
 
@@ -81,12 +81,13 @@ let OxInputFile = class OxInputFile extends OxFormField {
81
81
  border-bottom: var(--file-uploader-li-border-bottom);
82
82
  font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
83
83
  color: var(--md-sys-color-on-primary-container);
84
+ display: flex;
85
+ align-items: center;
84
86
  }
85
87
  li md-icon {
86
- float: right;
87
88
  cursor: pointer;
88
- margin: var(--file-uploader-li-icon-margin);
89
89
  font-size: var(--icon-size-small);
90
+ margin-left: auto;
90
91
  }
91
92
  li md-icon:hover,
92
93
  li md-icon:active {
@@ -1 +1 @@
1
- {"version":3,"file":"ox-input-file.js","sourceRoot":"","sources":["../../src/ox-input-file.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGzC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,WAAW;IAArC;;QAkFuB,SAAI,GAAY,QAAQ,CAAA;QAExB,gBAAW,GAAY,kBAAkB,CAA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SAAS,CAAC,KAAiB,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAiB,CAAC,CAAC,CAAA;QAEhD,SAAS,CAAC,KAAK,GAAG,IAAI,CAAA;QAEtB,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC;IAED,aAAa;QACX,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;YACxB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI,CAAC,KAAK;SACnB,CAAC,CACH,CAAA;IACH,CAAC;;AA/G4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAmB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAgB;AACf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAA0C;AAErE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;iDAC1C;AAE7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;mDAC1C;AAET;IAArB,KAAK,CAAC,aAAa,CAAC;8CAA6B;AA1FvC,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAgMvB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/icon/icon.js'\n\nimport { css, html, PropertyValues } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { ScrollbarStyles } from '@operato/styles'\nimport { FileDropHelper } from '@operato/utils'\n\nimport { OxFormField } from './ox-form-field.js'\n\n@customElement('ox-input-file')\nexport class OxInputFile extends OxFormField {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n border-radius: var(--md-sys-shape-corner-small);\n align-items: center;\n justify-content: center;\n padding: var(--padding-default, 9px);\n min-height: 100px;\n text-transform: capitalize;\n\n border: 1px dashed var(--md-sys-color-outline-variant);\n background-color: var(--md-sys-color-surface);\n font-size: var(--md-sys-typescale-label-large-size, 0.875rem);\n }\n :host > span {\n color: var(--md-sys-color-primary);\n font-weight: var(--md-sys-typescale-label-medium-weight, var(--md-ref-typeface-weight-medium, 500));\n }\n\n :host > md-icon {\n color: var(--md-sys-color-primary);\n --md-icon-size: var(--file-uploader-icon-size, 36px);\n }\n\n :host(.candrop) {\n background-color: var(--md-sys-color-primary-fixed);\n border: 1px dashed var(--md-sys-color-primary-fixed-dim);\n }\n\n #input-file {\n display: none;\n }\n\n label {\n position: relative;\n width: auto;\n border: none;\n text-transform: capitalize;\n\n padding: var(--file-uploader-label-padding);\n border-radius: var(--file-uploader-label-border-radius);\n font-size: var(--md-sys-typescale-label-large-size, 0.875rem);\n color: var(--md-sys-color-on-surface-variant);\n }\n\n ul {\n max-width: 500px;\n width: 100%;\n list-style: none;\n margin: 5px 0 0 0;\n padding: 0;\n max-height: 46px;\n overflow: auto;\n background-color: var(--md-sys-color-on-primary);\n }\n li {\n text-align: left;\n\n padding: 3px 5px 2px 5px;\n border-bottom: var(--file-uploader-li-border-bottom);\n font-size: var(--md-sys-typescale-label-large-size, 0.875rem);\n color: var(--md-sys-color-on-primary-container);\n }\n li md-icon {\n float: right;\n cursor: pointer;\n margin: var(--file-uploader-li-icon-margin);\n font-size: var(--icon-size-small);\n }\n li md-icon:hover,\n li md-icon:active {\n color: var(--md-sys-color-error);\n }\n `\n ]\n\n @property({ type: Boolean }) multiple?: boolean\n @property({ type: String }) accept?: string\n @property({ type: String }) icon?: string = 'upload'\n @property({ type: String }) label?: string\n @property({ type: String }) description?: string = 'drop files here!'\n @property({ type: Boolean, reflect: true, attribute: 'hide-filelist' })\n hideFileList: boolean = false\n @property({ type: Boolean, reflect: true, attribute: 'attach-filelist' })\n attachFileList: boolean = false\n\n @query('#input-file') fileInput!: HTMLInputElement\n\n render() {\n var files: File[] = this.value || []\n\n return html`\n <md-icon>${this.icon || 'upload'}</md-icon>\n\n <span>${this.description || 'drop files here!'}</span>\n\n <input\n id=\"input-file\"\n type=\"file\"\n accept=${this.accept}\n ?multiple=${this.multiple}\n hidden\n capture=\"environment\"\n @change=${(e: Event) => this._onChangeValue(e)}\n ?disabled=${this.disabled}\n />\n\n <label for=\"input-file\">${this.label || 'select files'}</label>\n\n ${!this.hideFileList && files?.length\n ? html` <ul>\n ${files.map(\n file => html`\n <li>\n - ${file.name}\n <md-icon\n @click=${(e: Event) => {\n if (this.disabled) {\n return\n }\n files.splice(files.indexOf(file), 1)\n this.value = [...files]\n this._notifyChange()\n }}\n >delete_outline</md-icon\n >\n </li>\n `\n )}\n </ul>`\n : html``}\n `\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('value') && !(this.value instanceof Array)) {\n this.value = !this.value ? [] : [this.value]\n }\n }\n\n firstUpdated() {\n FileDropHelper.set(this)\n\n this.addEventListener('file-drop', (e: Event) => {\n if (this.disabled) {\n return\n }\n\n const detail = (e as CustomEvent).detail\n this.value = this.multiple ? detail : detail[0] ? [detail[0]] : []\n\n this._notifyChange()\n })\n }\n\n get files() {\n return this.value\n }\n\n reset() {\n this.fileInput.value = ''\n this.value = []\n\n this._notifyChange()\n }\n\n _onChangeValue(e: Event) {\n const fileInput = e.currentTarget as HTMLInputElement\n const files = this.value || []\n\n this.value = this.attachFileList\n ? [...files, ...Array.from(fileInput.files as FileList)]\n : [...Array.from(fileInput.files as FileList)]\n\n fileInput.files = null\n\n this._notifyChange()\n }\n\n _notifyChange() {\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n}\n"]}
1
+ {"version":3,"file":"ox-input-file.js","sourceRoot":"","sources":["../../src/ox-input-file.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGzC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,WAAW;IAArC;;QAmFuB,SAAI,GAAY,QAAQ,CAAA;QAExB,gBAAW,GAAY,kBAAkB,CAAA;QAErE,iBAAY,GAAY,KAAK,CAAA;QAE7B,mBAAc,GAAY,KAAK,CAAA;IAwGjC,CAAC;aAhMQ,WAAM,GAAG;QACd,eAAe;QACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2EF;KACF,AA9EY,CA8EZ;IAcD,MAAM;QACJ,IAAI,KAAK,GAAW,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;QAEpC,OAAO,IAAI,CAAA;iBACE,IAAI,CAAC,IAAI,IAAI,QAAQ;;cAExB,IAAI,CAAC,WAAW,IAAI,kBAAkB;;;;;iBAKnC,IAAI,CAAC,MAAM;oBACR,IAAI,CAAC,QAAQ;;;kBAGf,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;oBAClC,IAAI,CAAC,QAAQ;;;gCAGD,IAAI,CAAC,KAAK,IAAI,cAAc;;QAE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;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAA0C;AAErE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;iDAC1C;AAE7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;mDAC1C;AAET;IAArB,KAAK,CAAC,aAAa,CAAC;8CAA6B;AA3FvC,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAiMvB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/icon/icon.js'\n\nimport { css, html, PropertyValues } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { ScrollbarStyles } from '@operato/styles'\nimport { FileDropHelper } from '@operato/utils'\n\nimport { OxFormField } from './ox-form-field.js'\n\n@customElement('ox-input-file')\nexport class OxInputFile extends OxFormField {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n border-radius: var(--md-sys-shape-corner-small);\n align-items: center;\n justify-content: center;\n padding: var(--padding-default, 9px);\n min-height: 100px;\n text-transform: capitalize;\n\n border: 1px dashed var(--md-sys-color-outline-variant);\n background-color: var(--md-sys-color-surface);\n font-size: var(--md-sys-typescale-label-large-size, 0.875rem);\n }\n :host > span {\n color: var(--md-sys-color-primary);\n font-weight: var(--md-sys-typescale-label-medium-weight, var(--md-ref-typeface-weight-medium, 500));\n }\n\n :host > md-icon {\n color: var(--md-sys-color-primary);\n --md-icon-size: var(--file-uploader-icon-size, 36px);\n }\n\n :host(.candrop) {\n background-color: var(--md-sys-color-primary-fixed);\n border: 1px dashed var(--md-sys-color-primary-fixed-dim);\n }\n\n #input-file {\n display: none;\n }\n\n label {\n position: relative;\n width: auto;\n border: none;\n text-transform: capitalize;\n\n padding: var(--file-uploader-label-padding);\n border-radius: var(--file-uploader-label-border-radius);\n font-size: var(--md-sys-typescale-label-large-size, 0.875rem);\n color: var(--md-sys-color-on-surface-variant);\n }\n\n ul {\n max-width: 500px;\n width: 100%;\n list-style: none;\n margin: 5px 0 0 0;\n padding: 0;\n max-height: 46px;\n overflow: auto;\n background-color: var(--md-sys-color-on-primary);\n }\n li {\n text-align: left;\n\n padding: 3px 5px 2px 5px;\n border-bottom: var(--file-uploader-li-border-bottom);\n font-size: var(--md-sys-typescale-label-large-size, 0.875rem);\n color: var(--md-sys-color-on-primary-container);\n display: flex;\n align-items: center;\n }\n li md-icon {\n cursor: pointer;\n font-size: var(--icon-size-small);\n margin-left: auto;\n }\n li md-icon:hover,\n li md-icon:active {\n color: var(--md-sys-color-error);\n }\n `\n ]\n\n @property({ type: Boolean }) multiple?: boolean\n @property({ type: String }) accept?: string\n @property({ type: String }) icon?: string = 'upload'\n @property({ type: String }) label?: string\n @property({ type: String }) description?: string = 'drop files here!'\n @property({ type: Boolean, reflect: true, attribute: 'hide-filelist' })\n hideFileList: boolean = false\n @property({ type: Boolean, reflect: true, attribute: 'attach-filelist' })\n attachFileList: boolean = false\n\n @query('#input-file') fileInput!: HTMLInputElement\n\n render() {\n var files: File[] = this.value || []\n\n return html`\n <md-icon>${this.icon || 'upload'}</md-icon>\n\n <span>${this.description || 'drop files here!'}</span>\n\n <input\n id=\"input-file\"\n type=\"file\"\n accept=${this.accept}\n ?multiple=${this.multiple}\n hidden\n capture=\"environment\"\n @change=${(e: Event) => this._onChangeValue(e)}\n ?disabled=${this.disabled}\n />\n\n <label for=\"input-file\">${this.label || 'select files'}</label>\n\n ${!this.hideFileList && files?.length\n ? html` <ul>\n ${files.map(\n file => html`\n <li>\n - ${file.name}\n <md-icon\n @click=${(e: Event) => {\n if (this.disabled) {\n return\n }\n files.splice(files.indexOf(file), 1)\n this.value = [...files]\n this._notifyChange()\n }}\n >delete_outline</md-icon\n >\n </li>\n `\n )}\n </ul>`\n : html``}\n `\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('value') && !(this.value instanceof Array)) {\n this.value = !this.value ? [] : [this.value]\n }\n }\n\n firstUpdated() {\n FileDropHelper.set(this)\n\n this.addEventListener('file-drop', (e: Event) => {\n if (this.disabled) {\n return\n }\n\n const detail = (e as CustomEvent).detail\n this.value = this.multiple ? detail : detail[0] ? [detail[0]] : []\n\n this._notifyChange()\n })\n }\n\n get files() {\n return this.value\n }\n\n reset() {\n this.fileInput.value = ''\n this.value = []\n\n this._notifyChange()\n }\n\n _onChangeValue(e: Event) {\n const fileInput = e.currentTarget as HTMLInputElement\n const files = this.value || []\n\n this.value = this.attachFileList\n ? [...files, ...Array.from(fileInput.files as FileList)]\n : [...Array.from(fileInput.files as FileList)]\n\n fileInput.files = null\n\n this._notifyChange()\n }\n\n _notifyChange() {\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n}\n"]}
@@ -2,13 +2,16 @@ import '@material/web/icon/icon.js';
2
2
  import { OxFormField } from './ox-form-field.js';
3
3
  export declare class OxInputSignature extends OxFormField {
4
4
  static styles: import("lit").CSSResult[];
5
- isDrawing: boolean;
6
5
  value: string | null;
7
- private ctx;
6
+ private previewDiv;
7
+ private dialog;
8
8
  private canvas;
9
+ private ctx;
10
+ private isDrawing;
9
11
  render(): import("lit-html").TemplateResult<1>;
10
12
  firstUpdated(): void;
11
- updated(changedProperties: Map<string | number | symbol, unknown>): void;
13
+ openDialog(): void;
14
+ closeDialog(): void;
12
15
  startDrawing(event: MouseEvent | TouchEvent): void;
13
16
  stopDrawing(): void;
14
17
  draw(event: MouseEvent | TouchEvent): void;
@@ -1,83 +1,105 @@
1
1
  import { __decorate } from "tslib";
2
2
  import '@material/web/icon/icon.js';
3
- import { css, html, nothing } from 'lit';
4
- import { customElement, property } from 'lit/decorators.js';
3
+ import { css, html } from 'lit';
4
+ import { customElement, property, query } from 'lit/decorators.js';
5
5
  import { OxFormField } from './ox-form-field.js';
6
6
  let OxInputSignature = class OxInputSignature extends OxFormField {
7
7
  constructor() {
8
8
  super(...arguments);
9
- this.isDrawing = false;
10
9
  this.value = null;
10
+ this.isDrawing = false;
11
11
  }
12
12
  static { this.styles = [
13
13
  css `
14
14
  :host {
15
- position: relative;
16
- box-sizing: border-box;
17
-
18
15
  display: flex;
19
16
  flex-direction: column;
20
- place-content: center;
21
- border-radius: var(--border-radius);
22
- padding: var(--padding-default, 9px);
23
- min-height: 100px;
24
- text-transform: capitalize;
17
+ min-height: var(--signature-min-height, 80px);
18
+ min-width: var(--signature-min-width, 120px);
25
19
 
26
- border: var(--file-uploader-border);
27
- background-color: var(--md-sys-color-background);
28
- font: var(--file-uploader-font) !important;
29
- color: var(--file-uploader-color);
20
+ background-color: var(--signature-background-color, white);
30
21
 
31
22
  overflow: hidden;
32
23
  }
33
24
 
34
- canvas {
25
+ .signature-preview {
26
+ flex: 1;
27
+ align-self: stretch;
28
+
29
+ border: 1px solid var(--md-sys-color-outline);
30
+ background-size: contain;
31
+ background-repeat: no-repeat;
32
+ background-position: center;
33
+ }
34
+
35
+ dialog canvas {
35
36
  width: 100%;
36
- border: 1px solid #000;
37
+ height: 100%;
38
+ border: 1px solid var(--md-sys-color-outline);
37
39
  }
38
40
 
39
41
  .controls {
40
42
  margin-top: 10px;
43
+ display: flex;
44
+ flex-direction: row;
45
+ gap: var(--spacing-medium);
46
+ }
47
+
48
+ .filler {
49
+ flex: 1;
41
50
  }
42
51
  `
43
52
  ]; }
44
53
  render() {
45
54
  return html `
46
- <canvas
47
- width="400"
48
- height="200"
49
- @mousedown=${this.startDrawing}
50
- @mouseup=${this.stopDrawing}
51
- @mousemove=${this.draw}
52
- @mouseleave=${this.stopDrawing}
53
- @touchstart=${this.startDrawing}
54
- @touchend=${this.stopDrawing}
55
- @touchmove=${this.draw}
56
- ></canvas>
55
+ <div class="signature-preview" @click=${this.openDialog}></div>
57
56
 
58
- ${!this.disabled
59
- ? html ` <div class="controls">
60
- <button @click="${this.clearCanvas}">Clear</button>
61
- <button @click="${this.saveSignature}">Save</button>
62
- </div>`
63
- : nothing}
57
+ <dialog>
58
+ <canvas
59
+ width="800"
60
+ height="400"
61
+ @mousedown=${this.startDrawing}
62
+ @mouseup=${this.stopDrawing}
63
+ @mousemove=${this.draw}
64
+ @mouseleave=${this.stopDrawing}
65
+ @touchstart=${this.startDrawing}
66
+ @touchend=${this.stopDrawing}
67
+ @touchmove=${this.draw}
68
+ ></canvas>
69
+ <div class="controls">
70
+ <button @click="${this.clearCanvas}">Clear</button>
71
+ <div class="filler"></div>
72
+ <button @click="${this.saveSignature}">Save</button>
73
+ <button @click="${this.closeDialog}">Close</button>
74
+ </div>
75
+ </dialog>
64
76
  `;
65
77
  }
66
78
  firstUpdated() {
67
- this.canvas = this.shadowRoot.querySelector('canvas');
68
79
  this.ctx = this.canvas.getContext('2d');
69
80
  this.ctx.strokeStyle = '#000';
70
81
  this.ctx.lineWidth = 2;
71
- // 처음 로딩 시 서명 데이터를 캔버스에 표시
82
+ // 처음 로딩 시 서명 데이터를 미리보기 div에 표시
72
83
  if (this.value) {
73
84
  this.loadSignature(this.value);
74
85
  }
75
86
  }
76
- updated(changedProperties) {
77
- if (changedProperties.has('value') && this.value) {
78
- this.loadSignature(this.value);
87
+ openDialog() {
88
+ if (this.disabled)
89
+ return;
90
+ this.dialog.showModal();
91
+ // 다이아로그가 열릴 때 현재 value를 캔버스에 그리기
92
+ if (this.value) {
93
+ const img = new Image();
94
+ img.onload = () => {
95
+ this.ctx.drawImage(img, 0, 0, this.canvas.width, this.canvas.height);
96
+ };
97
+ img.src = this.value;
79
98
  }
80
99
  }
100
+ closeDialog() {
101
+ this.dialog.close();
102
+ }
81
103
  startDrawing(event) {
82
104
  if (this.disabled) {
83
105
  return;
@@ -103,14 +125,11 @@ let OxInputSignature = class OxInputSignature extends OxFormField {
103
125
  saveSignature() {
104
126
  this.value = this.canvas.toDataURL();
105
127
  this._notifyChange();
128
+ this.previewDiv.style.backgroundImage = `url(${this.value})`;
129
+ this.closeDialog();
106
130
  }
107
131
  loadSignature(dataUrl) {
108
- const image = new Image();
109
- image.onload = () => {
110
- this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); // 이전 내용을 지움
111
- this.ctx.drawImage(image, 0, 0); // 이미지를 캔버스에 그림
112
- };
113
- image.src = dataUrl;
132
+ this.previewDiv.style.backgroundImage = `url(${dataUrl})`;
114
133
  }
115
134
  getEventPosition(event) {
116
135
  const rect = this.canvas.getBoundingClientRect();
@@ -131,12 +150,18 @@ let OxInputSignature = class OxInputSignature extends OxFormField {
131
150
  }));
132
151
  }
133
152
  };
134
- __decorate([
135
- property({ type: Boolean })
136
- ], OxInputSignature.prototype, "isDrawing", void 0);
137
153
  __decorate([
138
154
  property({ type: String })
139
155
  ], OxInputSignature.prototype, "value", void 0);
156
+ __decorate([
157
+ query('.signature-preview')
158
+ ], OxInputSignature.prototype, "previewDiv", void 0);
159
+ __decorate([
160
+ query('dialog')
161
+ ], OxInputSignature.prototype, "dialog", void 0);
162
+ __decorate([
163
+ query('canvas')
164
+ ], OxInputSignature.prototype, "canvas", void 0);
140
165
  OxInputSignature = __decorate([
141
166
  customElement('ox-input-signature')
142
167
  ], OxInputSignature);
@@ -1 +1 @@
1
- {"version":3,"file":"ox-input-signature.js","sourceRoot":"","sources":["../../src/ox-input-signature.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGzC,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,WAAW;IAA1C;;QAkCwB,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AAE,OAAO,EAAE,CAAC;mDAAkB;AAClB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAA4B;AAnC5C,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CAiJ5B","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { css, html, nothing } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field.js'\n\n@customElement('ox-input-signature')\nexport class OxInputSignature extends OxFormField {\n static styles = [\n css`\n :host {\n position: relative;\n box-sizing: border-box;\n\n display: flex;\n flex-direction: column;\n place-content: center;\n border-radius: var(--border-radius);\n padding: var(--padding-default, 9px);\n min-height: 100px;\n text-transform: capitalize;\n\n border: var(--file-uploader-border);\n background-color: var(--md-sys-color-background);\n font: var(--file-uploader-font) !important;\n color: var(--file-uploader-color);\n\n overflow: hidden;\n }\n\n canvas {\n width: 100%;\n border: 1px solid #000;\n }\n\n .controls {\n margin-top: 10px;\n }\n `\n ]\n\n @property({ type: Boolean }) isDrawing = false\n @property({ type: String }) value: string | null = null\n\n private ctx!: CanvasRenderingContext2D\n private canvas!: HTMLCanvasElement\n\n render() {\n return html`\n <canvas\n width=\"400\"\n height=\"200\"\n @mousedown=${this.startDrawing}\n @mouseup=${this.stopDrawing}\n @mousemove=${this.draw}\n @mouseleave=${this.stopDrawing}\n @touchstart=${this.startDrawing}\n @touchend=${this.stopDrawing}\n @touchmove=${this.draw}\n ></canvas>\n\n ${!this.disabled\n ? html` <div class=\"controls\">\n <button @click=\"${this.clearCanvas}\">Clear</button>\n <button @click=\"${this.saveSignature}\">Save</button>\n </div>`\n : nothing}\n `\n }\n\n firstUpdated() {\n this.canvas = this.shadowRoot!.querySelector('canvas')!\n this.ctx = this.canvas.getContext('2d')!\n this.ctx.strokeStyle = '#000'\n this.ctx.lineWidth = 2\n\n // 처음 로딩 시 서명 데이터를 캔버스에 표시\n if (this.value) {\n this.loadSignature(this.value)\n }\n }\n\n updated(changedProperties: Map<string | number | symbol, unknown>) {\n if (changedProperties.has('value') && this.value) {\n this.loadSignature(this.value)\n }\n }\n\n startDrawing(event: MouseEvent | TouchEvent) {\n if (this.disabled) {\n return\n }\n\n this.isDrawing = true\n this.ctx.beginPath()\n const position = this.getEventPosition(event)\n this.ctx.moveTo(position.x, position.y)\n }\n\n stopDrawing() {\n this.isDrawing = false\n }\n\n draw(event: MouseEvent | TouchEvent) {\n if (!this.isDrawing) return\n const position = this.getEventPosition(event)\n this.ctx.lineTo(position.x, position.y)\n this.ctx.stroke()\n }\n\n clearCanvas() {\n this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)\n }\n\n saveSignature() {\n this.value = this.canvas.toDataURL()\n this._notifyChange()\n }\n\n loadSignature(dataUrl: string) {\n const image = new Image()\n image.onload = () => {\n this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height) // 이전 내용을 지움\n this.ctx.drawImage(image, 0, 0) // 이미지를 캔버스에 그림\n }\n image.src = dataUrl\n }\n\n getEventPosition(event: MouseEvent | TouchEvent) {\n const rect = this.canvas.getBoundingClientRect()\n\n // 캔버스의 실제 크기와 CSS 크기 간의 비율을 계산\n const scaleX = this.canvas.width / rect.width\n const scaleY = this.canvas.height / rect.height\n\n // 실제 좌표 계산\n const isTouchEvent = event instanceof TouchEvent\n const x = (isTouchEvent ? event.touches[0].clientX - rect.left : (event as MouseEvent).clientX - rect.left) * scaleX\n const y = (isTouchEvent ? event.touches[0].clientY - rect.top : (event as MouseEvent).clientY - rect.top) * scaleY\n\n return { x, y }\n }\n\n _notifyChange() {\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n}\n"]}
1
+ {"version":3,"file":"ox-input-signature.js","sourceRoot":"","sources":["../../src/ox-input-signature.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAW,MAAM,KAA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AO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;IACjB,CAAC;IAED,aAAa;QACX,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;YACxB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI,CAAC,KAAK;SACnB,CAAC,CACH,CAAA;IACH,CAAC;;AA/H2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAA4B;AAG/C;IADP,KAAK,CAAC,oBAAoB,CAAC;oDACO;AAE3B;IADP,KAAK,CAAC,QAAQ,CAAC;gDACkB;AAE1B;IADP,KAAK,CAAC,QAAQ,CAAC;gDACkB;AAlDvB,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CA2K5B","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { css, html, nothing } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field.js'\n\n@customElement('ox-input-signature')\nexport class OxInputSignature extends OxFormField {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n min-height: var(--signature-min-height, 80px);\n min-width: var(--signature-min-width, 120px);\n\n background-color: var(--signature-background-color, white);\n\n overflow: hidden;\n }\n\n .signature-preview {\n flex: 1;\n align-self: stretch;\n\n border: 1px solid var(--md-sys-color-outline);\n background-size: contain;\n background-repeat: no-repeat;\n background-position: center;\n }\n\n dialog canvas {\n width: 100%;\n height: 100%;\n border: 1px solid var(--md-sys-color-outline);\n }\n\n .controls {\n margin-top: 10px;\n display: flex;\n flex-direction: row;\n gap: var(--spacing-medium);\n }\n\n .filler {\n flex: 1;\n }\n `\n ]\n\n @property({ type: String }) value: string | null = null\n\n @query('.signature-preview')\n private previewDiv!: HTMLDivElement\n @query('dialog')\n private dialog!: HTMLDialogElement\n @query('canvas')\n private canvas!: HTMLCanvasElement\n\n private ctx!: CanvasRenderingContext2D\n private isDrawing = false\n\n render() {\n return html`\n <div class=\"signature-preview\" @click=${this.openDialog}></div>\n\n <dialog>\n <canvas\n width=\"800\"\n height=\"400\"\n @mousedown=${this.startDrawing}\n @mouseup=${this.stopDrawing}\n @mousemove=${this.draw}\n @mouseleave=${this.stopDrawing}\n @touchstart=${this.startDrawing}\n @touchend=${this.stopDrawing}\n @touchmove=${this.draw}\n ></canvas>\n <div class=\"controls\">\n <button @click=\"${this.clearCanvas}\">Clear</button>\n <div class=\"filler\"></div>\n <button @click=\"${this.saveSignature}\">Save</button>\n <button @click=\"${this.closeDialog}\">Close</button>\n </div>\n </dialog>\n `\n }\n\n firstUpdated() {\n this.ctx = this.canvas.getContext('2d')!\n this.ctx.strokeStyle = '#000'\n this.ctx.lineWidth = 2\n\n // 처음 로딩 시 서명 데이터를 미리보기 div에 표시\n if (this.value) {\n this.loadSignature(this.value)\n }\n }\n\n openDialog() {\n if (this.disabled) return\n this.dialog.showModal()\n\n // 다이아로그가 열릴 현재 value를 캔버스에 그리기\n if (this.value) {\n const img = new Image()\n img.onload = () => {\n this.ctx.drawImage(img, 0, 0, this.canvas.width, this.canvas.height)\n }\n img.src = this.value\n }\n }\n\n closeDialog() {\n this.dialog.close()\n }\n\n startDrawing(event: MouseEvent | TouchEvent) {\n if (this.disabled) {\n return\n }\n\n this.isDrawing = true\n this.ctx.beginPath()\n const position = this.getEventPosition(event)\n this.ctx.moveTo(position.x, position.y)\n }\n\n stopDrawing() {\n this.isDrawing = false\n }\n\n draw(event: MouseEvent | TouchEvent) {\n if (!this.isDrawing) return\n const position = this.getEventPosition(event)\n this.ctx.lineTo(position.x, position.y)\n this.ctx.stroke()\n }\n\n clearCanvas() {\n this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)\n }\n\n saveSignature() {\n this.value = this.canvas.toDataURL()\n this._notifyChange()\n this.previewDiv.style.backgroundImage = `url(${this.value})`\n this.closeDialog()\n }\n\n loadSignature(dataUrl: string) {\n this.previewDiv.style.backgroundImage = `url(${dataUrl})`\n }\n\n getEventPosition(event: MouseEvent | TouchEvent) {\n const rect = this.canvas.getBoundingClientRect()\n\n // 캔버스의 실제 크기와 CSS 크기 간의 비율을 계산\n const scaleX = this.canvas.width / rect.width\n const scaleY = this.canvas.height / rect.height\n\n // 실제 좌표 계산\n const isTouchEvent = event instanceof TouchEvent\n const x = (isTouchEvent ? event.touches[0].clientX - rect.left : (event as MouseEvent).clientX - rect.left) * scaleX\n const y = (isTouchEvent ? event.touches[0].clientY - rect.top : (event as MouseEvent).clientY - rect.top) * scaleY\n\n return { x, y }\n }\n\n _notifyChange() {\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n}\n"]}
@@ -0,0 +1,38 @@
1
+ import { PropertyValues } from 'lit';
2
+ import { OxFormField } from './ox-form-field';
3
+ type Card = {
4
+ name: string;
5
+ image: string;
6
+ };
7
+ export declare class OxSelectFloor extends OxFormField {
8
+ static styles: import("lit").CSSResult[];
9
+ cards: Card[];
10
+ value?: string;
11
+ bottomLimit: number;
12
+ private selectedIndex;
13
+ private activeIndex;
14
+ private carouselContainer;
15
+ private isDragging;
16
+ private lastTouchY;
17
+ private lastMouseY;
18
+ render(): import("lit-html").TemplateResult<1>;
19
+ updated(changes: PropertyValues<this>): void;
20
+ firstUpdated(): void;
21
+ getClassForCard(index: number): "selected" | "compressed";
22
+ isActive(index: number): boolean;
23
+ handleWheel(event: WheelEvent): void;
24
+ handleTouchStart(event: TouchEvent): void;
25
+ handleTouchMove(event: TouchEvent): void;
26
+ handleTouchEnd(): void;
27
+ handleMouseDown(event: MouseEvent): void;
28
+ handleMouseMove(event: MouseEvent): void;
29
+ handleMouseUp(): void;
30
+ handleMouseLeave(): void;
31
+ private toggleActiveCard;
32
+ private updateSelectedIndex;
33
+ private scrollToSelectedCard;
34
+ private selectCard;
35
+ private _notifySelection;
36
+ private adjustCardHeight;
37
+ }
38
+ export {};
@@ -0,0 +1,246 @@
1
+ import { __decorate } from "tslib";
2
+ import { css, html } from 'lit';
3
+ import { customElement, property, query, state } from 'lit/decorators.js';
4
+ import { OxFormField } from './ox-form-field';
5
+ let OxSelectFloor = class OxSelectFloor extends OxFormField {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.cards = [];
9
+ this.bottomLimit = 70;
10
+ this.selectedIndex = 0;
11
+ this.activeIndex = null;
12
+ this.isDragging = false;
13
+ this.lastTouchY = 0;
14
+ this.lastMouseY = 0;
15
+ }
16
+ static { this.styles = [
17
+ css `
18
+ :host {
19
+ display: block;
20
+ position: relative;
21
+ overflow: hidden;
22
+ height: 100%;
23
+
24
+ --ox-select-floor-rotate-x: 60deg;
25
+ --ox-select-floor-rotate-x-active: 40deg;
26
+ --ox-select-floor-perspective: 1200px;
27
+ }
28
+
29
+ .carousel-container {
30
+ position: relative;
31
+ height: 100%;
32
+ width: 100%;
33
+ overflow: hidden;
34
+ user-select: none;
35
+ }
36
+
37
+ .card {
38
+ position: absolute;
39
+ bottom: 0;
40
+ width: 100%;
41
+ background-color: white;
42
+ transition:
43
+ transform 0.3s ease,
44
+ opacity 0.3s ease,
45
+ box-shadow 0.3s ease,
46
+ border 0.3s ease;
47
+ transform-origin: bottom;
48
+ transform: perspective(var(--ox-select-floor-perspective)) rotateX(var(--ox-select-floor-rotate-x));
49
+ opacity: 0.5;
50
+ border: 2px solid transparent;
51
+ border-radius: 12px;
52
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
53
+ }
54
+
55
+ .card img {
56
+ width: 100%;
57
+ height: auto;
58
+ display: block;
59
+ pointer-events: none;
60
+ border-radius: 12px;
61
+ }
62
+
63
+ .selected {
64
+ z-index: 10;
65
+ opacity: 0.8;
66
+ border: 4px solid #3b82f6;
67
+ box-shadow: 0 8px 16px rgba(59, 130, 246, 0.4);
68
+ }
69
+
70
+ .selected.active {
71
+ opacity: 1;
72
+ transform: perspective(var(--ox-select-floor-perspective)) rotateX(var(--ox-select-floor-rotate-x-active));
73
+ box-shadow: 0 12px 24px rgba(59, 130, 246, 0.4);
74
+ }
75
+
76
+ [template-container] {
77
+ position: absolute;
78
+ right: 10px;
79
+ z-index: 20;
80
+ }
81
+ `
82
+ ]; }
83
+ render() {
84
+ const length = this.cards.length;
85
+ return html `
86
+ <div
87
+ class="carousel-container"
88
+ @wheel=${this.handleWheel}
89
+ @mousedown=${this.handleMouseDown}
90
+ @mousemove=${this.handleMouseMove}
91
+ @mouseup=${this.handleMouseUp}
92
+ @mouseleave=${this.handleMouseLeave}
93
+ @touchstart=${this.handleTouchStart}
94
+ @touchmove=${this.handleTouchMove}
95
+ @touchend=${this.handleTouchEnd}
96
+ >
97
+ ${this.cards.map(({ image, name }, index) => {
98
+ const reverse = length - index - 1;
99
+ return html `
100
+ <div
101
+ class="card ${this.getClassForCard(reverse)} ${this.isActive(reverse) ? 'active' : ''}"
102
+ style="bottom: ${(this.bottomLimit * reverse) / length}%;"
103
+ @click=${() => this.selectCard(reverse)}
104
+ @tap=${() => this.toggleActiveCard(reverse)}
105
+ >
106
+ <img src="${image}" @load=${(e) => this.adjustCardHeight(e, reverse)} />
107
+ </div>
108
+ `;
109
+ })}
110
+ ${this.cards.map(({ image, name }, index) => {
111
+ const reverse = length - index - 1;
112
+ return html `
113
+ <div
114
+ style="bottom: ${(this.bottomLimit * reverse) / length}%;"
115
+ @click=${() => this.selectCard(reverse)}
116
+ template-container
117
+ >
118
+ <slot name="template-${reverse}"></slot>
119
+ </div>
120
+ `;
121
+ })}
122
+ </div>
123
+ `;
124
+ }
125
+ updated(changes) {
126
+ if (changes.has('value')) {
127
+ if (this.value) {
128
+ this.selectedIndex = this.cards.findIndex(card => card.name == this.value);
129
+ }
130
+ else {
131
+ this.selectedIndex = -1;
132
+ }
133
+ }
134
+ }
135
+ firstUpdated() {
136
+ this.scrollToSelectedCard();
137
+ }
138
+ getClassForCard(index) {
139
+ return index === this.selectedIndex ? 'selected' : 'compressed';
140
+ }
141
+ isActive(index) {
142
+ return this.activeIndex === index;
143
+ }
144
+ handleWheel(event) {
145
+ event.preventDefault();
146
+ const delta = Math.sign(event.deltaY);
147
+ this.updateSelectedIndex(this.selectedIndex + delta);
148
+ }
149
+ handleTouchStart(event) {
150
+ this.lastTouchY = event.touches[0].clientY;
151
+ }
152
+ handleTouchMove(event) {
153
+ const touch = event.touches[0];
154
+ const deltaY = touch.clientY - this.lastTouchY;
155
+ this.lastTouchY = touch.clientY;
156
+ if (Math.abs(deltaY) > 30) {
157
+ const direction = deltaY < 0 ? -1 : 1;
158
+ this.updateSelectedIndex(this.selectedIndex + direction);
159
+ }
160
+ }
161
+ handleTouchEnd() {
162
+ this.isDragging = false;
163
+ }
164
+ handleMouseDown(event) {
165
+ this.isDragging = true;
166
+ this.lastMouseY = event.clientY;
167
+ }
168
+ handleMouseMove(event) {
169
+ if (!this.isDragging) {
170
+ return;
171
+ }
172
+ const deltaY = event.clientY - this.lastMouseY;
173
+ if (!this.lastMouseY) {
174
+ this.lastMouseY = event.clientY;
175
+ }
176
+ if (Math.abs(deltaY) > 30) {
177
+ this.lastMouseY = event.clientY;
178
+ const direction = deltaY > 0 ? -1 : 1;
179
+ this.updateSelectedIndex(this.selectedIndex + direction);
180
+ }
181
+ }
182
+ handleMouseUp() {
183
+ this.isDragging = false;
184
+ }
185
+ handleMouseLeave() {
186
+ this.isDragging = false;
187
+ }
188
+ toggleActiveCard(index) {
189
+ if (this.activeIndex === index) {
190
+ this.activeIndex = null;
191
+ }
192
+ else {
193
+ this.activeIndex = index;
194
+ }
195
+ }
196
+ updateSelectedIndex(newIndex) {
197
+ this.activeIndex = null;
198
+ this.selectedIndex = Math.max(0, Math.min(newIndex, this.cards.length - 1));
199
+ this.scrollToSelectedCard();
200
+ }
201
+ scrollToSelectedCard() {
202
+ const cardHeight = 320;
203
+ const targetScrollTop = this.selectedIndex * cardHeight - (window.innerHeight / 2 - cardHeight / 2);
204
+ this.carouselContainer.scrollTo({ top: targetScrollTop, behavior: 'smooth' });
205
+ }
206
+ selectCard(index) {
207
+ this.selectedIndex = index;
208
+ this._notifySelection();
209
+ this.scrollToSelectedCard();
210
+ }
211
+ _notifySelection() {
212
+ this.value = this.selectedIndex !== -1 ? this.cards[this.selectedIndex]?.name : undefined;
213
+ this.dispatchEvent(new CustomEvent('change', {
214
+ detail: this.value
215
+ }));
216
+ }
217
+ adjustCardHeight(e, index) {
218
+ const imgElement = e.target;
219
+ const aspectRatio = imgElement.naturalWidth / imgElement.naturalHeight;
220
+ const newHeight = imgElement.offsetWidth / aspectRatio;
221
+ imgElement.style.height = `${newHeight}px`;
222
+ }
223
+ };
224
+ __decorate([
225
+ property({ type: Array })
226
+ ], OxSelectFloor.prototype, "cards", void 0);
227
+ __decorate([
228
+ property({ type: String })
229
+ ], OxSelectFloor.prototype, "value", void 0);
230
+ __decorate([
231
+ property({ type: Number })
232
+ ], OxSelectFloor.prototype, "bottomLimit", void 0);
233
+ __decorate([
234
+ state()
235
+ ], OxSelectFloor.prototype, "selectedIndex", void 0);
236
+ __decorate([
237
+ state()
238
+ ], OxSelectFloor.prototype, "activeIndex", void 0);
239
+ __decorate([
240
+ query('.carousel-container')
241
+ ], OxSelectFloor.prototype, "carouselContainer", void 0);
242
+ OxSelectFloor = __decorate([
243
+ customElement('ox-select-floor')
244
+ ], OxSelectFloor);
245
+ export { OxSelectFloor };
246
+ //# sourceMappingURL=ox-select-floor.js.map