@skewedaspect/sleekspace-ui 0.9.0 → 0.10.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.
- package/dist/components/Accordion/context.d.ts +4 -0
- package/dist/components/Autocomplete/SkAutocomplete.vue.d.ts +87 -0
- package/dist/components/Autocomplete/SkAutocompleteEmpty.vue.d.ts +17 -0
- package/dist/components/Autocomplete/SkAutocompleteGroup.vue.d.ts +17 -0
- package/dist/components/Autocomplete/SkAutocompleteGroupLabel.vue.d.ts +17 -0
- package/dist/components/Autocomplete/SkAutocompleteItem.vue.d.ts +39 -0
- package/dist/components/Autocomplete/SkAutocompleteSeparator.vue.d.ts +2 -0
- package/dist/components/Autocomplete/index.d.ts +7 -0
- package/dist/components/Autocomplete/types.d.ts +3 -0
- package/dist/components/Breadcrumbs/context.d.ts +4 -0
- package/dist/components/Button/SkButton.vue.d.ts +8 -1
- package/dist/components/Button/types.d.ts +2 -0
- package/dist/components/Card/SkCard.vue.d.ts +1 -1
- package/dist/components/ContextMenu/context.d.ts +3 -0
- package/dist/components/Dropdown/SkDropdown.vue.d.ts +1 -1
- package/dist/components/Dropdown/context.d.ts +3 -0
- package/dist/components/Field/SkField.vue.d.ts +7 -6
- package/dist/components/Input/SkInput.vue.d.ts +9 -2
- package/dist/components/Input/types.d.ts +2 -0
- package/dist/components/InputGroup/SkInputGroup.vue.d.ts +23 -0
- package/dist/components/InputGroup/SkInputGroupAddon.vue.d.ts +33 -0
- package/dist/components/InputGroup/types.d.ts +13 -0
- package/dist/components/NumberInput/SkNumberInput.vue.d.ts +15 -1
- package/dist/components/NumberInput/types.d.ts +2 -0
- package/dist/components/Pagination/context.d.ts +5 -0
- package/dist/components/Panel/SkPanel.vue.d.ts +1 -1
- package/dist/components/Panel/types.d.ts +2 -1
- package/dist/components/Radio/context.d.ts +4 -0
- package/dist/components/Select/SkSelect.vue.d.ts +7 -1
- package/dist/components/Select/types.d.ts +2 -0
- package/dist/components/Sidebar/SkSidebar.vue.d.ts +1 -1
- package/dist/components/Tabs/context.d.ts +6 -0
- package/dist/components/Textarea/SkTextarea.vue.d.ts +1 -1
- package/dist/components/Tooltip/SkTooltip.vue.d.ts +1 -1
- package/dist/composables/injectionKeys.d.ts +9 -0
- package/dist/global.d.ts +4 -0
- package/dist/index.d.ts +18 -0
- package/dist/sleekspace-ui.css +836 -280
- package/dist/sleekspace-ui.es.js +3759 -2545
- package/dist/sleekspace-ui.umd.js +3765 -2543
- package/dist/static/components/alert.d.ts +2 -1
- package/dist/static/components/avatar.d.ts +2 -1
- package/dist/static/components/breadcrumbs.d.ts +2 -1
- package/dist/static/components/button.d.ts +4 -2
- package/dist/static/components/card.d.ts +2 -1
- package/dist/static/components/checkbox.d.ts +2 -1
- package/dist/static/components/colorPicker.d.ts +2 -1
- package/dist/static/components/divider.d.ts +2 -1
- package/dist/static/components/dropdown.d.ts +2 -1
- package/dist/static/components/field.d.ts +2 -1
- package/dist/static/components/group.d.ts +2 -1
- package/dist/static/components/input.d.ts +4 -2
- package/dist/static/components/inputGroup.d.ts +8 -0
- package/dist/static/components/inputGroupAddon.d.ts +7 -0
- package/dist/static/components/navBar.d.ts +2 -1
- package/dist/static/components/numberInput.d.ts +4 -2
- package/dist/static/components/page.d.ts +2 -1
- package/dist/static/components/pagination.d.ts +2 -1
- package/dist/static/components/panel.d.ts +2 -1
- package/dist/static/components/progress.d.ts +2 -1
- package/dist/static/components/radio.d.ts +2 -1
- package/dist/static/components/select.d.ts +4 -2
- package/dist/static/components/sidebar.d.ts +2 -1
- package/dist/static/components/skeleton.d.ts +2 -1
- package/dist/static/components/slider.d.ts +2 -1
- package/dist/static/components/spinner.d.ts +2 -1
- package/dist/static/components/switchInput.d.ts +2 -1
- package/dist/static/components/table.d.ts +2 -1
- package/dist/static/components/tag.d.ts +2 -1
- package/dist/static/components/tagsInput.d.ts +2 -1
- package/dist/static/components/textarea.d.ts +2 -1
- package/dist/static/components/toolbar.d.ts +2 -1
- package/dist/static/components/tooltip.d.ts +2 -1
- package/dist/static/h.d.ts +2 -0
- package/dist/static/index.cjs.js +1 -1
- package/dist/static/index.d.ts +6 -0
- package/dist/static/index.es.js +366 -216
- package/dist/static/render.d.ts +2 -1
- package/dist/static/stringH.d.ts +2 -0
- package/dist/static/types.d.ts +5 -0
- package/dist/tailwind.css +222 -0
- package/dist/tokens.css +0 -223
- package/dist/types/corners.d.ts +1 -0
- package/dist/utils/slots.d.ts +6 -0
- package/llms-full.txt +17 -9
- package/package.json +9 -3
- package/src/components/Accordion/SkAccordion.vue +5 -2
- package/src/components/Accordion/SkAccordionItem.vue +7 -4
- package/src/components/Accordion/context.ts +23 -0
- package/src/components/Alert/SkAlert.vue +4 -2
- package/src/components/Autocomplete/SkAutocomplete.test.ts +83 -0
- package/src/components/Autocomplete/SkAutocomplete.vue +305 -0
- package/src/components/Autocomplete/SkAutocompleteEmpty.vue +39 -0
- package/src/components/Autocomplete/SkAutocompleteGroup.vue +46 -0
- package/src/components/Autocomplete/SkAutocompleteGroupLabel.vue +39 -0
- package/src/components/Autocomplete/SkAutocompleteItem.vue +85 -0
- package/src/components/Autocomplete/SkAutocompleteSeparator.vue +39 -0
- package/src/components/Autocomplete/index.ts +13 -0
- package/src/components/Autocomplete/types.ts +10 -0
- package/src/components/Breadcrumbs/SkBreadcrumbItem.vue +8 -3
- package/src/components/Breadcrumbs/SkBreadcrumbSeparator.vue +8 -2
- package/src/components/Breadcrumbs/SkBreadcrumbs.vue +11 -14
- package/src/components/Breadcrumbs/context.ts +20 -0
- package/src/components/Button/SkButton.vue +54 -11
- package/src/components/Button/types.ts +6 -0
- package/src/components/Card/SkCard.vue +12 -5
- package/src/components/Checkbox/SkCheckbox.vue +9 -2
- package/src/components/ColorPicker/SkColorPicker.vue +27 -5
- package/src/components/ContextMenu/SkContextMenu.vue +4 -1
- package/src/components/ContextMenu/SkContextMenuSubmenu.vue +5 -2
- package/src/components/ContextMenu/context.ts +17 -0
- package/src/components/Dropdown/SkDropdown.vue +2 -1
- package/src/components/Dropdown/SkDropdownSubmenu.vue +4 -3
- package/src/components/Dropdown/context.ts +16 -0
- package/src/components/Field/SkField.test.ts +88 -0
- package/src/components/Field/SkField.vue +15 -7
- package/src/components/Input/SkInput.test.ts +61 -0
- package/src/components/Input/SkInput.vue +42 -7
- package/src/components/Input/types.ts +2 -0
- package/src/components/InputGroup/SkInputGroup.test.ts +171 -0
- package/src/components/InputGroup/SkInputGroup.vue +131 -0
- package/src/components/InputGroup/SkInputGroupAddon.test.ts +104 -0
- package/src/components/InputGroup/SkInputGroupAddon.vue +107 -0
- package/src/components/InputGroup/types.ts +27 -0
- package/src/components/Listbox/SkListbox.vue +27 -6
- package/src/components/Modal/SkModal.vue +11 -4
- package/src/components/NavBar/SkNavBar.vue +5 -4
- package/src/components/NumberInput/SkNumberInput.vue +49 -8
- package/src/components/NumberInput/types.ts +2 -0
- package/src/components/Page/SkPage.vue +18 -15
- package/src/components/Pagination/SkPagination.vue +6 -3
- package/src/components/Pagination/SkPaginationItem.vue +8 -5
- package/src/components/Pagination/context.ts +19 -0
- package/src/components/Panel/types.ts +3 -2
- package/src/components/Popover/SkPopover.vue +11 -4
- package/src/components/Radio/SkRadio.vue +14 -4
- package/src/components/Radio/SkRadioGroup.vue +4 -2
- package/src/components/Radio/context.ts +17 -0
- package/src/components/Select/SkSelect.vue +39 -7
- package/src/components/Select/types.ts +2 -0
- package/src/components/Switch/SkSwitch.vue +14 -13
- package/src/components/Tabs/SkTab.vue +10 -3
- package/src/components/Tabs/SkTabList.vue +4 -2
- package/src/components/Tabs/SkTabs.vue +5 -3
- package/src/components/Tabs/context.ts +19 -0
- package/src/components/TagsInput/SkTagsInput.vue +28 -7
- package/src/components/Textarea/SkTextarea.vue +27 -6
- package/src/components/TreeView/SkTreeItem.vue +10 -2
- package/src/composables/injectionKeys.ts +52 -0
- package/src/index.ts +28 -0
- package/src/static/__tests__/parity.test.ts +2 -1
- package/src/static/__tests__/parityHarness.ts +5 -2
- package/src/static/components/__tests__/helpers.test.ts +191 -99
- package/src/static/components/alert.ts +12 -11
- package/src/static/components/avatar.ts +15 -16
- package/src/static/components/breadcrumbs.ts +3 -2
- package/src/static/components/button.ts +23 -27
- package/src/static/components/card.ts +3 -2
- package/src/static/components/checkbox.ts +11 -14
- package/src/static/components/colorPicker.ts +7 -9
- package/src/static/components/divider.ts +4 -3
- package/src/static/components/dropdown.ts +15 -6
- package/src/static/components/field.ts +32 -15
- package/src/static/components/group.ts +3 -2
- package/src/static/components/input.ts +20 -15
- package/src/static/components/inputGroup.ts +30 -0
- package/src/static/components/inputGroupAddon.ts +29 -0
- package/src/static/components/navBar.ts +30 -17
- package/src/static/components/numberInput.ts +17 -17
- package/src/static/components/page.ts +3 -2
- package/src/static/components/pagination.ts +3 -2
- package/src/static/components/panel.ts +3 -2
- package/src/static/components/progress.ts +3 -2
- package/src/static/components/radio.ts +14 -20
- package/src/static/components/select.ts +18 -15
- package/src/static/components/sidebar.ts +9 -13
- package/src/static/components/skeleton.ts +7 -10
- package/src/static/components/slider.ts +7 -9
- package/src/static/components/spinner.ts +22 -22
- package/src/static/components/switchInput.ts +12 -14
- package/src/static/components/table.ts +8 -10
- package/src/static/components/tag.ts +17 -11
- package/src/static/components/tagsInput.ts +3 -3
- package/src/static/components/textarea.ts +8 -13
- package/src/static/components/toolbar.ts +7 -10
- package/src/static/components/tooltip.ts +3 -2
- package/src/static/generated/defaults.ts +25 -9
- package/src/static/generated/propTypes.ts +19 -2
- package/src/static/h.ts +16 -0
- package/src/static/index.ts +8 -0
- package/src/static/render.test.ts +14 -10
- package/src/static/render.ts +33 -18
- package/src/static/specs.test.ts +1 -0
- package/src/static/specs.ts +22 -2
- package/src/static/stringH.ts +104 -0
- package/src/static/types.ts +25 -0
- package/src/styles/components/_autocomplete.scss +498 -0
- package/src/styles/components/_button.scss +55 -6
- package/src/styles/components/_index.scss +2 -0
- package/src/styles/components/_input-group.scss +292 -0
- package/src/styles/components/_input.scss +57 -9
- package/src/styles/components/_number-input.scss +88 -14
- package/src/styles/components/_select.scss +56 -9
- package/src/styles/mixins/_cut-border.scss +83 -0
- package/src/styles/tailwind.scss +262 -0
- package/src/styles/tokens.scss +8 -255
- package/src/types/corners.ts +10 -0
- package/src/utils/slots.test.ts +89 -0
- package/src/utils/slots.ts +80 -0
- package/web-types.json +392 -12
package/src/static/render.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
//----------------------------------------------------------------------------------------------------------------------
|
|
2
2
|
// Render Core
|
|
3
3
|
//
|
|
4
|
-
// Generic renderer used by every component helper. Takes
|
|
5
|
-
//
|
|
4
|
+
// Generic renderer used by every component helper. Takes an `H` adapter (from the consumer's
|
|
5
|
+
// framework — Vue's h, React's createElement, or stringH for plain HTML-string output), a
|
|
6
|
+
// `RenderSpec` (element tag, class composition spec, optional extras), a props object, and the
|
|
7
|
+
// children to nest inside.
|
|
8
|
+
//
|
|
9
|
+
// The output type is whatever `h` returns — a Vue VNode, a React element, or an HTML string —
|
|
10
|
+
// so consumers compose static helpers naturally with their framework's templating.
|
|
6
11
|
//
|
|
7
12
|
// The output is the class-API form: <tag class="sk-component modifier-classes"> ... </tag>.
|
|
8
13
|
// Custom-element output is NOT emitted here — helpers always produce class-API HTML.
|
|
9
14
|
//----------------------------------------------------------------------------------------------------------------------
|
|
10
15
|
|
|
11
16
|
import { type ClassSpec, composeClasses } from './classes';
|
|
12
|
-
import {
|
|
17
|
+
import type { H } from './h';
|
|
13
18
|
|
|
14
19
|
//----------------------------------------------------------------------------------------------------------------------
|
|
15
20
|
|
|
@@ -26,51 +31,61 @@ export interface RenderSpec
|
|
|
26
31
|
|
|
27
32
|
//----------------------------------------------------------------------------------------------------------------------
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
function buildAttrs(spec : RenderSpec, props : Record<string, unknown>) : Record<string, unknown>
|
|
30
35
|
{
|
|
31
|
-
const
|
|
32
|
-
const attrs : string[] = [ `class="${ escapeAttr(classes) }"` ];
|
|
36
|
+
const attrs : Record<string, unknown> = { class: composeClasses(spec.classSpec, props) };
|
|
33
37
|
|
|
34
38
|
if(spec.tag === 'button')
|
|
35
39
|
{
|
|
36
|
-
attrs.
|
|
40
|
+
attrs.type = 'button';
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
if(spec.extraAttrs)
|
|
40
44
|
{
|
|
41
45
|
for(const [ name, value ] of Object.entries(spec.extraAttrs))
|
|
42
46
|
{
|
|
43
|
-
attrs
|
|
47
|
+
attrs[name] = value;
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
const styleParts : string[] = [];
|
|
48
51
|
if(spec.customColorVars)
|
|
49
52
|
{
|
|
53
|
+
const styleParts : string[] = [];
|
|
50
54
|
const { base, text: textVar } = spec.customColorVars;
|
|
51
55
|
if(base && typeof props.baseColor === 'string')
|
|
52
56
|
{
|
|
53
|
-
styleParts.push(`${ base }: ${
|
|
57
|
+
styleParts.push(`${ base }: ${ props.baseColor };`);
|
|
54
58
|
}
|
|
55
59
|
if(textVar && typeof props.textColor === 'string')
|
|
56
60
|
{
|
|
57
|
-
styleParts.push(`${ textVar }: ${
|
|
61
|
+
styleParts.push(`${ textVar }: ${ props.textColor };`);
|
|
62
|
+
}
|
|
63
|
+
if(styleParts.length > 0)
|
|
64
|
+
{
|
|
65
|
+
attrs.style = styleParts.join(' ');
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
68
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
return attrs;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
65
73
|
|
|
66
|
-
|
|
74
|
+
export function render<T>(
|
|
75
|
+
h : H<T>,
|
|
76
|
+
spec : RenderSpec,
|
|
77
|
+
props : Record<string, unknown>,
|
|
78
|
+
children ?: T | T[]
|
|
79
|
+
) : T
|
|
80
|
+
{
|
|
81
|
+
const attrs = buildAttrs(spec, props);
|
|
67
82
|
|
|
68
83
|
if(spec.void)
|
|
69
84
|
{
|
|
70
|
-
return
|
|
85
|
+
return h(spec.tag, attrs);
|
|
71
86
|
}
|
|
72
87
|
|
|
73
|
-
return
|
|
88
|
+
return h(spec.tag, attrs, children);
|
|
74
89
|
}
|
|
75
90
|
|
|
76
91
|
//----------------------------------------------------------------------------------------------------------------------
|
package/src/static/specs.test.ts
CHANGED
|
@@ -20,6 +20,7 @@ const componentsDir = join(here, '..', 'components');
|
|
|
20
20
|
// Components that are out-of-scope per the design spec (Vue-only, not pure-CSS-eligible)
|
|
21
21
|
const OUT_OF_SCOPE = new Set([
|
|
22
22
|
'Accordion',
|
|
23
|
+
'Autocomplete',
|
|
23
24
|
'Collapsible',
|
|
24
25
|
'ContextMenu',
|
|
25
26
|
'Listbox',
|
package/src/static/specs.ts
CHANGED
|
@@ -183,7 +183,7 @@ export const SPECS : Record<string, RenderSpec> = {
|
|
|
183
183
|
// Class-only form controls — class-API HTML on native elements
|
|
184
184
|
input: {
|
|
185
185
|
tag: 'input',
|
|
186
|
-
classSpec: { base: 'sk-input', kind: true, size: true },
|
|
186
|
+
classSpec: { base: 'sk-input', kind: true, size: true, listFlags: [ { prop: 'corners', family: 'cut' } ] },
|
|
187
187
|
void: true,
|
|
188
188
|
},
|
|
189
189
|
|
|
@@ -194,7 +194,7 @@ export const SPECS : Record<string, RenderSpec> = {
|
|
|
194
194
|
|
|
195
195
|
select: {
|
|
196
196
|
tag: 'select',
|
|
197
|
-
classSpec: { base: 'sk-select', kind: true, size: true },
|
|
197
|
+
classSpec: { base: 'sk-select', kind: true, size: true, listFlags: [ { prop: 'corners', family: 'cut' } ] },
|
|
198
198
|
},
|
|
199
199
|
|
|
200
200
|
slider: {
|
|
@@ -220,6 +220,26 @@ export const SPECS : Record<string, RenderSpec> = {
|
|
|
220
220
|
// respective component files. They compose multiple inner elements the generic renderer
|
|
221
221
|
// can't express.
|
|
222
222
|
|
|
223
|
+
inputGroup: {
|
|
224
|
+
tag: 'div',
|
|
225
|
+
classSpec: {
|
|
226
|
+
base: 'sk-input-group',
|
|
227
|
+
kind: true,
|
|
228
|
+
size: true,
|
|
229
|
+
listFlags: [ { prop: 'corners', family: 'cut' } ],
|
|
230
|
+
},
|
|
231
|
+
customColorVars: { base: '--sk-input-group-color-base', text: '--sk-input-group-fg' },
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
inputGroupAddon: {
|
|
235
|
+
tag: 'span',
|
|
236
|
+
classSpec: {
|
|
237
|
+
base: 'sk-input-group-addon',
|
|
238
|
+
kind: true,
|
|
239
|
+
size: true,
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
|
|
223
243
|
// Dropdown: disclosure via <details> + <summary>
|
|
224
244
|
dropdown: {
|
|
225
245
|
tag: 'details',
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
2
|
+
// String H Adapter — emits HTML strings.
|
|
3
|
+
//
|
|
4
|
+
// The H adapter for plain HTML-string output. Pass this as the first argument to any static
|
|
5
|
+
// helper to get an HTML string back instead of a framework VNode. Used by the parity tests
|
|
6
|
+
// and by any consumer that wants raw markup (custom SSGs, markdown plugins, etc.).
|
|
7
|
+
//
|
|
8
|
+
// Attribute serialisation rules:
|
|
9
|
+
// - undefined / null / false → omitted entirely
|
|
10
|
+
// - true → bare attribute name (e.g. `disabled`)
|
|
11
|
+
// - innerHTML → short-circuits children; value used as raw inner HTML
|
|
12
|
+
// - everything else → key="value" with HTML-escaped value
|
|
13
|
+
//
|
|
14
|
+
// Children handling:
|
|
15
|
+
// - Void elements (see VOID_ELEMENTS) with no children → self-closing `<tag ... />`
|
|
16
|
+
// - All other elements → always emit a closing tag, even with no children
|
|
17
|
+
// - String → child verbatim (caller-supplied HTML; escape upstream)
|
|
18
|
+
// - Array → joined with no separator
|
|
19
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
import { escapeAttr } from './escape';
|
|
22
|
+
import type { H } from './h';
|
|
23
|
+
|
|
24
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
// Standard HTML void elements — self-close only these. Everything else gets a closing tag.
|
|
27
|
+
// Includes historical keygen and param for defensive coverage.
|
|
28
|
+
// `progress` is not a spec void element but is treated as void by this library (RenderSpec.void=true)
|
|
29
|
+
// and the component tests assert self-closing output, so it lives here.
|
|
30
|
+
const VOID_ELEMENTS = new Set([
|
|
31
|
+
'area',
|
|
32
|
+
'base',
|
|
33
|
+
'br',
|
|
34
|
+
'col',
|
|
35
|
+
'embed',
|
|
36
|
+
'hr',
|
|
37
|
+
'img',
|
|
38
|
+
'input',
|
|
39
|
+
'keygen',
|
|
40
|
+
'link',
|
|
41
|
+
'meta',
|
|
42
|
+
'param',
|
|
43
|
+
'progress',
|
|
44
|
+
'source',
|
|
45
|
+
'track',
|
|
46
|
+
'wbr',
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
50
|
+
|
|
51
|
+
function attrToString(name : string, value : unknown) : string | null
|
|
52
|
+
{
|
|
53
|
+
if(value === undefined || value === null || value === false) { return null; }
|
|
54
|
+
if(value === true) { return name; }
|
|
55
|
+
return `${ name }="${ escapeAttr(String(value)) }"`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function serialiseAttrs(attrs : Record<string, unknown> | null) : string
|
|
59
|
+
{
|
|
60
|
+
if(!attrs) { return ''; }
|
|
61
|
+
|
|
62
|
+
const parts : string[] = [];
|
|
63
|
+
for(const [ name, value ] of Object.entries(attrs))
|
|
64
|
+
{
|
|
65
|
+
const part = attrToString(name, value);
|
|
66
|
+
if(part !== null) { parts.push(part); }
|
|
67
|
+
}
|
|
68
|
+
return parts.length > 0 ? ` ${ parts.join(' ') }` : '';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
export const stringH : H<string> = (tag, attrs, children) =>
|
|
74
|
+
{
|
|
75
|
+
// innerHTML in attrs short-circuits children — emit the tag with the inner HTML as content,
|
|
76
|
+
// stripping innerHTML from the serialised attributes.
|
|
77
|
+
if(attrs && typeof attrs.innerHTML === 'string')
|
|
78
|
+
{
|
|
79
|
+
const innerHtml = attrs.innerHTML;
|
|
80
|
+
const otherAttrs = { ...attrs };
|
|
81
|
+
delete otherAttrs.innerHTML;
|
|
82
|
+
const attrString = serialiseAttrs(otherAttrs);
|
|
83
|
+
return `<${ tag }${ attrString }>${ innerHtml }</${ tag }>`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const attrString = serialiseAttrs(attrs);
|
|
87
|
+
|
|
88
|
+
// Void elements with no children self-close. Non-void elements always get a closing tag.
|
|
89
|
+
const isEmpty = children === undefined
|
|
90
|
+
|| children === ''
|
|
91
|
+
|| (Array.isArray(children) && children.length === 0);
|
|
92
|
+
|
|
93
|
+
if(VOID_ELEMENTS.has(tag) && isEmpty)
|
|
94
|
+
{
|
|
95
|
+
return `<${ tag }${ attrString } />`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const childString = children === undefined
|
|
99
|
+
? ''
|
|
100
|
+
: Array.isArray(children) ? children.join('') : children;
|
|
101
|
+
return `<${ tag }${ attrString }>${ childString }</${ tag }>`;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
//----------------------------------------------------------------------------------------------------------------------
|
package/src/static/types.ts
CHANGED
|
@@ -71,6 +71,7 @@ export type ButtonKind = ComponentKind;
|
|
|
71
71
|
export type ButtonSize = ComponentSize;
|
|
72
72
|
export type ButtonVariant = ComponentVariant;
|
|
73
73
|
export type ButtonType = 'button' | 'submit' | 'reset';
|
|
74
|
+
export type ButtonCorner = 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
|
|
74
75
|
|
|
75
76
|
//----------------------------------------------------------------------------------------------------------------------
|
|
76
77
|
// Card
|
|
@@ -115,6 +116,30 @@ export type PagePanelMode = 'auto' | 'persistent' | 'drawer';
|
|
|
115
116
|
|
|
116
117
|
export type PaginationKind = ComponentKind;
|
|
117
118
|
|
|
119
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
120
|
+
// Input
|
|
121
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
export type InputCorner = 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
|
|
124
|
+
|
|
125
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
126
|
+
// InputGroup
|
|
127
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
128
|
+
|
|
129
|
+
export type InputGroupCorner = 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
|
|
130
|
+
|
|
131
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
132
|
+
// NumberInput
|
|
133
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
134
|
+
|
|
135
|
+
export type NumberInputCorner = 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
|
|
136
|
+
|
|
137
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
138
|
+
// Select
|
|
139
|
+
//----------------------------------------------------------------------------------------------------------------------
|
|
140
|
+
|
|
141
|
+
export type SelectCorner = 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
|
|
142
|
+
|
|
118
143
|
//----------------------------------------------------------------------------------------------------------------------
|
|
119
144
|
// Panel
|
|
120
145
|
//----------------------------------------------------------------------------------------------------------------------
|