@esportsplus/ui 0.18.0 → 0.19.0

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 (93) hide show
  1. package/.github/dependabot.yml +2 -0
  2. package/.github/workflows/bump.yml +2 -0
  3. package/.github/workflows/dependabot.yml +12 -0
  4. package/.github/workflows/publish.yml +2 -0
  5. package/build/components/accordion/index.d.ts +5 -15
  6. package/build/components/accordion/index.js +28 -20
  7. package/build/components/counter/index.d.ts +2 -2
  8. package/build/components/counter/index.js +10 -10
  9. package/build/components/ellipsis/index.d.ts +1 -1
  10. package/build/components/field/checkbox.d.ts +9 -339
  11. package/build/components/field/checkbox.js +24 -21
  12. package/build/components/field/description.d.ts +3 -3
  13. package/build/components/field/error.d.ts +3 -2
  14. package/build/components/field/index.d.ts +1912 -0
  15. package/build/components/field/index.js +9 -0
  16. package/build/components/field/input.d.ts +18 -348
  17. package/build/components/field/input.js +33 -23
  18. package/build/components/field/select.d.ts +119 -226
  19. package/build/components/field/select.js +81 -69
  20. package/build/components/field/title.d.ts +114 -107
  21. package/build/components/field/title.js +15 -8
  22. package/build/components/form/action.d.ts +21 -6
  23. package/build/components/form/action.js +20 -9
  24. package/build/components/form/index.d.ts +130 -2
  25. package/build/components/frame/index.d.ts +3 -112
  26. package/build/components/frame/index.js +4 -6
  27. package/build/components/highlight/index.d.ts +5 -7
  28. package/build/components/highlight/index.js +23 -15
  29. package/build/components/icon/index.d.ts +3 -3
  30. package/build/components/index.d.ts +2 -2
  31. package/build/components/index.js +2 -2
  32. package/build/components/loader/index.d.ts +3 -3
  33. package/build/components/loader/index.js +13 -16
  34. package/build/components/loading/index.d.ts +1 -1
  35. package/build/components/overlay/index.d.ts +3 -112
  36. package/build/components/overlay/index.js +4 -6
  37. package/build/components/page/index.d.ts +0 -12
  38. package/build/components/page/index.js +0 -10
  39. package/build/components/root/onclick.js +4 -6
  40. package/build/components/scrollbar/index.d.ts +8 -112
  41. package/build/components/scrollbar/index.js +25 -20
  42. package/build/components/sidebar/index.d.ts +3 -112
  43. package/build/components/sidebar/index.js +4 -6
  44. package/build/components/site/index.d.ts +3 -112
  45. package/build/components/site/index.js +5 -8
  46. package/build/components/template/index.d.ts +8 -4
  47. package/build/components/template/index.js +5 -4
  48. package/build/components/tooltip/index.d.ts +235 -332
  49. package/build/components/tooltip/index.js +3 -106
  50. package/build/components/tooltip/menu.d.ts +20 -0
  51. package/build/components/tooltip/menu.js +28 -0
  52. package/build/components/tooltip/onclick.d.ts +124 -0
  53. package/build/components/tooltip/onclick.js +67 -0
  54. package/build/components/tooltip/onhover.d.ts +7 -0
  55. package/build/components/tooltip/onhover.js +25 -0
  56. package/build/components/typewriter/index.d.ts +4 -6
  57. package/build/components/typewriter/index.js +34 -33
  58. package/package.json +10 -9
  59. package/src/components/accordion/index.ts +41 -26
  60. package/src/components/counter/index.ts +15 -13
  61. package/src/components/field/checkbox.ts +31 -30
  62. package/src/components/field/description.ts +2 -2
  63. package/src/components/field/error.ts +2 -2
  64. package/src/components/field/index.ts +8 -3
  65. package/src/components/field/input.ts +41 -33
  66. package/src/components/field/select.ts +123 -108
  67. package/src/components/field/title.ts +18 -8
  68. package/src/components/form/action.ts +75 -47
  69. package/src/components/frame/index.ts +4 -9
  70. package/src/components/highlight/index.ts +53 -39
  71. package/src/components/icon/index.ts +3 -3
  72. package/src/components/index.ts +2 -2
  73. package/src/components/loader/index.ts +15 -17
  74. package/src/components/overlay/index.ts +4 -9
  75. package/src/components/page/index.ts +1 -17
  76. package/src/components/root/onclick.ts +6 -7
  77. package/src/components/scrollbar/index.ts +34 -23
  78. package/src/components/sidebar/index.ts +4 -9
  79. package/src/components/site/index.ts +5 -13
  80. package/src/components/template/index.ts +18 -10
  81. package/src/components/tooltip/index.ts +4 -156
  82. package/src/components/tooltip/menu.ts +52 -0
  83. package/src/components/tooltip/onclick.ts +97 -0
  84. package/src/components/tooltip/onhover.ts +35 -0
  85. package/src/components/typewriter/index.ts +44 -41
  86. package/build/components/footer/index.d.ts +0 -22
  87. package/build/components/footer/index.js +0 -61
  88. package/build/components/footer/scss/index.scss +0 -2
  89. package/build/components/form/types.d.ts +0 -10
  90. package/build/components/form/types.js +0 -1
  91. package/src/components/footer/index.ts +0 -74
  92. package/src/components/footer/scss/index.scss +0 -26
  93. package/src/components/form/types.ts +0 -14
