@operato/input 7.0.78 → 7.1.2

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,32 @@
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
+ ### [7.1.2](https://github.com/hatiolab/operato/compare/v7.1.1...v7.1.2) (2024-09-02)
7
+
8
+
9
+ ### :bug: Bug Fix
10
+
11
+ * input signature ([aff132e](https://github.com/hatiolab/operato/commit/aff132e06f794c18430ec3cb31691f82e01e7f28))
12
+ * support signature-input type for dataset ([f9e758e](https://github.com/hatiolab/operato/commit/f9e758eeb5efd6926af9d3526f0d7374e0c1b081))
13
+
14
+
15
+
16
+ ### [7.1.1](https://github.com/hatiolab/operato/compare/v7.0.80...v7.1.1) (2024-09-01)
17
+
18
+ **Note:** Version bump only for package @operato/input
19
+
20
+
21
+
22
+
23
+
24
+ ## [7.1.0](https://github.com/hatiolab/operato/compare/v7.0.80...v7.1.0) (2024-09-01)
25
+
26
+ **Note:** Version bump only for package @operato/input
27
+
28
+
29
+
30
+
31
+
6
32
  ### [7.0.78](https://github.com/hatiolab/operato/compare/v7.0.77...v7.0.78) (2024-08-31)
7
33
 
8
34
 
@@ -30,3 +30,4 @@ export * from './ox-input-textarea.js';
30
30
  export * from './ox-input-direction.js';
31
31
  export * from './ox-input-table-column-config.js';
32
32
  export * from './ox-input-search.js';
33
+ export * from './ox-input-signature.js';
package/dist/src/index.js CHANGED
@@ -30,4 +30,5 @@ export * from './ox-input-textarea.js';
30
30
  export * from './ox-input-direction.js';
31
31
  export * from './ox-input-table-column-config.js';
32
32
  export * from './ox-input-search.js';
33
+ export * from './ox-input-signature.js';
33
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mCAAmC,CAAA;AACjD,cAAc,sBAAsB,CAAA","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nexport * from './ox-form-field.js'\nexport * from './ox-buttons-radio.js'\nexport * from './ox-checkbox.js'\nexport * from './ox-select.js'\nexport * from './ox-input-angle.js'\nexport * from './ox-input-3dish.js'\nexport * from './ox-input-3axis.js'\nexport * from './ox-input-stack.js'\nexport * from './ox-input-barcode.js'\nexport * from './ox-input-code.js'\nexport * from './ox-input-color.js'\nexport * from './ox-input-multiple-colors.js'\nexport * from './ox-input-color-stops.js'\nexport * from './ox-input-color-gradient.js'\nexport * from './ox-input-file.js'\nexport * from './ox-input-image.js'\nexport * from './ox-input-value-ranges.js'\nexport * from './ox-input-value-map.js'\nexport * from './ox-input-table.js'\nexport * from './ox-input-scene-component-id.js'\nexport * from './ox-input-crontab.js'\nexport * from './ox-input-partition-keys.js'\nexport * from './ox-input-duration.js'\nexport * from './ox-input-quantifier.js'\nexport * from './ox-input-select-buttons.js'\nexport * from './ox-input-textarea.js'\nexport * from './ox-input-direction.js'\nexport * from './ox-input-table-column-config.js'\nexport * from './ox-input-search.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mCAAmC,CAAA;AACjD,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nexport * from './ox-form-field.js'\nexport * from './ox-buttons-radio.js'\nexport * from './ox-checkbox.js'\nexport * from './ox-select.js'\nexport * from './ox-input-angle.js'\nexport * from './ox-input-3dish.js'\nexport * from './ox-input-3axis.js'\nexport * from './ox-input-stack.js'\nexport * from './ox-input-barcode.js'\nexport * from './ox-input-code.js'\nexport * from './ox-input-color.js'\nexport * from './ox-input-multiple-colors.js'\nexport * from './ox-input-color-stops.js'\nexport * from './ox-input-color-gradient.js'\nexport * from './ox-input-file.js'\nexport * from './ox-input-image.js'\nexport * from './ox-input-value-ranges.js'\nexport * from './ox-input-value-map.js'\nexport * from './ox-input-table.js'\nexport * from './ox-input-scene-component-id.js'\nexport * from './ox-input-crontab.js'\nexport * from './ox-input-partition-keys.js'\nexport * from './ox-input-duration.js'\nexport * from './ox-input-quantifier.js'\nexport * from './ox-input-select-buttons.js'\nexport * from './ox-input-textarea.js'\nexport * from './ox-input-direction.js'\nexport * from './ox-input-table-column-config.js'\nexport * from './ox-input-search.js'\nexport * from './ox-input-signature.js'\n"]}
@@ -0,0 +1,23 @@
1
+ import '@material/web/icon/icon.js';
2
+ import { OxFormField } from './ox-form-field.js';
3
+ export declare class OxInputSignature extends OxFormField {
4
+ static styles: import("lit").CSSResult[];
5
+ isDrawing: boolean;
6
+ value: string | null;
7
+ private ctx;
8
+ private canvas;
9
+ render(): import("lit-html").TemplateResult<1>;
10
+ firstUpdated(): void;
11
+ updated(changedProperties: Map<string | number | symbol, unknown>): void;
12
+ startDrawing(event: MouseEvent | TouchEvent): void;
13
+ stopDrawing(): void;
14
+ draw(event: MouseEvent | TouchEvent): void;
15
+ clearCanvas(): void;
16
+ saveSignature(): void;
17
+ loadSignature(dataUrl: string): void;
18
+ getEventPosition(event: MouseEvent | TouchEvent): {
19
+ x: number;
20
+ y: number;
21
+ };
22
+ _notifyChange(): void;
23
+ }
@@ -0,0 +1,144 @@
1
+ import { __decorate } from "tslib";
2
+ import '@material/web/icon/icon.js';
3
+ import { css, html, nothing } from 'lit';
4
+ import { customElement, property } from 'lit/decorators.js';
5
+ import { OxFormField } from './ox-form-field.js';
6
+ let OxInputSignature = class OxInputSignature extends OxFormField {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.isDrawing = false;
10
+ this.value = null;
11
+ }
12
+ static { this.styles = [
13
+ css `
14
+ :host {
15
+ position: relative;
16
+ box-sizing: border-box;
17
+
18
+ display: flex;
19
+ 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;
25
+
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);
30
+
31
+ overflow: hidden;
32
+ }
33
+
34
+ canvas {
35
+ width: 100%;
36
+ border: 1px solid #000;
37
+ }
38
+
39
+ .controls {
40
+ margin-top: 10px;
41
+ }
42
+ `
43
+ ]; }
44
+ render() {
45
+ 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>
57
+
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}
64
+ `;
65
+ }
66
+ firstUpdated() {
67
+ this.canvas = this.shadowRoot.querySelector('canvas');
68
+ this.ctx = this.canvas.getContext('2d');
69
+ this.ctx.strokeStyle = '#000';
70
+ this.ctx.lineWidth = 2;
71
+ // 처음 로딩 시 서명 데이터를 캔버스에 표시
72
+ if (this.value) {
73
+ this.loadSignature(this.value);
74
+ }
75
+ }
76
+ updated(changedProperties) {
77
+ if (changedProperties.has('value') && this.value) {
78
+ this.loadSignature(this.value);
79
+ }
80
+ }
81
+ startDrawing(event) {
82
+ if (this.disabled) {
83
+ return;
84
+ }
85
+ this.isDrawing = true;
86
+ this.ctx.beginPath();
87
+ const position = this.getEventPosition(event);
88
+ this.ctx.moveTo(position.x, position.y);
89
+ }
90
+ stopDrawing() {
91
+ this.isDrawing = false;
92
+ }
93
+ draw(event) {
94
+ if (!this.isDrawing)
95
+ return;
96
+ const position = this.getEventPosition(event);
97
+ this.ctx.lineTo(position.x, position.y);
98
+ this.ctx.stroke();
99
+ }
100
+ clearCanvas() {
101
+ this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
102
+ }
103
+ saveSignature() {
104
+ this.value = this.canvas.toDataURL();
105
+ this._notifyChange();
106
+ }
107
+ 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;
114
+ }
115
+ getEventPosition(event) {
116
+ const rect = this.canvas.getBoundingClientRect();
117
+ // 캔버스의 실제 크기와 CSS 크기 간의 비율을 계산
118
+ const scaleX = this.canvas.width / rect.width;
119
+ const scaleY = this.canvas.height / rect.height;
120
+ // 실제 좌표 계산
121
+ const isTouchEvent = event instanceof TouchEvent;
122
+ const x = (isTouchEvent ? event.touches[0].clientX - rect.left : event.clientX - rect.left) * scaleX;
123
+ const y = (isTouchEvent ? event.touches[0].clientY - rect.top : event.clientY - rect.top) * scaleY;
124
+ return { x, y };
125
+ }
126
+ _notifyChange() {
127
+ this.dispatchEvent(new CustomEvent('change', {
128
+ bubbles: true,
129
+ composed: true,
130
+ detail: this.value
131
+ }));
132
+ }
133
+ };
134
+ __decorate([
135
+ property({ type: Boolean })
136
+ ], OxInputSignature.prototype, "isDrawing", void 0);
137
+ __decorate([
138
+ property({ type: String })
139
+ ], OxInputSignature.prototype, "value", void 0);
140
+ OxInputSignature = __decorate([
141
+ customElement('ox-input-signature')
142
+ ], OxInputSignature);
143
+ export { OxInputSignature };
144
+ //# sourceMappingURL=ox-input-signature.js.map
@@ -0,0 +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,cAAS,GAAG,KAAK,CAAA;QAClB,UAAK,GAAkB,IAAI,CAAA;IA8GzD,CAAC;aAhJQ,WAAM,GAAG;QACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6BF;KACF,AA/BY,CA+BZ;IAQD,MAAM;QACJ,OAAO,IAAI,CAAA;;;;qBAIM,IAAI,CAAC,YAAY;mBACnB,IAAI,CAAC,WAAW;qBACd,IAAI,CAAC,IAAI;sBACR,IAAI,CAAC,WAAW;sBAChB,IAAI,CAAC,YAAY;oBACnB,IAAI,CAAC,WAAW;qBACf,IAAI,CAAC,IAAI;;;QAGtB,CAAC,IAAI,CAAC,QAAQ;YACd,CAAC,CAAC,IAAI,CAAA;8BACgB,IAAI,CAAC,WAAW;8BAChB,IAAI,CAAC,aAAa;iBAC/B;YACT,CAAC,CAAC,OAAO;KACZ,CAAA;IACH,CAAC;IAED,YAAY;QACV,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAW,CAAC,aAAa,CAAC,QAAQ,CAAE,CAAA;QACvD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAE,CAAA;QACxC,IAAI,CAAC,GAAG,CAAC,WAAW,GAAG,MAAM,CAAA;QAC7B,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,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AAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAE,KAAoB,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAA;QAElH,OAAO,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;;AA9G4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,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"]}
@@ -0,0 +1,23 @@
1
+ import '../src/ox-input-signature.js';
2
+ import { TemplateResult } from 'lit';
3
+ declare const _default: {
4
+ title: string;
5
+ component: string;
6
+ argTypes: {
7
+ disabled: {
8
+ control: string;
9
+ };
10
+ };
11
+ };
12
+ export default _default;
13
+ interface Story<T> {
14
+ (args: T): TemplateResult;
15
+ args?: Partial<T>;
16
+ argTypes?: Record<string, unknown>;
17
+ }
18
+ interface ArgTypes {
19
+ label?: string;
20
+ name?: string;
21
+ disabled?: boolean;
22
+ }
23
+ export declare const Regular: Story<ArgTypes>;
@@ -0,0 +1,56 @@
1
+ import '../src/ox-input-signature.js';
2
+ import { html } from 'lit';
3
+ import { styles as MDTypeScaleStyles } from '@material/web/typography/md-typescale-styles';
4
+ export default {
5
+ title: 'ox-input-signature',
6
+ component: 'ox-input-signature',
7
+ argTypes: {
8
+ disabled: { control: 'boolean' }
9
+ }
10
+ };
11
+ const Template = ({ label = 'signature', name = 'signature', disabled }) => html `
12
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet" />
13
+
14
+ <link href="/themes/light.css" rel="stylesheet" />
15
+ <link href="/themes/dark.css" rel="stylesheet" />
16
+ <link href="/themes/spacing.css" rel="stylesheet" />
17
+
18
+ <link
19
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
20
+ rel="stylesheet"
21
+ />
22
+ <link
23
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
24
+ rel="stylesheet"
25
+ />
26
+ <link
27
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
28
+ rel="stylesheet"
29
+ />
30
+
31
+ <style>
32
+ ${MDTypeScaleStyles.cssText}
33
+ </style>
34
+
35
+ <style>
36
+ .container {
37
+ height: 500px;
38
+ text-align: center;
39
+ padding: 20px;
40
+
41
+ background-color: var(--md-sys-color-primary-container);
42
+ color: var(--md-sys-color-on-primary-container);
43
+ }
44
+ </style>
45
+
46
+ <div class="container md-typescale-body-large-prominent">
47
+ <ox-input-signature
48
+ ?disabled=${disabled}
49
+ @change=${(e) => console.log(e.target.value)}
50
+ >
51
+ </ox-input-signature>
52
+ </div>
53
+ `;
54
+ export const Regular = Template.bind({});
55
+ Regular.args = {};
56
+ //# sourceMappingURL=ox-input-%08signature.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-input-\bsignature.stories.js","sourceRoot":"","sources":["../../stories/ox-input-\bsignature.stories.ts"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAA;AAErC,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC1C,OAAO,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,8CAA8C,CAAA;AAE1F,eAAe;IACb,KAAK,EAAE,oBAAoB;IAC3B,SAAS,EAAE,oBAAoB;IAC/B,QAAQ,EAAE;QACR,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;KACjC;CACF,CAAA;AAcD,MAAM,QAAQ,GAAoB,CAAC,EAAE,KAAK,GAAG,WAAW,EAAE,IAAI,GAAG,WAAW,EAAE,QAAQ,EAAY,EAAE,EAAE,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;MAqBrG,iBAAiB,CAAC,OAAO;;;;;;;;;;;;;;;;kBAgBb,QAAQ;gBACV,CAAC,CAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAG,CAAiB,CAAC,MAAe,CAAC,KAAK,CAAC;;;;CAInF,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACxC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAA","sourcesContent":["import '../src/ox-input-signature.js'\n\nimport { html, TemplateResult } from 'lit'\nimport { styles as MDTypeScaleStyles } from '@material/web/typography/md-typescale-styles'\n\nexport default {\n title: 'ox-input-signature',\n component: 'ox-input-signature',\n argTypes: {\n disabled: { control: 'boolean' }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n label?: string\n name?: string\n disabled?: boolean\n}\n\nconst Template: Story<ArgTypes> = ({ label = 'signature', name = 'signature', disabled }: ArgTypes) => html`\n <link href=\"https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap\" rel=\"stylesheet\" />\n\n <link href=\"/themes/light.css\" rel=\"stylesheet\" />\n <link href=\"/themes/dark.css\" rel=\"stylesheet\" />\n <link href=\"/themes/spacing.css\" rel=\"stylesheet\" />\n\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n\n <style>\n ${MDTypeScaleStyles.cssText}\n </style>\n\n <style>\n .container {\n height: 500px;\n text-align: center;\n padding: 20px;\n\n background-color: var(--md-sys-color-primary-container);\n color: var(--md-sys-color-on-primary-container);\n }\n </style>\n\n <div class=\"container md-typescale-body-large-prominent\">\n <ox-input-signature\n ?disabled=${disabled}\n @change=${(e: Event) => console.log(((e as CustomEvent).target as any)!.value)}\n >\n </ox-input-signature>\n </div>\n`\n\nexport const Regular = Template.bind({})\nRegular.args = {}\n"]}