@esportsplus/ui 0.0.119 → 0.0.120

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 (256) hide show
  1. package/.editorconfig +9 -0
  2. package/.gitattributes +2 -0
  3. package/assets/0af89c10df9bc2f8d646.woff2 +0 -0
  4. package/assets/109e3207d9afea8524be.woff2 +0 -0
  5. package/assets/16663c3f6ab1da2d6c86.woff +0 -0
  6. package/assets/16e8721ef5837bc6375e.woff +0 -0
  7. package/assets/2a3e005f58bfca9c117e.woff +0 -0
  8. package/assets/58a8d7ebc386843b62c5.woff2 +0 -0
  9. package/assets/593de7c561e5ffe80c3e.woff2 +0 -0
  10. package/assets/68b7982c2b30b51bf932.woff2 +0 -0
  11. package/assets/a04b5e24af93da353f0e.woff +0 -0
  12. package/assets/bf331673b91821715c08.woff +0 -0
  13. package/assets/c54b0f4340f2914802d1.woff +0 -0
  14. package/assets/dd8646a41e4397b77fc4.woff2 +0 -0
  15. package/assets/e06c107cc50506570954.woff2 +0 -0
  16. package/assets/ecdfe4c05425592708aa.woff2 +0 -0
  17. package/assets/f0032576ac7462ccbd0c.woff +0 -0
  18. package/assets/f872e621917a45943fbc.woff +0 -0
  19. package/build/assets/0af89c10df9bc2f8d646.woff2 +0 -0
  20. package/build/assets/109e3207d9afea8524be.woff2 +0 -0
  21. package/build/assets/16663c3f6ab1da2d6c86.woff +0 -0
  22. package/build/assets/16e8721ef5837bc6375e.woff +0 -0
  23. package/build/assets/2a3e005f58bfca9c117e.woff +0 -0
  24. package/build/assets/58a8d7ebc386843b62c5.woff2 +0 -0
  25. package/build/assets/593de7c561e5ffe80c3e.woff2 +0 -0
  26. package/build/assets/68b7982c2b30b51bf932.woff2 +0 -0
  27. package/build/assets/a04b5e24af93da353f0e.woff +0 -0
  28. package/build/assets/bf331673b91821715c08.woff +0 -0
  29. package/build/assets/c54b0f4340f2914802d1.woff +0 -0
  30. package/build/assets/dd8646a41e4397b77fc4.woff2 +0 -0
  31. package/build/assets/e06c107cc50506570954.woff2 +0 -0
  32. package/build/assets/ecdfe4c05425592708aa.woff2 +0 -0
  33. package/build/assets/f0032576ac7462ccbd0c.woff +0 -0
  34. package/build/assets/f872e621917a45943fbc.woff +0 -0
  35. package/build/css/components/styles.css +1 -0
  36. package/build/css/components/variables.css +1 -0
  37. package/build/css/fonts/montserrat.css +1 -0
  38. package/build/css/normalizer.css +1 -0
  39. package/build/css/utilities/styles.css +1 -0
  40. package/build/css/utilities/variables.css +1 -0
  41. package/components/alert/index.d.ts +10 -0
  42. package/components/alert/index.js +124 -0
  43. package/components/export/clipboard.d.ts +2 -0
  44. package/components/export/clipboard.js +10 -0
  45. package/components/export/index.d.ts +5 -0
  46. package/components/export/index.js +8 -0
  47. package/components/export/json.d.ts +2 -0
  48. package/components/export/json.js +10 -0
  49. package/components/field/checkbox.d.ts +17 -0
  50. package/components/field/checkbox.js +46 -0
  51. package/components/field/description.d.ts +4 -0
  52. package/components/field/description.js +11 -0
  53. package/components/field/error.d.ts +4 -0
  54. package/components/field/error.js +13 -0
  55. package/components/field/file.d.ts +18 -0
  56. package/components/field/file.js +50 -0
  57. package/components/field/index.d.ts +222 -0
  58. package/components/field/index.js +13 -0
  59. package/components/field/optional.d.ts +92 -0
  60. package/components/field/optional.js +21 -0
  61. package/components/field/select.d.ts +32 -0
  62. package/components/field/select.js +110 -0
  63. package/components/field/switch.d.ts +3 -0
  64. package/components/field/switch.js +11 -0
  65. package/components/field/text.d.ts +21 -0
  66. package/components/field/text.js +51 -0
  67. package/components/field/textarea.d.ts +3 -0
  68. package/components/field/textarea.js +10 -0
  69. package/components/field/title.d.ts +5 -0
  70. package/components/field/title.js +24 -0
  71. package/components/form/action.d.ts +5 -0
  72. package/components/form/action.js +51 -0
  73. package/components/form/index.d.ts +23 -0
  74. package/components/form/index.js +9 -0
  75. package/components/form/input.d.ts +9 -0
  76. package/components/form/input.js +12 -0
  77. package/components/form/layout.d.ts +12 -0
  78. package/components/form/layout.js +14 -0
  79. package/components/form/types.d.ts +12 -0
  80. package/components/form/types.js +2 -0
  81. package/components/number/index.d.ts +8 -0
  82. package/components/number/index.js +20 -0
  83. package/components/page/index.d.ts +22 -0
  84. package/components/page/index.js +16 -0
  85. package/components/root/index.d.ts +9 -0
  86. package/components/root/index.js +9 -0
  87. package/components/root/onclick.d.ts +5 -0
  88. package/components/root/onclick.js +16 -0
  89. package/components/scrollbar/index.d.ts +11 -0
  90. package/components/scrollbar/index.js +38 -0
  91. package/components/site/index.d.ts +9 -0
  92. package/components/site/index.js +20 -0
  93. package/components/tooltip/index.d.ts +58 -0
  94. package/components/tooltip/index.js +75 -0
  95. package/components/tooltip/menu.d.ts +25 -0
  96. package/components/tooltip/menu.js +46 -0
  97. package/css/components/styles.css +1 -0
  98. package/css/components/variables.css +1 -0
  99. package/css/fonts/montserrat.css +1 -0
  100. package/css/normalizer.css +1 -0
  101. package/css/utilities/styles.css +1 -0
  102. package/css/utilities/variables.css +1 -0
  103. package/package.json +1 -7
  104. package/src/components/accordion/scss/index.scss +16 -0
  105. package/src/components/accordion/scss/variables.scss +4 -0
  106. package/src/components/alert/index.ts +157 -0
  107. package/src/components/alert/scss/index.scss +55 -0
  108. package/src/components/alert/scss/variables.scss +8 -0
  109. package/src/components/anchor/scss/index.scss +41 -0
  110. package/src/components/anchor/scss/variables.scss +5 -0
  111. package/src/components/banner/scss/index.scss +40 -0
  112. package/src/components/banner/scss/variables.scss +6 -0
  113. package/src/components/border/scss/index.scss +10 -0
  114. package/src/components/border/scss/variables.scss +6 -0
  115. package/src/components/bubble/scss/index.scss +30 -0
  116. package/src/components/bubble/scss/variables.scss +19 -0
  117. package/src/components/button/scss/index.scss +92 -0
  118. package/src/components/button/scss/variables.scss +69 -0
  119. package/src/components/card/scss/index.scss +35 -0
  120. package/src/components/card/scss/variables.scss +42 -0
  121. package/src/components/container/scss/index.scss +10 -0
  122. package/src/components/container/scss/variables.scss +5 -0
  123. package/src/components/ellipsis/scss/index.scss +72 -0
  124. package/src/components/ellipsis/scss/variables.scss +3 -0
  125. package/src/components/export/clipboard.ts +12 -0
  126. package/src/components/export/index.ts +5 -0
  127. package/src/components/export/json.ts +15 -0
  128. package/src/components/field/checkbox.ts +61 -0
  129. package/src/components/field/description.ts +12 -0
  130. package/src/components/field/error.ts +14 -0
  131. package/src/components/field/file.ts +64 -0
  132. package/src/components/field/index.ts +10 -0
  133. package/src/components/field/optional.ts +27 -0
  134. package/src/components/field/scss/_check.scss +225 -0
  135. package/src/components/field/scss/_normalize.scss +36 -0
  136. package/src/components/field/scss/_text.scss +106 -0
  137. package/src/components/field/scss/index.scss +159 -0
  138. package/src/components/field/scss/variables.scss +138 -0
  139. package/src/components/field/select.ts +151 -0
  140. package/src/components/field/switch.ts +9 -0
  141. package/src/components/field/text.ts +68 -0
  142. package/src/components/field/textarea.ts +8 -0
  143. package/src/components/field/title.ts +23 -0
  144. package/src/components/form/action.ts +68 -0
  145. package/src/components/form/index.ts +6 -0
  146. package/src/components/form/input.ts +15 -0
  147. package/src/components/form/layout.ts +26 -0
  148. package/src/components/form/types.ts +16 -0
  149. package/src/components/group/scss/index.scss +36 -0
  150. package/src/components/group/scss/variables.scss +17 -0
  151. package/src/components/icon/scss/index.scss +17 -0
  152. package/src/components/icon/scss/variables.scss +7 -0
  153. package/src/components/link/scss/index.scss +28 -0
  154. package/src/components/link/scss/variables.scss +47 -0
  155. package/src/components/loading/scss/index.scss +24 -0
  156. package/src/components/loading/scss/variables.scss +31 -0
  157. package/src/components/modal/scss/index.scss +32 -0
  158. package/src/components/modal/scss/variables.scss +10 -0
  159. package/src/components/number/index.ts +24 -0
  160. package/src/components/page/index.ts +15 -0
  161. package/src/components/page/scss/index.scss +27 -0
  162. package/src/components/page/scss/variables.scss +27 -0
  163. package/src/components/processing/scss/index.scss +47 -0
  164. package/src/components/processing/scss/variables.scss +11 -0
  165. package/src/components/root/index.ts +5 -0
  166. package/src/components/root/onclick.ts +21 -0
  167. package/src/components/root/scss/index.scss +93 -0
  168. package/src/components/root/scss/variables.scss +55 -0
  169. package/src/components/row/scss/index.scss +7 -0
  170. package/src/components/scrollbar/index.ts +44 -0
  171. package/src/components/scrollbar/scss/index.scss +59 -0
  172. package/src/components/scrollbar/scss/variables.scss +6 -0
  173. package/src/components/sidebar/scss/index.scss +50 -0
  174. package/src/components/sidebar/scss/variables.scss +21 -0
  175. package/src/components/site/index.ts +27 -0
  176. package/src/components/site/scss/index.scss +3 -0
  177. package/src/components/text/scss/index.scss +12 -0
  178. package/src/components/text/scss/variables.scss +9 -0
  179. package/src/components/thumbnail/scss/index.scss +7 -0
  180. package/src/components/thumbnail/scss/variables.scss +7 -0
  181. package/src/components/tooltip/index.ts +94 -0
  182. package/src/components/tooltip/menu.ts +71 -0
  183. package/src/components/tooltip/scss/_center.scss +13 -0
  184. package/src/components/tooltip/scss/_east.scss +34 -0
  185. package/src/components/tooltip/scss/_north.scss +34 -0
  186. package/src/components/tooltip/scss/_south.scss +35 -0
  187. package/src/components/tooltip/scss/_west.scss +34 -0
  188. package/src/components/tooltip/scss/index.scss +93 -0
  189. package/src/components/tooltip/scss/variables.scss +25 -0
  190. package/src/css-utilities/[margin,padding]/scss/index.scss +41 -0
  191. package/src/css-utilities/[margin,padding]/scss/variables.scss +54 -0
  192. package/src/css-utilities/absolute/scss/index.scss +59 -0
  193. package/src/css-utilities/background/scss/variables.scss +27 -0
  194. package/src/css-utilities/border/scss/index.scss +21 -0
  195. package/src/css-utilities/border/scss/variables.scss +66 -0
  196. package/src/css-utilities/color/scss/variables.scss +31 -0
  197. package/src/css-utilities/disabled/scss/index.scss +4 -0
  198. package/src/css-utilities/flex/scss/index.scss +65 -0
  199. package/src/css-utilities/glass/scss/index.scss +3 -0
  200. package/src/css-utilities/glass/scss/variables.scss +3 -0
  201. package/src/css-utilities/hidden/scss/index.scss +28 -0
  202. package/src/css-utilities/index.scss +14 -0
  203. package/src/css-utilities/inline/scss/index.scss +7 -0
  204. package/src/css-utilities/line-height/scss/variables.scss +10 -0
  205. package/src/css-utilities/not-allowed/scss/index.scss +7 -0
  206. package/src/css-utilities/overflow/scss/index.scss +5 -0
  207. package/src/css-utilities/pointer/scss/index.scss +5 -0
  208. package/src/css-utilities/size/scss/variables.scss +12 -0
  209. package/src/css-utilities/slide/scss/index.scss +20 -0
  210. package/src/css-utilities/slide/scss/variables.scss +6 -0
  211. package/src/css-utilities/text/scss/index.scss +93 -0
  212. package/src/css-utilities/text/scss/variables.scss +31 -0
  213. package/src/css-utilities/transition/scss/variables.scss +14 -0
  214. package/src/css-utilities/viewport/scss/index.scss +5 -0
  215. package/src/css-utilities/width/scss/index.scss +3 -0
  216. package/src/css-utilities/width/scss/variables.scss +9 -0
  217. package/src/lib/index.scss +7 -0
  218. package/src/lib/scss/breakpoint.scss +41 -0
  219. package/src/lib/scss/color.scss +1 -0
  220. package/src/lib/scss/css-variables.scss +13 -0
  221. package/src/lib/scss/list.scss +76 -0
  222. package/src/lib/scss/map.scss +1 -0
  223. package/src/lib/scss/position.scss +77 -0
  224. package/src/lib/scss/string.scss +33 -0
  225. package/src/tokens/index.scss +11 -0
  226. package/src/tokens/scss/border-radius.scss +12 -0
  227. package/src/tokens/scss/border-width.scss +6 -0
  228. package/src/tokens/scss/box-shadow.scss +13 -0
  229. package/src/tokens/scss/color.scss +64 -0
  230. package/src/tokens/scss/font-size.scss +12 -0
  231. package/src/tokens/scss/font-weight.scss +6 -0
  232. package/src/tokens/scss/line-height.scss +6 -0
  233. package/src/tokens/scss/size.scss +13 -0
  234. package/src/tokens/scss/spacer.scss +8 -0
  235. package/src/tokens/scss/state.scss +86 -0
  236. package/src/tokens/scss/transition-duration.scss +5 -0
  237. package/storage/fonts/montserrat/Montserrat-Bold.woff +0 -0
  238. package/storage/fonts/montserrat/Montserrat-Bold.woff2 +0 -0
  239. package/storage/fonts/montserrat/Montserrat-BoldItalic.woff +0 -0
  240. package/storage/fonts/montserrat/Montserrat-BoldItalic.woff2 +0 -0
  241. package/storage/fonts/montserrat/Montserrat-Italic.woff +0 -0
  242. package/storage/fonts/montserrat/Montserrat-Italic.woff2 +0 -0
  243. package/storage/fonts/montserrat/Montserrat-Medium.woff +0 -0
  244. package/storage/fonts/montserrat/Montserrat-Medium.woff2 +0 -0
  245. package/storage/fonts/montserrat/Montserrat-MediumItalic.woff +0 -0
  246. package/storage/fonts/montserrat/Montserrat-MediumItalic.woff2 +0 -0
  247. package/storage/fonts/montserrat/Montserrat-Regular.woff +0 -0
  248. package/storage/fonts/montserrat/Montserrat-Regular.woff2 +0 -0
  249. package/storage/fonts/montserrat/Montserrat-SemiBold.woff +0 -0
  250. package/storage/fonts/montserrat/Montserrat-SemiBold.woff2 +0 -0
  251. package/storage/fonts/montserrat/Montserrat-SemiBoldItalic.woff +0 -0
  252. package/storage/fonts/montserrat/Montserrat-SemiBoldItalic.woff2 +0 -0
  253. package/storage/fonts/montserrat/index.css +79 -0
  254. package/storage/psd/Color Palette.psd +0 -0
  255. package/tsconfig.json +11 -0
  256. package/webpack.config.ts +28 -0