@@ -4,10 +4,13 @@ import { omit } from '@esportsplus/utilities';
4
4
  import './scss/index.scss';
5
5
 
6
6
 
7
+ const OMIT = ['currency', 'decimals', 'delay', 'max', 'state', 'suffix', 'value'];
8
+
9
+
7
10
  let formatters: Record<string, Intl.NumberFormat> = {};
8
11
 
9
12
 
10
- export default (data: Attributes & {
13
+ export default (attributes: Attributes & {
11
14
  currency?: 'IGNORE' | 'EUR' | 'GBP' | 'USD';
12
15
  decimals?: number;
13
16
  delay?: number;
@@ -16,8 +19,8 @@ export default (data: Attributes & {
16
19
  suffix?: string;
17
20
  value: number;
18
21
  }) => {
19
- let { currency, decimals, delay, max, suffix, value } = data,
20
- api = data.state || reactive({ value: -1 }),
22
+ let { currency, decimals, delay, max, suffix, value } = attributes,
23
+ api = attributes.state || reactive({ value: -1 }),
21
24
  formatter = currency === 'IGNORE'
22
25
  ? undefined
23
26
  : formatters[currency || 'USD'] ??= new Intl.NumberFormat('en-US', {
@@ -76,7 +79,7 @@ export default (data: Attributes & {
76
79
  });
77
80
 
78
81
  return html`
79
- <div class='counter' ${omit(data, ['currency', 'decimals', 'delay', 'max', 'state', 'suffix'])}>
82
+ <div class='counter' ${omit(attributes, OMIT)}>
80
83
  ${() => {
81
84
  let n = state.length;
82
85
 
@@ -85,7 +88,7 @@ export default (data: Attributes & {
85
88
  }
86
89
 
87
90
  return html.reactive(state.render, function (value, i) {
88
- if (isNaN(parseInt(value as string, 10))) {
91
+ if (isNaN(parseInt(value, 10))) {
89
92
  return html`
90
93
  <span class='counter-character counter-character--symbol'>
91
94
  ${value}
@@ -94,20 +97,19 @@ export default (data: Attributes & {
94
97
  }
95
98
 
96
99
  return html`
97
- <div
98
- class='
99
- ${i > n - 3 && 'counter-character--fraction'}
100
- counter-character
101
- '
102
- >
103
- <div class='counter-character-track' style='${() => `--value: ${this[i]}`}'>
100
+ <div class=' counter-character' ${{
101
+ class: i > n - 3 && 'counter-character--fraction'
102
+ }}>
103
+ <div class='counter-character-track' ${{
104
+ style: `--value: ${this[i]}`}
105
+ }}>
104
106
  <span>9</span>
105
107
  ${[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((value) => html`<span>${value}</span>`)}
106
108
  <span>0</span>
107
109
  </div>
108
110
  </div>
109
111
  `;
110
- })
112
+ });
111
113
  }}
112
114
  </div>
113
115
  `;
@@ -14,59 +14,60 @@ type A = Attributes & {
14
14
  };
15
15
 
16
16
 
17
- const TAG_KEYS = ['checked', 'disabled', 'name', 'required'];
17
+ const OMIT_FIELD = ['state'];
18
+
19
+ const TAG = ['checked', 'disabled', 'name', 'required'];
18
20
 
19
21
 
20
22
  function mask(attributes: A, modifier: string, state: { active: boolean }) {
21
23
  return html`
22
24
  <div
23
- class='
24
- ${`field-mask--${modifier}`}
25
- field-mask
26
- '
27
- ${omit(attributes, TAG_KEYS)}
25
+ class='field-mask'
26
+ ${omit(attributes, TAG)}
27
+ ${{
28
+ class: `field-mask--${modifier}`
29
+ }}
28
30
  >
29
31
  <input
30
- ${attributes.checked || attributes.value || state.active && 'checked'}
31
32
  class='field-mask-tag field-mask-tag--hidden'
32
- type='${modifier === 'radio' ? 'radio' : 'checkbox'}'
33
- value='${attributes.value || 1}'
34
- ${pick(attributes, TAG_KEYS)}
33
+ ${{
34
+ checked: attributes.checked || attributes.value || state.active,
35
+ type: modifier === 'radio' ? 'radio' : 'checkbox',
36
+ value: attributes.value || 1
37
+ }}
38
+ ${pick(attributes, TAG) as Attributes}
35
39
  >
36
40
  </div>
37
41
  `;
38
42
  }
39
43
 
40
44
 
41
- const field = template.factory<
42
- Attributes & { state?: { active: boolean } },
43
- (mask: ((attributes: A) => Renderable)) => Renderable
44
- >(
45
+ const field = template.factory(
45
46
  function(
46
- this: ((attributes: A, state: { active: boolean }) => Renderable),
47
- attributes,
48
- content
47
+ this: ((attributes: A, state: { active: boolean }) => Renderable<unknown>),
48
+ attributes: Attributes & { state?: { active: boolean } },
49
+ content: (mask: ((attributes: A) => Renderable<unknown>)) => Renderable<unknown>
49
50
  ) {
50
- let state = attributes.state || reactive({
51
+ let state = attributes?.state || reactive({
51
52
  active: false
52
53
  });
53
54
 
54
55
  return html`
55
56
  <label
56
- class='
57
- ${() => state.active && '--active'}
58
- field
59
- '
60
- onchange='${(e: Event) => {
61
- if ((e.target as HTMLInputElement).type !== 'checkbox') {
62
- return;
63
- }
57
+ class='field'
58
+ ${omit(attributes, OMIT_FIELD)}
59
+ ${{
60
+ class: () => state.active && '--active',
61
+ onchange: (e) => {
62
+ if ((e.target as HTMLInputElement).type !== 'checkbox') {
63
+ return;
64
+ }
64
65
 
65
- state.active = (e.target as HTMLInputElement)?.checked;
66
- }}'
67
- ${omit(attributes, ['state'])}
66
+ state.active = (e.target as HTMLInputElement)?.checked;
67
+ }
68
+ }}
68
69
  >
