@operato/input 2.0.0-beta.2 → 2.0.0-beta.20

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.
@@ -8,18 +8,7 @@ import './ox-checkbox.js';
8
8
  import { css, html, render } from 'lit';
9
9
  import { customElement, property, state } from 'lit/decorators.js';
10
10
  import { TooltipStyles } from '@operato/styles';
11
- import { detectOverflow } from '@operato/utils';
12
11
  import { OxFormField } from './ox-form-field.js';
13
- function onmouseover(e) {
14
- const element = e.target;
15
- if (detectOverflow(element)) {
16
- element.setAttribute('data-tooltip', element.textContent);
17
- }
18
- }
19
- function onmouseout(e) {
20
- const element = e.target;
21
- element.removeAttribute('data-tooltip');
22
- }
23
12
  let OxSelect = class OxSelect extends OxFormField {
24
13
  constructor() {
25
14
  super(...arguments);
@@ -88,7 +77,7 @@ let OxSelect = class OxSelect extends OxFormField {
88
77
  '';
89
78
  return html `
90
79
  <div @click=${this.expand}>
91
- <span @mouseover=${onmouseover} @mouseout=${onmouseout}>${label}</span>
80
+ <span data-reactive-tooltip>${label}</span>
92
81
  <md-icon>expand_more</md-icon>
93
82
  </div>
94
83
 
@@ -1 +1 @@
1
- {"version":3,"file":"ox-select.js","sourceRoot":"","sources":["../../src/ox-select.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AACnC,OAAO,iCAAiC,CAAA;AACxC,OAAO,kBAAkB,CAAA;AAEzB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAA2B,MAAM,KAAK,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAGzE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,SAAS,WAAW,CAAC,CAA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AAG;YACR,CAAC,CAAC,IAAI,CAAA,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA,sBAAsB,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,OAAO,SAAS,CAAC,EAAE;;KAE3G,CAAA;QAED,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IACxB,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,OAAM;QACR,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe,CAAgB,CAAA;QAEpE,IAAI,SAAS,EAAE,CAAC;YACd,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,WAAW,IAAI,CAAA;YAC/C,MAAM,KAAK,GAAG,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAA;YAErE,MAAM,KAAK,GAAG;gBACZ,GAAG,EAAE,IAAI,CAAC,YAAY;gBACtB,CAAC,KAAK,CAAC,EAAE,CAAC;aACX,CAAA;YAED,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACvB,CAAC;IACH,CAAC;;AA9H2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAyB;AAE3C;IAAR,KAAK,EAAE;uCAA8B;AA3D3B,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAuLpB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/icon/icon.js'\nimport '@operato/popup/ox-popup-list.js'\nimport './ox-checkbox.js'\n\nimport { css, html, render, PropertyValues, nothing } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { OxPopupList } from '@operato/popup'\nimport { TooltipStyles } from '@operato/styles'\nimport { detectOverflow } from '@operato/utils'\n\nimport { OxFormField } from './ox-form-field.js'\n\nfunction onmouseover(e: Event) {\n const element = e.target as HTMLSpanElement\n if (detectOverflow(element)) {\n element.setAttribute('data-tooltip', element.textContent!)\n }\n}\n\nfunction onmouseout(e: Event) {\n const element = e.target as HTMLSpanElement\n element.removeAttribute('data-tooltip')\n}\n\n@customElement('ox-select')\nexport class OxSelect extends OxFormField {\n static styles = [\n TooltipStyles,\n css`\n :host {\n display: block;\n position: relative;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15);\n\n --ox-select-padding: var(--spacing-tiny);\n --ox-select-font: var(--input-font);\n --ox-select-color: var(--input-color, var(--md-sys-color-on-surface-variant));\n --ox-select-icon-color: var(--theme-primary-text-color, var(--md-sys-color-on-surface-variant));\n --ox-select-icon-hover-color: var(--md-sys-color-on-primary-container, #3c3938);\n }\n\n div {\n width: 100%;\n box-sizing: border-box;\n\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n padding: var(--ox-select-padding);\n font: var(--ox-select-font);\n color: var(--ox-select-color);\n }\n\n span {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n gap: 4px;\n }\n\n md-icon {\n --md-icon-size: 16px;\n display: block;\n text-align: right;\n color: var(--ox-select-icon-color);\n opacity: 0.7;\n }\n\n div:hover md-icon {\n color: var(--md-sys-color-on-primary-container);\n }\n\n ::slotted(ox-popup-list) {\n width: 100%;\n }\n `\n ]\n\n @property({ type: String }) name: string = ''\n @property({ type: String }) placeholder: string = ''\n\n @state() label: string | string[] = ''\n\n render() {\n const label =\n (this.label instanceof Array ? this.label.join(', ') : this.label?.trim()) ||\n (this.value instanceof Array ? this.value.join(', ') : this.value?.trim()) ||\n this.placeholder ||\n ''\n\n return html`\n <div @click=${this.expand}>\n <span @mouseover=${onmouseover} @mouseout=${onmouseout}>${label}</span>\n <md-icon>expand_more</md-icon>\n </div>\n\n <slot></slot>\n `\n }\n\n connectedCallback() {\n super.connectedCallback()\n\n this.setAttribute('tabindex', '0')\n\n this.addEventListener('select', (e: Event) => {\n this.value = (e as CustomEvent).detail\n })\n\n this.addEventListener('close', e => {\n /* popup이 close될 때 change 이벤트를 발생시킨다. */\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n })\n\n this.addEventListener('keydown', (e: KeyboardEvent) => {\n e.preventDefault()\n\n if (e.key === ' ' || e.key === 'Spacebar' || e.key === 'ArrowDown') {\n this.expand()\n }\n })\n }\n\n async updated(changes: PropertyValues<this>) {\n if (changes.has('value')) {\n const popupList = this.querySelector('ox-popup-list') as OxPopupList\n if (popupList) {\n popupList.value = this.value\n await this.requestUpdate()\n\n this.label = popupList.getSelectedLabels()\n }\n }\n }\n\n setOptions(\n options: string[] | { display: string; value: string }[],\n opt: { multiple?: boolean; withSearch?: boolean } = {}\n ) {\n const objOptions = options.map(option => {\n return typeof option == 'string' ? { display: option, value: option } : option\n })\n\n const { multiple, withSearch } = opt || {}\n\n const template = html`\n <ox-popup-list\n align-left\n nowrap\n ?multiple=${multiple}\n attr-selected=${multiple ? 'checked' : ''}\n ?with-search=${withSearch}\n >\n ${multiple\n ? html`<ox-checkbox\n @change=${(e: Event) => {\n const target = e.target as HTMLInputElement\n const options = Array.from(target.parentElement!.querySelectorAll('[option]')).filter(\n option => !option.hasAttribute('hidden')\n )\n options.forEach(option => ((option as HTMLInputElement).checked = target.checked))\n\n this.value = options\n .map(option =>\n (option as HTMLInputElement).checked ? (option as HTMLInputElement).value : undefined\n )\n .filter(Boolean)\n }}\n >set all</ox-checkbox\n >\n ${objOptions.map(\n option => html` <ox-checkbox option value=${option.value}>${option.display}</ox-checkbox> `\n )} `\n : html`${objOptions.map(option => html` <div option value=${option.value}>${option.display}</div> `)}`}\n </ox-popup-list>\n `\n\n render(template, this)\n }\n\n expand() {\n if (this.disabled) {\n return\n }\n\n const popupList = this.querySelector('ox-popup-list') as OxPopupList\n\n if (popupList) {\n popupList.style.width = `${this.offsetWidth}px`\n const align = popupList.hasAttribute('align-left') ? 'left' : 'right'\n\n const props = {\n top: this.offsetHeight,\n [align]: 0\n }\n\n popupList.open(props)\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ox-select.js","sourceRoot":"","sources":["../../src/ox-select.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AACnC,OAAO,iCAAiC,CAAA;AACxC,OAAO,kBAAkB,CAAA;AAEzB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAA2B,MAAM,KAAK,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAGzE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGzC,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,WAAW;IAAlC;;QAwDuB,SAAI,GAAW,EAAE,CAAA;QACjB,gBAAW,GAAW,EAAE,CAAA;QAE3C,UAAK,GAAsB,EAAE,CAAA;IA4HxC,CAAC;aAtLQ,WAAM,GAAG;QACd,aAAa;QACb,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkDF;KACF,AArDY,CAqDZ;IAOD,MAAM;QACJ,MAAM,KAAK,GACT,CAAC,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;YAC1E,CAAC,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,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CAAC,WAAW,CAAC;GACd,QAAQ,CAuLpB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/icon/icon.js'\nimport '@operato/popup/ox-popup-list.js'\nimport './ox-checkbox.js'\n\nimport { css, html, render, PropertyValues, nothing } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { OxPopupList } from '@operato/popup'\nimport { TooltipStyles } from '@operato/styles'\n\nimport { OxFormField } from './ox-form-field.js'\n\n@customElement('ox-select')\nexport class OxSelect extends OxFormField {\n static styles = [\n TooltipStyles,\n css`\n :host {\n display: block;\n position: relative;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15);\n\n --ox-select-padding: var(--spacing-tiny);\n --ox-select-font: var(--input-font);\n --ox-select-color: var(--input-color, var(--md-sys-color-on-surface-variant));\n --ox-select-icon-color: var(--theme-primary-text-color, var(--md-sys-color-on-surface-variant));\n --ox-select-icon-hover-color: var(--md-sys-color-on-primary-container, #3c3938);\n }\n\n div {\n width: 100%;\n box-sizing: border-box;\n\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n padding: var(--ox-select-padding);\n font: var(--ox-select-font);\n color: var(--ox-select-color);\n }\n\n span {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n gap: 4px;\n }\n\n md-icon {\n --md-icon-size: 16px;\n display: block;\n text-align: right;\n color: var(--ox-select-icon-color);\n opacity: 0.7;\n }\n\n div:hover md-icon {\n color: var(--md-sys-color-on-primary-container);\n }\n\n ::slotted(ox-popup-list) {\n width: 100%;\n }\n `\n ]\n\n @property({ type: String }) name: string = ''\n @property({ type: String }) placeholder: string = ''\n\n @state() label: string | string[] = ''\n\n render() {\n const label =\n (this.label instanceof Array ? this.label.join(', ') : this.label?.trim()) ||\n (this.value instanceof Array ? this.value.join(', ') : this.value?.trim()) ||\n this.placeholder ||\n ''\n\n return html`\n <div @click=${this.expand}>\n <span data-reactive-tooltip>${label}</span>\n <md-icon>expand_more</md-icon>\n </div>\n\n <slot></slot>\n `\n }\n\n connectedCallback() {\n super.connectedCallback()\n\n this.setAttribute('tabindex', '0')\n\n this.addEventListener('select', (e: Event) => {\n this.value = (e as CustomEvent).detail\n })\n\n this.addEventListener('close', e => {\n /* popup이 close될 때 change 이벤트를 발생시킨다. */\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n })\n\n this.addEventListener('keydown', (e: KeyboardEvent) => {\n e.preventDefault()\n\n if (e.key === ' ' || e.key === 'Spacebar' || e.key === 'ArrowDown') {\n this.expand()\n }\n })\n }\n\n async updated(changes: PropertyValues<this>) {\n if (changes.has('value')) {\n const popupList = this.querySelector('ox-popup-list') as OxPopupList\n if (popupList) {\n popupList.value = this.value\n await this.requestUpdate()\n\n this.label = popupList.getSelectedLabels()\n }\n }\n }\n\n setOptions(\n options: string[] | { display: string; value: string }[],\n opt: { multiple?: boolean; withSearch?: boolean } = {}\n ) {\n const objOptions = options.map(option => {\n return typeof option == 'string' ? { display: option, value: option } : option\n })\n\n const { multiple, withSearch } = opt || {}\n\n const template = html`\n <ox-popup-list\n align-left\n nowrap\n ?multiple=${multiple}\n attr-selected=${multiple ? 'checked' : ''}\n ?with-search=${withSearch}\n >\n ${multiple\n ? html`<ox-checkbox\n @change=${(e: Event) => {\n const target = e.target as HTMLInputElement\n const options = Array.from(target.parentElement!.querySelectorAll('[option]')).filter(\n option => !option.hasAttribute('hidden')\n )\n options.forEach(option => ((option as HTMLInputElement).checked = target.checked))\n\n this.value = options\n .map(option =>\n (option as HTMLInputElement).checked ? (option as HTMLInputElement).value : undefined\n )\n .filter(Boolean)\n }}\n >set all</ox-checkbox\n >\n ${objOptions.map(\n option => html` <ox-checkbox option value=${option.value}>${option.display}</ox-checkbox> `\n )} `\n : html`${objOptions.map(option => html` <div option value=${option.value}>${option.display}</div> `)}`}\n </ox-popup-list>\n `\n\n render(template, this)\n }\n\n expand() {\n if (this.disabled) {\n return\n }\n\n const popupList = this.querySelector('ox-popup-list') as OxPopupList\n\n if (popupList) {\n popupList.style.width = `${this.offsetWidth}px`\n const align = popupList.hasAttribute('align-left') ? 'left' : 'right'\n\n const props = {\n top: this.offsetHeight,\n [align]: 0\n }\n\n popupList.open(props)\n }\n }\n}\n"]}
@@ -0,0 +1,34 @@
1
+ import '../src/ox-input-table-column-config.js';
2
+ import { TemplateResult } from 'lit';
3
+ declare const _default: {
4
+ title: string;
5
+ component: string;
6
+ argTypes: {
7
+ name: {
8
+ control: string;
9
+ };
10
+ value: {
11
+ control: string;
12
+ };
13
+ disabled: {
14
+ control: string;
15
+ };
16
+ theme: {
17
+ control: string;
18
+ options: string[];
19
+ };
20
+ };
21
+ };
22
+ export default _default;
23
+ interface Story<T> {
24
+ (args: T): TemplateResult;
25
+ args?: Partial<T>;
26
+ argTypes?: Record<string, unknown>;
27
+ }
28
+ interface ArgTypes {
29
+ name?: string;
30
+ value?: object;
31
+ disabled?: boolean;
32
+ theme?: string;
33
+ }
34
+ export declare const Regular: Story<ArgTypes>;
@@ -0,0 +1,99 @@
1
+ import '../src/ox-input-table-column-config.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-table-column-config',
6
+ component: 'ox-input-table-column-config',
7
+ argTypes: {
8
+ name: { control: 'text' },
9
+ value: { control: 'object' },
10
+ disabled: { control: 'boolean' },
11
+ theme: { control: 'select', options: ['light', 'dark'] }
12
+ }
13
+ };
14
+ const Template = ({ name = 'table-column-config', value = {}, disabled, theme = 'light' }) => html `
15
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet" />
16
+
17
+ <link href="/themes/light.css" rel="stylesheet" />
18
+ <link href="/themes/dark.css" rel="stylesheet" />
19
+ <link href="/themes/spacing.css" rel="stylesheet" />
20
+
21
+ <link
22
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
23
+ rel="stylesheet"
24
+ />
25
+ <link
26
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
27
+ rel="stylesheet"
28
+ />
29
+ <link
30
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
31
+ rel="stylesheet"
32
+ />
33
+
34
+ <style>
35
+ ${MDTypeScaleStyles.cssText}
36
+ </style>
37
+
38
+ <style>
39
+ .container {
40
+ height: 500px;
41
+ text-align: center;
42
+ padding: 20px;
43
+
44
+ background-color: var(--md-sys-color-primary-container);
45
+ color: var(--md-sys-color-on-primary-container);
46
+ }
47
+ </style>
48
+
49
+ <script>
50
+ document.body.classList.add('${theme}')
51
+ </script>
52
+
53
+ <div class="container md-typescale-body-large-prominent">
54
+ <ox-input-table-column-config
55
+ @change=${(e) => {
56
+ console.log(e.target.value);
57
+ }}
58
+ name=${name}
59
+ .value=${value}
60
+ ?disabled=${disabled}
61
+ >
62
+ </ox-input-table-column-config>
63
+ </div>
64
+ `;
65
+ export const Regular = Template.bind({});
66
+ Regular.args = {
67
+ name: 'table-column-config',
68
+ value: [
69
+ {
70
+ name: 'section',
71
+ label: 'Section',
72
+ visible: true,
73
+ width: 100,
74
+ order: 1
75
+ },
76
+ {
77
+ name: 'title',
78
+ label: 'Title',
79
+ visible: true,
80
+ width: 110,
81
+ order: 2
82
+ },
83
+ {
84
+ name: 'startDate',
85
+ label: 'Start Date',
86
+ visible: true,
87
+ width: 150,
88
+ order: 3
89
+ },
90
+ {
91
+ name: 'endDate',
92
+ label: 'End Date',
93
+ visible: true,
94
+ width: 200,
95
+ order: 4
96
+ }
97
+ ]
98
+ };
99
+ //# sourceMappingURL=ox-input-table-column-config.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-input-table-column-config.stories.js","sourceRoot":"","sources":["../../stories/ox-input-table-column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ACb,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,CAAC;SACT;QACD;YACE,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,YAAY;YACnB,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,CAAC;SACT;QACD;YACE,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,CAAC;SACT;KACF;CACF,CAAA","sourcesContent":["import '../src/ox-input-table-column-config.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-table-column-config',\n component: 'ox-input-table-column-config',\n argTypes: {\n name: { control: 'text' },\n value: { control: 'object' },\n disabled: { control: 'boolean' },\n theme: { control: 'select', options: ['light', 'dark'] }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n name?: string\n value?: object\n disabled?: boolean\n theme?: string\n}\n\nconst Template: Story<ArgTypes> = ({\n name = 'table-column-config',\n value = {},\n disabled,\n theme = 'light'\n}: 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 <script>\n document.body.classList.add('${theme}')\n </script>\n\n <div class=\"container md-typescale-body-large-prominent\">\n <ox-input-table-column-config\n @change=${(e: Event) => {\n console.log((e.target as HTMLInputElement).value)\n }}\n name=${name}\n .value=${value}\n ?disabled=${disabled}\n >\n </ox-input-table-column-config>\n </div>\n`\n\nexport const Regular = Template.bind({})\nRegular.args = {\n name: 'table-column-config',\n value: [\n {\n name: 'section',\n label: 'Section',\n visible: true,\n width: 100,\n order: 1\n },\n {\n name: 'title',\n label: 'Title',\n visible: true,\n width: 110,\n order: 2\n },\n {\n name: 'startDate',\n label: 'Start Date',\n visible: true,\n width: 150,\n order: 3\n },\n {\n name: 'endDate',\n label: 'End Date',\n visible: true,\n width: 200,\n order: 4\n }\n ]\n}\n"]}