@@ -0,0 +1,151 @@
1
+ import { reactive } from '@esportsplus/reactivity';
2
+ import { html } from '@esportsplus/template';
3
+ import form from '~/components/form';
4
+ import scrollbar from '~/components/scrollbar';
5
+ import root from '~/components/root';
6
+ import description from './description';
7
+ import error from './error';
8
+ import title from './title';
9
+
10
+
11
+ type Data = {
12
+ class?: string;
13
+ effect?: (selected: number | string) => void;
14
+ mask?: {
15
+ class?: string;
16
+ content?: any;
17
+ style?: string;
18
+ };
19
+ name?: string;
20
+ options: Record<number | string, number | string>;
21
+ option?: {
22
+ class?: string;
23
+ style?: string;
24
+ };
25
+ selected?: any;
26
+ scrollbar?: {
27
+ style?: string;
28
+ };
29
+ style?: string;
30
+ text?: {
31
+ class?: string;
32
+ };
33
+ tooltip?: {
34
+ class?: string;
35
+ direction?: any;
36
+ style?: string;
37
+ };
38
+ } & Parameters<typeof description>[0] & Parameters<typeof title>[0];
39
+
40
+
41
+ function parse(keys: (number | string)[], selected: number | string) {
42
+ let options: Record<string, boolean> = {};
43
+
44
+ for (let key of keys) {
45
+ options[key] = false;
46
+ }
47
+
48
+ options[selected] = true;
49
+
50
+ return {
51
+ options,
52
+ selected: selected || keys[0]
53
+ };
54
+ }
55
+
56
+ function template(data: Data, state: { active: boolean, options: Record<number | string, boolean>, selected: number | string }) {
57
+ let { attributes: a, html: h } = scrollbar({
58
+ fixed: true,
59
+ style: data?.scrollbar?.style || '--background-default: var(--color-black-400);'
60
+ });
61
+
62
+ return html`
63
+ <div
64
+ class='tooltip-content tooltip-content--${data?.tooltip?.direction || 's'} ${data?.tooltip?.class || ''} --flex-column --width-full'
65
+ style='${data?.tooltip?.style || ''}'
66
+ >
67
+ <div
68
+ class='row --flex-column'
69
+ onclick='${(e: Event) => {
70
+ let key = (e?.target as HTMLElement)?.dataset?.key;
71
+
72
+ if (key === undefined) {
73
+ return;
74
+ }
75
+
76
+ // Swap active
77
+ state.options[key] = true;
78
+ state.options[state.selected] = false;
79
+
80
+ state.active = false;
81
+ state.selected = key;
82
+
83
+ if (data.effect) {
84
+ data.effect(key);
85
+ }
86
+ }}'
87
+ ${a}
88
+ >
89
+ ${Object.keys( data.options || {} ).map((key: number | string) => html`
90
+ <div
91
+ class='link ${data?.option?.class || ''} ${() => state.options[key] ? '--active' : ''} --flex-vertical' data-key='${key}'
92
+ style='${data?.option?.style || ''}'
93
+ >
94
+ <span class="--text-truncate">
95
+ ${data.options[key]}
96
+ </span>
97
+ </div>
98
+ `)}
99
+ </div>
100
+
101
+ ${h}
102
+ </div>
103
+ `;
104
+ }
105
+
106
+
107
+ export default (data: Data) => {
108
+ let state = reactive(Object.assign({
109
+ active: false,
110
+ error: '',
111
+ render: false,
112
+ }, parse(Object.keys( data.options || {} ), data.selected)));
113
+
114
+ return html`
115
+ <div class="field tooltip ${data?.class || ''} ${() => state.active ? '--active' : ''} --flex-column" style='${data?.style || ''}'>
116
+ ${title(data)}
117
+
118
+ <label
119
+ class="field-mask field-mask--select --flex-row ${data?.mask?.class || ''} ${(data?.title || (data?.class || '').indexOf('field--optional') !== -1) && '--margin-top'} --margin-300 --padding-400"
120
+ onclick='${() => {
121
+ state.render = true;
122
+ state.active = !state.active;
123
+
124
+ if (state.active) {
125
+ root.onclick.add(() => state.active = false);
126
+ }
127
+ }}'
128
+ style='${data?.mask?.style || ''}'
129
+ >
130
+ <input
131
+ class='field-tag field-tag--hidden'
132
+ name='${data.name}'
133
+ onclick='${() => { /* Prevent double click events from firing */ }}'
134
+ onrender='${form.input.attributes(state)}'
135
+ value='${() => state.selected}'
136
+ >
137
+
138
+ <div class="field-text ${data?.text?.class || ''}" style='pointer-events: none'>
139
+ ${() => data.options[ state.selected ] || '-'}
140
+ </div>
141
+
142
+ <div class='field-mask-arrow'></div>
143
+
144
+ ${() => state.render ? template(data, state) : ''}
145
+ </label>
146
+
147
+ ${description(data)}
148
+ ${error(state)}
149
+ </div>
150
+ `;
151
+ };
@@ -0,0 +1,9 @@
1
+ import checkbox from './checkbox';
2
+
3
+
4
+ export default (data: Parameters<typeof checkbox>[0]) => {
5
+ data.mask = data.mask || {};
6
+ data.mask.class = `field-mask--switch ${data.mask?.class || ''}`;
7
+
8
+ return checkbox(data);
9
+ };
@@ -0,0 +1,68 @@
1
+ import { reactive } from '@esportsplus/reactivity';
2
+ import { html } from '@esportsplus/template';
3
+ import form from '~/components/form';
4
+ import description from './description';
5
+ import error from './error';
6
+ import title from './title';
7
+
8
+
9
+ type Data = {
10
+ class?: string;
11
+ mask?: {
12
+ class?: string;
13
+ content?: any;
14
+ style?: string;
15
+ };
16
+ name?: string;
17
+ placeholder?: string;
18
+ style?: string;
19
+ tag?: {
20
+ class?: string;
21
+ };
22
+ textarea?: boolean;
23
+ type?: string;
24
+ value?: unknown;
25
+ } & Parameters<typeof description>[0] & Parameters<typeof title>[0];
26
+
27
+
28
+ export default (data: Data) => {
29
+ let state = reactive({
30
+ active: false,
31
+ error: ''
32
+ });
33
+
34
+ return html`
35
+ <div
36
+ class="field ${data?.class || ''} ${() => state.active ? '--active' : ''} --flex-column"
37
+ onfocusin='${() => {
38
+ state.active = true;
39
+ }}'
40
+ onfocusout='${() => {
41
+ state.active = false;
42
+ }}'
43
+ style='${data?.style || ''}'
44
+ >
45
+ ${title(data)}
46
+
47
+ <label
48
+ class='field-mask field-mask--input --flex-row ${data?.mask?.class || ''} ${(data?.title || (data?.class || '').indexOf('field--optional') !== -1) ? '--margin-top' : ''} --margin-300'
49
+ style='${data?.mask?.style || ''}'
50
+ >
51
+ <${data?.textarea ? 'textarea' : 'input'}
52
+ class='field-tag --padding-400 ${data?.tag?.class || ''}'
53
+ name='${data?.name || ''}'
54
+ placeholder='${data?.placeholder || ''}'
55
+ onrender='${form.input.attributes(state)}'
56
+ type='${data?.type || 'string'}'
57
+ ${!data?.textarea && data?.value !== undefined ? html`value='${data.value}'` : ''}
58
+ >
59
+ ${data?.textarea ? html`${data?.value || ''}</textarea>` : ''}
60
+
61
+ ${data?.mask?.content || ''}
62
+ </label>
63
+
64
+ ${description(data)}
65
+ ${error(state)}
66
+ </div>
67
+ `;
68
+ };
@@ -0,0 +1,8 @@
1
+ import text from './text';
2
+
3
+
4
+ export default (data: Parameters<typeof text>[0]) => {
5
+ data.textarea = true;
6
+
7
+ return text(data);
8
+ };
@@ -0,0 +1,23 @@
1
+ import { html } from '@esportsplus/template';
2
+ import tooltip from '~/components/tooltip';
3
+
4
+
5
+ export default (data: { required?: boolean, title?: string }) => {
6
+ if (!data?.title) {
7
+ return '';
8
+ }
9
+
10
+ let { attributes } = tooltip.onhover();
11
+
12
+ return html`
13
+ <div class="field-title --flex-horizontal-space-between --flex-vertical">
14
+ ${data.title}
15
+
16
+ ${data?.required && html`
17
+ <div class="bubble --background-primary --margin-left" ${attributes}>
18
+ <span class="tooltip-message tooltip-message--w">Required</span>
19
+ </div>
20
+ `}
21
+ </div>
22
+ `;
23
+ }
@@ -0,0 +1,68 @@
1
+ import { response } from '@esportsplus/action';
2
+ import { Action } from './types';
3
+ import alert from '~/components/alert';
4
+ import input from './input';
5
+
6
+
7
+ function parse(input: Record<string, any>) {
8
+ let data: Record<string, any> = {};
9
+
10
+ for (let path in input) {
11
+ let bucket = data,
12
+ keys = path.indexOf('.') !== -1 ? path.split('.') : [path];
13
+
14
+ for (let i = 0; i < keys.length - 1; i++) {
15
+ bucket = bucket[keys[i]] = bucket[keys[i]] || {};
16
+ }
17
+
18
+ bucket[ keys[keys.length - 1] ] = input[path];
19
+ }
20
+
21
+ return data;
22
+ };
23
+
24
+
25
+ export default function(action: Action) {
26
+ return {
27
+ onclick: function(this: HTMLFormElement, event: Event) {
28
+ let trigger = event.target as HTMLButtonElement;
29
+
30
+ if (trigger?.type !== 'submit') {
31
+ return;
32
+ }
33
+
34
+ // On initial page load both events will be dispatched without preventDefault
35
+ event.preventDefault();
36
+
37
+ this.dispatchEvent(
38
+ new SubmitEvent('submit', { cancelable: true, bubbles:true, submitter: trigger })
39
+ );
40
+ },
41
+ onsubmit: async function(this: HTMLFormElement, event: SubmitEvent) {
42
+ // TODO: Figure out processing
43
+ // - Could pass reactive value above and tie it to form layout handler
44
+ event.preventDefault();
45
+ event?.submitter?.classList.add('button--processing');
46
+
47
+ let { errors } = await action({
48
+ alert,
49
+ input: parse( Object.fromEntries( new FormData( this )?.entries() ) ),
50
+ response
51
+ });
52
+
53
+ for (let i = 0, n = errors.length; i < n; i++) {
54
+ let { message, path } = errors[i],
55
+ state = input.get( this[path] );
56
+
57
+ if (!state) {
58
+ continue;
59
+ }
60
+
61
+ state.error = `${message[0].toUpperCase()}${message.substring(1)}`;
62
+ }
63
+
64
+ // TODO: replace with signal
65
+ event?.submitter?.classList.remove('button--processing');
66
+ }
67
+ };
68
+ };
@@ -0,0 +1,6 @@
1
+ import action from './action';
2
+ import input from './input';
3
+ import layout from './layout';
4
+
5
+
6
+ export default { action, input, layout };
@@ -0,0 +1,15 @@
1
+ let cache = new WeakMap<HTMLInputElement | HTMLSelectElement, { error: string }>();
2
+
3
+
4
+ const attributes = (reactive: { error: string }) => {
5
+ return (element: HTMLInputElement | HTMLSelectElement) => {
6
+ cache.set(element, reactive);
7
+ };
8
+ };
9
+
10
+ const get = (element?: HTMLInputElement | HTMLSelectElement) => {
11
+ return element ? cache.get(element) : undefined;
12
+ };
13
+
14
+
15
+ export default { attributes, get };
@@ -0,0 +1,26 @@
1
+ import { html } from '@esportsplus/template';
2
+
3
+
4
+ type Data = {
5
+ action?: any;
6
+ button?: {
7
+ class?: string;
8
+ content?: any;
9
+ style?: string;
10
+ };
11
+ class?: string;
12
+ content?: any;
13
+ };
14
+
15
+
16
+ export default (data: Data) => html`
17
+ <form class='${data?.class}' ${data?.action || ''}>
18
+ ${data?.content || ''}
19
+
20
+ ${data?.button?.content ? html`
21
+ <button class="button ${data?.button?.class || ''}" style='${data?.button?.style || ''}'>
22
+ ${data?.button?.content || ''}
23
+ </button>
24
+ ` : ''}
25
+ </form>
26
+ `;
@@ -0,0 +1,16 @@
1
+ import { response, Response } from '@esportsplus/action';
2
+ import alert from '~/components/alert';
3
+
4
+
5
+ type Action = (data: Payload) => Promise<Errors> | Errors;
6
+
7
+ type Errors = { errors: Response<unknown>['errors'] };
8
+
9
+ type Payload = {
10
+ alert: typeof alert;
11
+ input: Record<string, any>;
12
+ response: typeof response;
13
+ };
14
+
15
+
16
+ export { Action, Errors, Payload };
@@ -0,0 +1,36 @@
1
+ .group {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ justify-content: flex-start;
5
+ margin: 0 calc(var(--margin-horizontal) / -2);
6
+ position: relative;
7
+ width: calc(100% + var(--margin-horizontal));
8
+
9
+
10
+ &--offset {
11
+ @each $direction in 'bottom' 'top' {
12
+ &-#{$direction} {
13
+ margin-#{$direction}: calc(var(--margin-vertical) * -1);
14
+ }
15
+ }
16
+ }
17
+
18
+ &--scroller {
19
+ flex-flow: row;
20
+ margin-bottom: calc(var(--scrollbar-width) * -1);
21
+ overflow-y: hidden;
22
+ padding-bottom: var(--scrollbar-width);
23
+ }
24
+
25
+
26
+ &-item {
27
+ display: flex;
28
+ margin: var(--margin-vertical) calc(var(--margin-horizontal) / 2) 0;
29
+ position: relative;
30
+ width: var(--width);
31
+
32
+ &[class*='--width'] {
33
+ width: calc(var(--width) - var(--margin-horizontal));
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,17 @@
1
+ .group {
2
+ --margin-horizontal: var(--size-400);
3
+ --width: auto;
4
+
5
+
6
+ &.--flex-column {
7
+ .group-item {
8
+ --width: 100%;
9
+ }
10
+ }
11
+
12
+ &--scroller {
13
+ .group-item {
14
+ --margin-vertical: 0px;
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,17 @@
1
+ .icon {
2
+ color: var(--color);
3
+ display: flex;
4
+ flex: 0 0 var(--width);
5
+ height: var(--height);
6
+ pointer-events: none;
7
+ position: relative;
8
+ width: var(--width);
9
+
10
+
11
+ svg {
12
+ color: currentColor;
13
+ fill: currentColor;
14
+ height: 100%;
15
+ width: 100%;
16
+ }
17
+ }
@@ -0,0 +1,7 @@
1
+ .icon {
2
+ --color: inherit;
3
+ --height: var(--size);
4
+ --margin-horizontal: var(--size-300);
5
+ --size: var(--size-400);
6
+ --width: var(--size);
7
+ }
@@ -0,0 +1,28 @@
1
+ @use '/tokens';
2
+
3
+ .link {
4
+ align-content: center;
5
+ background: var(--background);
6
+ color: var(--color);
7
+ cursor: pointer;
8
+ display: flex;
9
+ flex-wrap: wrap;
10
+ font-size: var(--font-size);
11
+ justify-content: flex-start;
12
+ line-height: var(--line-height);
13
+ padding: calc(var(--padding-vertical) - var(--border-width)) calc(var(--padding-horizontal) - var(--border-width));
14
+ position: relative;
15
+ transition:
16
+ background var(--transition-duration) ease-in-out,
17
+ border-color var(--transition-duration) ease-in-out,
18
+ color var(--transition-duration) ease-in-out,
19
+ opacity var(--transition-duration) ease-in-out;
20
+ width: var(--width);
21
+
22
+
23
+ &--underline {
24
+ @include tokens.state(active hover) {
25
+ text-decoration: underline;
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,47 @@
1
+ @use '/tokens';
2
+
3
+ .link {
4
+ --background: var(--background-default);
5
+ --background-active: var(--background-default);
6
+ --background-default: transparent;
7
+ --background-hover: var(--background-default);
8
+ --background-pressed: var(--background-default);
9
+ --border-color: var(--border-color-default);
10
+ --border-color-active: var(--border-color-default);
11
+ --border-color-default: var(--background);
12
+ --border-color-hover: var(--border-color-default);
13
+ --border-color-pressed: var(--border-color-default);
14
+ --border-radius: var(--border-radius-400);
15
+ --border-width: 0px;
16
+ --color: var(--color-default);
17
+ --color-active: var(--color-default);
18
+ --color-default: var(--color-text-400);
19
+ --color-hover: var(--color-default);
20
+ --color-pressed: var(--color-default);
21
+ --font-size: var(--font-size-400);
22
+ --font-weight: var(--font-weight-500);
23
+ --line-height: var(--line-height-400);
24
+ --padding-horizontal: var(--size-400);
25
+ --padding-vertical: var(--size-400);
26
+ --transition-duration: var(--transition-duration-400);
27
+ --width: auto;
28
+
29
+
30
+ @include tokens.state(active) {
31
+ --background: var(--background-active);
32
+ --border-color: var(--border-color-active);
33
+ --color: var(--color-active);
34
+ }
35
+
36
+ @include tokens.state(hover) {
37
+ --background: var(--background-hover);
38
+ --border-color: var(--border-color-hover);
39
+ --color: var(--color-hover);
40
+ }
41
+
42
+ @include tokens.state(pressed) {
43
+ --background: var(--background-pressed);
44
+ --border-color: var(--border-color-pressed);
45
+ --color: var(--color-pressed);
46
+ }
47
+ }
@@ -0,0 +1,24 @@
1
+ .loading {
2
+ animation: loading var(--animation-duration) infinite linear;
3
+ animation-delay: var(--animation-delay);
4
+ border: var(--border-width) var(--border-style) var(--border-color);
5
+ border-radius: 100%;
6
+ border-right-color: transparent;
7
+ border-top-color: transparent;
8
+ box-shadow: var(--box-shadow);
9
+ height: var(--height);
10
+ pointer-events: none;
11
+ position: relative;
12
+ transition: border-color var(--transition-duration) ease-in-out;
13
+ width: var(--width);
14
+ z-index: 0;
15
+ }
16
+
17
+ @keyframes loading {
18
+ 0% {
19
+ transform: rotate(0deg);
20
+ }
21
+ 100% {
22
+ transform: rotate(360deg);
23
+ }
24
+ }
@@ -0,0 +1,31 @@
1
+ .loading {
2
+ --animation-delay: calc(0s + (0.032s * var(--i)));
3
+ --animation-duration: calc(0.64s * (var(--i) + 1.5));
4
+ --border-color: inherit;
5
+ --border-style: solid;
6
+ --border-width: var(--border-width-400);
7
+ --box-shadow: none;
8
+ --height: calc(var(--size) * var(--multiplier));
9
+ --i: 0;
10
+ --multiplier: calc(1 - (.2 * var(--i)));
11
+ --size: var(--size-400);
12
+ --transition-duration: var(--transition-duration-400);
13
+ --width: calc(var(--size) * var(--multiplier));
14
+
15
+ .loading {
16
+ --i: 1;
17
+ --size: inherit;
18
+
19
+ .loading {
20
+ --i: 2;
21
+
22
+ .loading {
23
+ --i: 3;
24
+
25
+ .loading {
26
+ --i: 4;
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,32 @@
1
+ @use '/lib';
2
+ @use '/tokens';
3
+
4
+ .modal {
5
+ @include lib.position(fixed, center);
6
+ max-height: var(--max-height);
7
+ max-width: var(--max-width);
8
+ overflow: hidden;
9
+ transition: opacity var(--transition-duration) ease-in-out, transform var(--transition-duration) ease-in-out;
10
+ transform-origin: center;
11
+ width: var(--width);
12
+ z-index: 2;
13
+
14
+ @include tokens.state(inactive) {
15
+ opacity: 0;
16
+ pointer-events: none;
17
+ transform: translate(50%, 50%) scale(0.8);
18
+
19
+ input[type='password'] {
20
+ display: none;
21
+ }
22
+ }
23
+
24
+ &-frame {
25
+ transition: opacity var(--transition-duration) ease-in-out, transform var(--transition-duration) ease-in-out;
26
+ transform-origin: center;
27
+
28
+ @include tokens.state(inactive) {
29
+ display: none;
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,10 @@
1
+ .modal {
2
+ --max-height: calc(100svh - (var(--margin) * 2));
3
+ --max-width: 320px;
4
+ --width: calc(100svw - (var(--margin) * 2));
5
+
6
+ &,
7
+ &-frame {
8
+ --transition-duration: var(--transition-duration-300);
9
+ }
10
+ }
@@ -0,0 +1,24 @@
1
+ let formatter: null | Intl.NumberFormat = null,
2
+ suffixes = ['th', 'st', 'nd', 'rd'];
3
+
4
+
5
+ const abbreviate = (number: number) => {
6
+ if (formatter === null) {
7
+ formatter = new Intl.NumberFormat('en-GB', {
8
+ notation: 'compact',
9
+ compactDisplay: 'short'
10
+ });
11
+ }
12
+
13
+ return formatter.format(number);
14
+ };
15
+
16
+ const ordinal = (number: number) => {
17
+ let value = number % 100;
18
+
19
+ return suffixes[(value - 20) % 10] || suffixes[value] || suffixes[0];
20
+ };
21
+
22
+
23
+ export default { abbreviate, ordinal };
24
+ export { abbreviate, ordinal };