69
- ${content((attributes: A) => this(attributes, state))}
70
+ ${content((attributes) => this(attributes, state))}
70
71
  </label>
71
72
  `
72
73
  }
@@ -1,8 +1,8 @@
1
- import { html, type Attributes } from '@esportsplus/template';
1
+ import { html } from '@esportsplus/template';
2
2
  import template from '~/components/template';
3
3
 
4
4
 
5
- export default template.factory<Attributes>(
5
+ export default template.factory(
6
6
  (attributes, content) => html`
7
7
  <div class='field-description' ${attributes}>
8
8
  ${content}
@@ -1,7 +1,7 @@
1
- import { html } from '@esportsplus/template';
1
+ import { html, Renderable } from '@esportsplus/template';
2
2
 
3
3
 
4
- export default (state: { error: unknown }) => {
4
+ export default (state: { error: Renderable<unknown> }) => {
5
5
  return () => {
6
6
  if (!state.error) {
7
7
  return '';
@@ -1,10 +1,15 @@
1
1
  import checkbox from './checkbox';
2
2
  import description from './description';
3
- import select from './select';
4
3
  import input from './input';
4
+ import select from './select';
5
5
  import title from './title';
6
6
  import './scss/index.scss';
7
7
 
8
8
 
9
- // export default { checkbox, description, file, select, switch: s, textarea, text, title };
10
- // export { checkbox, description, file, select, s as switch, textarea, text, title };
9
+ const { checkbox: cb, radio, switch: sw } = checkbox;
10
+
11
+ const { file, text, textarea } = input;
12
+
13
+
14
+ export default { checkbox: cb, description, file, radio, select, switch: sw, textarea, text, title };
15
+ export { cb as checkbox, description, file, radio, select, sw as switch, textarea, text, title };
@@ -6,9 +6,11 @@ import template from '~/components/template';
6
6
  import error from './error';
7
7
 
8
8
 
9
- const FILE_TAG_KEYS = ['accept', 'disabled', 'name', 'required', 'value'];
9
+ const FILE_TAG = ['accept', 'disabled', 'name', 'required', 'value'];
10
10
 
11
- const TEXT_TAG_KEYS = [
11
+ const OMIT = ['state'];
12
+
13
+ const TEXT_TAG = [
12
14
  'autocapitalize',
13
15
  'autocomplete',
14
16
  'autocorrect',
@@ -27,14 +29,11 @@ const TEXT_TAG_KEYS = [
27
29
  ];
28
30
 
29
31
 
30
- const field = template.factory<
31
- Attributes & { state?: { active: boolean, error: string } },
32
- (mask: typeof file | typeof text | typeof textarea) => Renderable
33
- >(
32
+ const field = template.factory(
34
33
  function(
35
34
  this: typeof text | typeof textarea,
36
- attributes,
37
- content
35
+ attributes: Attributes & { state?: { active: boolean, error: string } },
36
+ content: (mask: typeof file | typeof text | typeof textarea) => Renderable<unknown>
38
37
  ) {
39
38
  let state = attributes.state || reactive({
40
39
  active: false,
@@ -43,17 +42,17 @@ const field = template.factory<
43
42
 
44
43
  return html`
45
44
  <div
46
- class='
47
- ${() => state.active && '--active'}
48
- field
49
- '
50
- onfocusin='${() => {
51
- state.active = true;
52
- }}'
53
- onfocusout='${() => {
54
- state.active = false;
55
- }}'
56
- ${omit(attributes, ['state'])}
45
+ class='field'
46
+ ${omit(attributes, OMIT)}
47
+ ${{
48
+ class: () => state.active && '--active',
49
+ onfocusin: () => {
50
+ state.active = true;
51
+ },
52
+ onfocusout: () => {
53
+ state.active = false;
54
+ }
55
+ }}
57
56
  >
58
57
  ${content(
59
58
  ((...args: any[]) => (this.call as any)(state, ...args))
@@ -64,18 +63,20 @@ const field = template.factory<
64
63
  }
65
64
  );
66
65
 
67
- const file = template.factory<Attributes>(
66
+ const file = template.factory(
68
67
  function(this: { active: boolean, error: string }, attributes, content) {
69
68
  return html`
70
69
  <label
71
70
  class='field-mask field-mask--file'
72
- ${omit(attributes, FILE_TAG_KEYS)}
71
+ ${omit(attributes, FILE_TAG)}
73
72
  >
74
73
  <input
75
74
  class='field-mask-tag field-mask-tag--hidden'
76
- onrender='${form.input.onrender(this)}'
77
75
  type='file'
78
- ${pick(attributes, FILE_TAG_KEYS)}
76
+ ${pick(attributes, FILE_TAG) as Attributes}
77
+ ${{
78
+ onrender: form.input.onrender(this)
79
+ }}
79
80
  >
80
81
 
81
82
  ${content}
@@ -84,15 +85,17 @@ const file = template.factory<Attributes>(
84
85
  }
85
86
  );
86
87
 
87
- const text = template.factory<Attributes>(
88
+ const text = template.factory(
88
89
  function(this: { active: boolean, error: string }, attributes, content) {
89
90
  return html`
90
- <label class='field-mask field-mask--input' ${omit(attributes, TEXT_TAG_KEYS)}>
91
+ <label class='field-mask field-mask--input' ${omit(attributes, TEXT_TAG)}>
91
92
  <input
92
93
  class='field-mask-tag'
93
- onrender='${form.input.onrender(this)}'
94
- type='${attributes.type || 'text'}'
95
- ${pick(attributes, TEXT_TAG_KEYS)}
94
+ ${pick(attributes, TEXT_TAG) as Attributes}
95
+ ${{
96
+ onrender: form.input.onrender(this),
97
+ type: attributes.type || 'text'
98
+ }}
96
99
  >
97
100
  ${content}
98
101
  </label>
@@ -100,14 +103,19 @@ const text = template.factory<Attributes>(
100
103
  }
101
104
  );
102
105
 
103
- const textarea = template.factory<Attributes>(
104
- function(this: { active: boolean, error: string }, attributes, content) {
106
+ const textarea = template.factory(
107
+ function(this: { active: boolean, error: string }, attributes: Attributes & { value?: string }, content) {
105
108
  return html`
106
- <label class='field-mask field-mask--textarea' ${omit(attributes, TEXT_TAG_KEYS)}>
109
+ <label
110
+ class='field-mask field-mask--textarea'
111
+ ${omit(attributes, TEXT_TAG)}
112
+ >
107
113
  <textarea
108
114
  class='field-mask-tag'
109
- onrender='${form.input.onrender(this)}'
110
- ${pick(attributes, TEXT_TAG_KEYS)}
115
+ ${pick(attributes, TEXT_TAG) as Attributes}
116
+ ${{
117
+ onrender: form.input.onrender(this)
118
+ }}
111
119
  >
112
120
  ${attributes.value}
113
121
  </textarea>
@@ -3,12 +3,12 @@ import { html, type Attributes, type Renderable } from '@esportsplus/template';
3
3
  import { isObject, omit, pick, toArray } from '@esportsplus/utilities';
4
4
  import form from '~/components/form';
5
5
  import root from '~/components/root';
6
- import scrollbar from '~/components/scrollbar';
6
+ import scrollbar, { Attributes as A } from '~/components/scrollbar';
7
7
  import template from '~/components/template';
8
8
  import error from './error';
9
9
 
10
10
 
11
- const TAG_KEYS = [
11
+ const PICK_TAG = [
12
12
  'autocomplete',
13
13
  'autofocus',
14
14
  'disabled',
@@ -17,15 +17,23 @@ const TAG_KEYS = [
17
17
  'type'
18
18
  ];
19
19
 
20
+ const OMIT_FIELD = ['options', 'state'];
20
21
 
21
- const select = template.factory<
22
- Attributes & Parameters<typeof scrollbar>[0] & {
23
- text?: Attributes;
24
- 'tooltip-content'?: Attributes & { direction?: string };
25
- }
26
- >(
22
+ const OMIT_MASK = [
23
+ ...PICK_TAG,
24
+ 'field-mask-arrow',
25
+ 'field-mask-text',
26
+ 'scrollbar',
27
+ 'scrollbar-container-content',
28
+ 'tooltip-content',
29
+ ];
30
+
31
+ const OMIT_OPTION = ['content'];
32
+
33
+
34
+ const select = template.factory(
27
35
  function(
28
- this: {
36
+ this: {
29
37
  options: Record<number | string, Attributes & { content: unknown }>;
30
38
  option?: Attributes;
31
39
  state: {
@@ -35,7 +43,11 @@ const select = template.factory<
35
43
  selected: string | number;
36
44
  }
37
45
  },
38
- data,
46
+ attributes: Attributes & A & {
47
+ 'field-mask-arrow'?: Attributes;
48
+ 'field-mask-text'?: Attributes;
49
+ 'tooltip-content'?: Attributes & { direction?: string };
50
+ },
39
51
  content
40
52
  ) {
41
53
  let { option, options, state } = this;
@@ -43,82 +55,86 @@ const select = template.factory<
43
55
  return html`
44
56
  <label
45
57
  class='field-mask field-mask--select'
46
- onclick='${() => {
47
- state.active = !state.active;
48
- state.render = true;
49
-
50
- if (state.active) {
51
- root.onclick.push(() => state.active = false);
58
+ ${omit(attributes, OMIT_MASK)}
59
+ ${{
60
+ onclick: () => {
61
+ state.active = !state.active;
62
+ state.render = true;
63
+
64
+ if (state.active) {
65
+ root.onclick.push(() => state.active = false);
66
+ }
52
67
  }
53
- }}'
54
- ${omit(data, TAG_KEYS)}
68
+ }}
55
69
  >
56
- <input
57
- class='field-mask-tag field-mask-tag--hidden'
58
- name='${data.name}'
59
- onclick='${() => { /* Prevent double click events from firing */ }}'
60
- onrender='${form.input.onrender(state)}'
61
- value='${() => state.selected}'
62
- ${pick(data, TAG_KEYS)}
70
+ <input class='field-mask-tag field-mask-tag--hidden'
71
+ ${{
72
+ name: attributes.name,
73
+ onclick: () => { /* Prevent double click events from firing */ },
74
+ onrender: form.input.onrender(state),
75
+ value: () => state.selected
76
+ }}
77
+ ${pick(attributes, PICK_TAG) as Attributes}
63
78
  >
64
79
 
65
80
  ${content || html`
66
- <div class='field-mask-text' ${data.text}>
67
- ${() => options[ state.selected ] || '-'}
81
+ <div class='field-mask-text' ${attributes['field-mask-text']}>
82
+ ${() => (options[ state.selected ] || '-') as any}
68
83
  </div>
69
84
  `}
70
85
 
71
- <div class='field-mask-arrow'></div>
86
+ <div class='field-mask-arrow' ${attributes['field-mask-arrow']}></div>
72
87
 
73
88
  ${() => {
74
89
  if (!state.render) {
75
90
  return;
76
91
  }
77
92
 
78
- let attributes = {
79
- ...data['tooltip-content'],
80
- scrollbar: { ...data['scrollbar'] },
81
- 'scrollbar-container-content': { ...data['scrollbar-container-content'] }
82
- },
83
- keys = Object.keys(options),
93
+ let keys = Object.keys(options),
84
94
  selected = reactive(
85
95
  Object.fromEntries( keys.map(key => [key, false]) )
86
96
  );
87
97
 
88
- attributes.class = toArray(attributes.class);
89
- attributes.class.push(`tooltip-content tooltip-content--${attributes.direction || 's'} --flex-column --width-full`);
90
-
91
- attributes.onclick = (e: Event) => {
92
- let key = (e?.target as HTMLElement)?.dataset?.key;
93
-
94
- if (key === undefined) {
95
- return;
96
- }
97
-
98
- let previous = state.selected;
99
-
100
- state.selected = key;
101
- state.active = false;
102
-
103
- selected[key] = true;
104
- selected[previous] = false;
105
- };
106
-
107
- return scrollbar(attributes, keys.map((key) => html`
108
- <div
109
- class='
110
- ${() => selected[key] && '--active'}
111
- link
112
- '
113
- data-key='${key}'
114
- ${omit(options[key], ['content'])}
115
- ${option}
116
- >
117
- <span class='--text-truncate'>
118
- ${options[key]}
119
- </span>
120
- </div>
121
- `));
98
+ return scrollbar(
99
+ {
100
+ ...attributes['tooltip-content'],
101
+ class: [
102
+ ...toArray(attributes['tooltip-content']?.class),
103
+ `tooltip-content tooltip-content--${attributes['tooltip-content']?.direction || 's'} --flex-column --width-full`
104
+ ],
105
+ onclick: (e: Event) => {
106
+ let key = (e?.target as HTMLElement)?.dataset?.key;
107
+
108
+ if (key === undefined) {
109
+ return;
110
+ }
111
+
112
+ let previous = state.selected;
113
+
114
+ state.selected = key;
115
+ state.active = false;
116
+
117
+ selected[key] = true;
118
+ selected[previous] = false;
119
+ },
120
+ scrollbar: attributes['scrollbar'],
121
+ 'scrollbar-container-content': attributes['scrollbar-container-content']
122
+ },
123
+ keys.map((key) => html`
124
+ <div class='link'
125
+ ${omit(options[key], OMIT_OPTION)}
126
+ ${option}
127
+ ${{
128
+ class: () => selected[key] && '--active',
129
+ 'data-key': key
130
+ }}
131
+ >
132
+ <span class='--text-truncate'>
133
+ ${options[key]}
134
+ </span>
135
+ </div>
136
+ `)
137
+ );
122
138
  }}
123
139
  </label>
124
140
  `;
@@ -126,9 +142,12 @@ const select = template.factory<
126
142
  );
127
143
 
128
144
 
145
+
146
+
147
+
129
148
  export default template.factory<
130
149
  Attributes & {
131
- options: Record<number | string, number | string | Attributes & { content: unknown }>;
150
+ options: Record<number | string, (number | string | Attributes & { content: unknown })>;
132
151
  option?: Attributes;
133
152
  } & (
134
153
  {
@@ -143,45 +162,41 @@ export default template.factory<
143
162
  }
144
163
  }
145
164
  ),
146
- (mask: typeof select) => Renderable
147
- >(
148
- (data, content) => {
149
- let options = data.options,
150
- state = data.state || reactive({
151
- active: false,
152
- error: '',
153
- selected: data.selected || Object.keys(options)[0]
154
- });
155
-
156
- for (let key in options) {
157
- if (isObject(options[key])) {
158
- continue;
159
- }
160
-
161
- options[key] = { content: options[key] };
165
+ (mask: typeof select) => Renderable<unknown>
166
+ >((attributes, content) => {
167
+ let options = attributes.options,
168
+ state = attributes.state || reactive({
169
+ active: false,
170
+ error: '',
171
+ selected: attributes.selected || Object.keys(options)[0]
172
+ });
173
+
174
+ for (let key in options) {
175
+ if (isObject(options[key])) {
176
+ continue;
162
177
  }
163
178
 
164
- return html`
165
- <div
166
- class='
167
- ${() => state.active && '--active'}
168
- field
169
- tooltip
170
- '
171
- ${omit(data, ['options', 'state'])}
172
- >
173
- ${content(
174
- (...args: any[]) => (select.call as any)(
175
- {
176
- option: data.option,
177
- options: data.options,
178
- state
179
- },
180
- ...args
181
- )
182
- )}
183
- ${error(state)}
184
- </div>
185
- `;
179
+ options[key] = { content: options[key] };
186
180
  }
187
- );
181
+
182
+ return html`
183
+ <div class='field tooltip'
184
+ ${omit(attributes as any, OMIT_FIELD)}
185
+ ${{
186
+ class: () => state.active && '--active'
187
+ }}
188
+ >
189
+ ${content(
190
+ (...args: any[]) => (select.call as any)(
191
+ {
192
+ option: attributes.option,
193
+ options: attributes.options,
194
+ state
195
+ },
196
+ ...args
197
+ )
198
+ )}
199
+ ${error(state)}
200
+ </div>
201
+ `;
202
+ });