@inglorious/ui 0.1.0 → 1.0.1
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/README.md +45 -0
- package/package.json +190 -15
- package/src/all.css +7 -0
- package/src/controls/button/button.stories.js +35 -15
- package/src/controls/button/index.js +1 -3
- package/src/controls/button/style.css +80 -37
- package/src/controls/button/template.js +23 -26
- package/src/controls/button-group/button-group.stories.js +19 -15
- package/src/controls/button-group/index.js +1 -2
- package/src/controls/button-group/style.css +0 -7
- package/src/controls/button-group/template.js +46 -56
- package/src/controls/checkbox/checkbox.stories.js +16 -13
- package/src/controls/checkbox/index.js +1 -2
- package/src/controls/checkbox/style.css +23 -2
- package/src/controls/checkbox/template.js +20 -18
- package/src/controls/combobox/combobox.stories.js +92 -0
- package/src/controls/{select → combobox}/handlers.js +8 -5
- package/src/controls/combobox/helpers.js +91 -0
- package/src/controls/combobox/index.js +43 -0
- package/src/controls/combobox/style.css +203 -0
- package/src/controls/combobox/template.js +340 -0
- package/src/controls/controls.css +12 -0
- package/src/controls/fab/fab.stories.js +11 -11
- package/src/controls/fab/index.js +1 -2
- package/src/controls/fab/template.js +21 -19
- package/src/controls/icon-button/icon-button.stories.js +8 -10
- package/src/controls/icon-button/index.js +1 -2
- package/src/controls/icon-button/template.js +13 -19
- package/src/controls/input/index.js +1 -2
- package/src/controls/input/input.stories.js +24 -23
- package/src/controls/input/style.css +9 -7
- package/src/controls/input/template.js +28 -31
- package/src/controls/radio-group/index.js +1 -2
- package/src/controls/radio-group/radio-group.stories.js +11 -8
- package/src/controls/radio-group/style.css +22 -1
- package/src/controls/radio-group/template.js +20 -15
- package/src/controls/rating/index.js +1 -2
- package/src/controls/rating/rating.stories.js +7 -10
- package/src/controls/rating/style.css +1 -2
- package/src/controls/rating/template.js +20 -17
- package/src/controls/select/helpers.js +2 -21
- package/src/controls/select/index.js +1 -13
- package/src/controls/select/select.stories.js +68 -64
- package/src/controls/select/style.css +66 -189
- package/src/controls/select/template.js +77 -406
- package/src/controls/slider/index.js +1 -2
- package/src/controls/slider/slider.stories.js +15 -12
- package/src/controls/slider/style.css +24 -3
- package/src/controls/slider/template.js +30 -23
- package/src/controls/switch/index.js +1 -2
- package/src/controls/switch/style.css +23 -2
- package/src/controls/switch/switch.stories.js +14 -11
- package/src/controls/switch/template.js +18 -16
- package/src/data-display/avatar/avatar.stories.js +106 -0
- package/src/data-display/avatar/index.js +3 -0
- package/src/data-display/avatar/style.css +64 -0
- package/src/data-display/avatar/template.js +81 -0
- package/src/data-display/badge/badge.stories.js +64 -0
- package/src/data-display/badge/index.js +3 -0
- package/src/data-display/badge/style.css +84 -0
- package/src/data-display/badge/template.js +46 -0
- package/src/data-display/chip/chip.stories.js +57 -0
- package/src/data-display/chip/index.js +3 -0
- package/src/data-display/chip/style.css +84 -0
- package/src/data-display/chip/template.js +32 -0
- package/src/data-display/data-display.css +11 -0
- package/src/data-display/data-grid/base.css +58 -0
- package/src/data-display/data-grid/data-grid.stories.js +158 -0
- package/src/data-display/data-grid/filters/helpers.js +8 -0
- package/src/data-display/data-grid/filters/index.js +21 -0
- package/src/data-display/data-grid/filters/input.js +24 -0
- package/src/data-display/data-grid/filters/range.js +48 -0
- package/src/data-display/data-grid/filters/select.js +17 -0
- package/src/data-display/data-grid/handlers.js +523 -0
- package/src/data-display/data-grid/helpers.js +248 -0
- package/src/data-display/data-grid/index.js +64 -0
- package/src/data-display/data-grid/style.css +14 -0
- package/src/data-display/data-grid/template.js +458 -0
- package/src/data-display/data-grid/theme.css +148 -0
- package/src/data-display/divider/divider.stories.js +48 -0
- package/src/data-display/divider/index.js +3 -0
- package/src/data-display/divider/style.css +18 -0
- package/src/data-display/divider/template.js +17 -0
- package/src/data-display/icon/icon-implementations.mdx +160 -0
- package/src/data-display/icon/icon-utf8.stories.js +156 -0
- package/src/data-display/icon/icon.stories.js +38 -0
- package/src/data-display/icon/index.js +3 -0
- package/src/data-display/icon/style.css +17 -0
- package/src/data-display/icon/template.js +19 -0
- package/src/data-display/list/handlers.js +25 -0
- package/src/data-display/list/index.js +4 -0
- package/src/data-display/list/list.stories.js +187 -0
- package/src/data-display/list/style.css +119 -0
- package/src/data-display/list/template.js +302 -0
- package/src/data-display/material-icon/index.js +3 -0
- package/src/data-display/material-icon/material-icon.stories.js +99 -0
- package/src/data-display/material-icon/style.css +27 -0
- package/src/data-display/material-icon/template.js +21 -0
- package/src/data-display/table/index.js +1 -0
- package/src/data-display/table/style.css +42 -0
- package/src/data-display/table/table.stories.js +40 -0
- package/src/data-display/table/template.js +114 -0
- package/src/data-display/tooltip/index.js +3 -0
- package/src/data-display/tooltip/style.css +57 -0
- package/src/data-display/tooltip/template.js +58 -0
- package/src/data-display/tooltip/tooltip.stories.js +44 -0
- package/src/data-display/typography/index.js +3 -0
- package/src/data-display/typography/style.css +49 -0
- package/src/data-display/typography/template.js +110 -0
- package/src/data-display/typography/typography.stories.js +48 -0
- package/src/data-display/virtual-list/handlers.js +68 -0
- package/src/data-display/virtual-list/index.js +4 -0
- package/src/data-display/virtual-list/template.js +101 -0
- package/src/examples/dashboard/app-drawer.js +255 -0
- package/src/examples/dashboard/app-header.js +149 -0
- package/src/examples/dashboard/dashboard.js +85 -0
- package/src/examples/dashboard/dashboard.stories.js +47 -0
- package/src/examples/dashboard/data.js +205 -0
- package/src/examples/dashboard/mode.js +27 -0
- package/src/examples/dashboard/primitive-content.js +1325 -0
- package/src/examples/dashboard/primitive-section.js +158 -0
- package/src/examples/dashboard/router.js +13 -0
- package/src/examples/dashboard/social-card.js +73 -0
- package/src/examples/dashboard/stat-card.js +84 -0
- package/src/examples/dashboard/style.css +339 -0
- package/src/examples/dashboard/theme-utils.js +95 -0
- package/src/examples/dashboard/theme.js +27 -0
- package/src/examples/dashboard/traffic-card.js +108 -0
- package/src/examples/dashboard/traffic-sales-card.js +267 -0
- package/src/feedback/alert/alert.stories.js +70 -0
- package/src/feedback/alert/index.js +3 -0
- package/src/feedback/alert/style.css +98 -0
- package/src/feedback/alert/template.js +74 -0
- package/src/feedback/backdrop/backdrop.stories.js +21 -0
- package/src/feedback/backdrop/index.js +3 -0
- package/src/feedback/backdrop/style.css +25 -0
- package/src/feedback/backdrop/template.js +31 -0
- package/src/feedback/dialog/dialog.stories.js +27 -0
- package/src/feedback/dialog/index.js +3 -0
- package/src/feedback/dialog/style.css +68 -0
- package/src/feedback/dialog/template.js +64 -0
- package/src/feedback/feedback.css +6 -0
- package/src/feedback/progress/index.js +3 -0
- package/src/feedback/progress/progress.stories.js +54 -0
- package/src/feedback/progress/style.css +95 -0
- package/src/feedback/progress/template.js +88 -0
- package/src/feedback/skeleton/index.js +3 -0
- package/src/feedback/skeleton/skeleton.stories.js +44 -0
- package/src/feedback/skeleton/style.css +41 -0
- package/src/feedback/skeleton/template.js +48 -0
- package/src/feedback/snackbar/index.js +3 -0
- package/src/feedback/snackbar/snackbar.stories.js +25 -0
- package/src/feedback/snackbar/style.css +64 -0
- package/src/feedback/snackbar/template.js +55 -0
- package/src/index.js +32 -1
- package/src/layout/container/container.stories.js +105 -0
- package/src/layout/container/index.js +3 -0
- package/src/layout/container/style.css +34 -0
- package/src/layout/container/template.js +119 -0
- package/src/layout/flex/flex.stories.js +28 -10
- package/src/layout/flex/index.js +1 -2
- package/src/layout/flex/style.css +20 -0
- package/src/layout/flex/template.js +40 -13
- package/src/layout/grid/grid.stories.js +46 -30
- package/src/layout/grid/index.js +1 -2
- package/src/layout/grid/style.css +20 -0
- package/src/layout/grid/template.js +100 -20
- package/src/layout/layout.css +3 -0
- package/src/navigation/bottom-navigation/bottom-navigation.stories.js +33 -0
- package/src/navigation/bottom-navigation/index.js +1 -0
- package/src/navigation/bottom-navigation/style.css +32 -0
- package/src/navigation/bottom-navigation/template.js +74 -0
- package/src/navigation/breadcrumbs/breadcrumbs.stories.js +33 -0
- package/src/navigation/breadcrumbs/index.js +1 -0
- package/src/navigation/breadcrumbs/style.css +27 -0
- package/src/navigation/breadcrumbs/template.js +79 -0
- package/src/navigation/drawer/drawer.stories.js +60 -0
- package/src/navigation/drawer/index.js +3 -0
- package/src/navigation/drawer/style.css +125 -0
- package/src/navigation/drawer/template.js +131 -0
- package/src/navigation/link/index.js +3 -0
- package/src/navigation/link/link.stories.js +53 -0
- package/src/navigation/link/style.css +40 -0
- package/src/navigation/link/template.js +53 -0
- package/src/navigation/menu/index.js +1 -0
- package/src/navigation/menu/menu.stories.js +36 -0
- package/src/navigation/menu/style.css +44 -0
- package/src/navigation/menu/template.js +81 -0
- package/src/navigation/navigation.css +9 -0
- package/src/navigation/pagination/index.js +1 -0
- package/src/navigation/pagination/pagination.stories.js +61 -0
- package/src/navigation/pagination/style.css +29 -0
- package/src/navigation/pagination/template.js +140 -0
- package/src/navigation/speed-dial/index.js +1 -0
- package/src/navigation/speed-dial/speed-dial.stories.js +40 -0
- package/src/navigation/speed-dial/style.css +38 -0
- package/src/navigation/speed-dial/template.js +68 -0
- package/src/navigation/stepper/index.js +1 -0
- package/src/navigation/stepper/stepper.stories.js +35 -0
- package/src/navigation/stepper/style.css +49 -0
- package/src/navigation/stepper/template.js +61 -0
- package/src/navigation/tabs/index.js +1 -0
- package/src/navigation/tabs/style.css +35 -0
- package/src/navigation/tabs/tabs.stories.js +40 -0
- package/src/navigation/tabs/template.js +79 -0
- package/src/overview.mdx +39 -0
- package/src/stories/notifyStory.js +22 -25
- package/src/styles/base.css +2 -0
- package/src/styles/reset.css +15 -0
- package/src/{themes → styles/themes}/bootstrap.css +2 -0
- package/src/{themes → styles/themes}/inglorious.css +9 -1
- package/src/{themes → styles/themes}/material.css +2 -0
- package/src/{tokens/index.css → styles/tokens.css} +9 -0
- package/src/surfaces/accordion/accordion.stories.js +60 -0
- package/src/surfaces/accordion/index.js +1 -0
- package/src/surfaces/accordion/style.css +64 -0
- package/src/surfaces/accordion/template.js +85 -0
- package/src/surfaces/app-bar/app-bar.stories.js +109 -0
- package/src/surfaces/app-bar/index.js +3 -0
- package/src/surfaces/app-bar/style.css +109 -0
- package/src/surfaces/app-bar/template.js +78 -0
- package/src/surfaces/card/card.stories.js +108 -0
- package/src/surfaces/card/index.js +1 -0
- package/src/surfaces/card/style.css +107 -0
- package/src/surfaces/card/template.js +163 -0
- package/src/surfaces/paper/index.js +3 -0
- package/src/surfaces/paper/paper.stories.js +97 -0
- package/src/surfaces/paper/style.css +73 -0
- package/src/surfaces/paper/template.js +76 -0
- package/src/surfaces/surfaces.css +4 -0
- package/types/controls/button-group.d.ts +8 -7
- package/types/controls/button.d.ts +10 -7
- package/types/controls/checkbox.d.ts +8 -6
- package/types/controls/combobox.d.ts +66 -0
- package/types/controls/fab.d.ts +6 -5
- package/types/controls/icon-button.d.ts +8 -7
- package/types/controls/input.d.ts +18 -11
- package/types/controls/radio-group.d.ts +7 -5
- package/types/controls/rating.d.ts +6 -5
- package/types/controls/select.d.ts +11 -34
- package/types/controls/slider.d.ts +8 -6
- package/types/controls/switch.d.ts +7 -5
- package/types/data-display/avatar.d.ts +30 -0
- package/types/data-display/badge.d.ts +20 -0
- package/types/data-display/chip.d.ts +25 -0
- package/types/data-display/data-grid.d.ts +151 -0
- package/types/data-display/divider.d.ts +14 -0
- package/types/data-display/icon.d.ts +16 -0
- package/types/data-display/list.d.ts +66 -0
- package/types/data-display/material-icon.d.ts +15 -0
- package/types/data-display/table.d.ts +45 -0
- package/types/data-display/tooltip.d.ts +20 -0
- package/types/data-display/typography.d.ts +28 -0
- package/types/data-display/virtual-list.d.ts +94 -0
- package/types/feedback/alert.d.ts +22 -0
- package/types/feedback/backdrop.d.ts +17 -0
- package/types/feedback/dialog.d.ts +21 -0
- package/types/feedback/progress.d.ts +18 -0
- package/types/feedback/skeleton.d.ts +18 -0
- package/types/feedback/snackbar.d.ts +19 -0
- package/types/index.d.ts +92 -14
- package/types/layout/container.d.ts +28 -0
- package/types/layout/flex.d.ts +16 -5
- package/types/layout/grid.d.ts +15 -4
- package/types/navigation/bottom-navigation.d.ts +33 -0
- package/types/navigation/breadcrumbs.d.ts +29 -0
- package/types/navigation/drawer.d.ts +23 -0
- package/types/navigation/link.d.ts +22 -0
- package/types/navigation/menu.d.ts +32 -0
- package/types/navigation/pagination.d.ts +50 -0
- package/types/navigation/speed-dial.d.ts +35 -0
- package/types/navigation/stepper.d.ts +26 -0
- package/types/navigation/tabs.d.ts +31 -0
- package/types/surfaces/accordion.d.ts +32 -0
- package/types/surfaces/app-bar.d.ts +25 -0
- package/types/surfaces/card.d.ts +39 -0
- package/types/surfaces/paper.d.ts +28 -0
- package/src/shared/withRenderValidation.js +0 -19
- package/src/widgets/card/card.stories.js +0 -135
- package/src/widgets/card/index.js +0 -4
- package/src/widgets/card/style.css +0 -53
- package/src/widgets/card/template.js +0 -97
- package/types/widgets/card.d.ts +0 -21
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
.iw-chip {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: var(--iw-space-1);
|
|
5
|
+
padding: var(--iw-space-1) var(--iw-space-2);
|
|
6
|
+
border-radius: 999px;
|
|
7
|
+
background: var(--iw-color-bg-secondary);
|
|
8
|
+
color: var(--iw-color-text);
|
|
9
|
+
font-size: var(--iw-font-size-sm);
|
|
10
|
+
line-height: 1;
|
|
11
|
+
|
|
12
|
+
.iw-chip-label {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
line-height: 1;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.iw-chip-remove {
|
|
19
|
+
display: inline-grid;
|
|
20
|
+
place-items: center;
|
|
21
|
+
align-self: center;
|
|
22
|
+
width: 1em;
|
|
23
|
+
height: 1em;
|
|
24
|
+
border: 0;
|
|
25
|
+
background: transparent;
|
|
26
|
+
color: inherit;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
padding: 0;
|
|
29
|
+
font-size: var(--iw-font-size-sm);
|
|
30
|
+
line-height: 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.iw-chip-sm {
|
|
34
|
+
padding-block: var(--iw-space-1);
|
|
35
|
+
padding-inline: var(--iw-space-2);
|
|
36
|
+
font-size: var(--iw-font-size-xs);
|
|
37
|
+
|
|
38
|
+
.iw-chip-remove {
|
|
39
|
+
font-size: var(--iw-font-size-xs);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&.iw-chip-lg {
|
|
44
|
+
padding-block: var(--iw-space-2);
|
|
45
|
+
padding-inline: var(--iw-space-3);
|
|
46
|
+
font-size: var(--iw-font-size-base);
|
|
47
|
+
|
|
48
|
+
.iw-chip-remove {
|
|
49
|
+
font-size: var(--iw-font-size-base);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&.iw-chip-shape-rounded {
|
|
54
|
+
border-radius: var(--iw-radius-md);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&.iw-chip-shape-square {
|
|
58
|
+
border-radius: var(--iw-radius-none);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&.iw-chip-primary {
|
|
62
|
+
background: color-mix(in srgb, var(--iw-color-primary) 20%, transparent);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&.iw-chip-secondary {
|
|
66
|
+
background: color-mix(in srgb, var(--iw-color-gray-600) 20%, transparent);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&.iw-chip-success {
|
|
70
|
+
background: color-mix(in srgb, var(--iw-color-success) 20%, transparent);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&.iw-chip-warning {
|
|
74
|
+
background: color-mix(in srgb, var(--iw-color-warning) 24%, transparent);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&.iw-chip-error {
|
|
78
|
+
background: color-mix(in srgb, var(--iw-color-error) 20%, transparent);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&.iw-chip-info {
|
|
82
|
+
background: color-mix(in srgb, var(--iw-color-info) 20%, transparent);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../../../types/data-display/chip').ChipProps} ChipProps
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { classMap, html } from "@inglorious/web"
|
|
6
|
+
|
|
7
|
+
export function render(props) {
|
|
8
|
+
const {
|
|
9
|
+
children,
|
|
10
|
+
isRemovable = false,
|
|
11
|
+
color = "default",
|
|
12
|
+
size = "md",
|
|
13
|
+
shape = "pill",
|
|
14
|
+
onClick,
|
|
15
|
+
} = props
|
|
16
|
+
|
|
17
|
+
const classes = {
|
|
18
|
+
"iw-chip": true,
|
|
19
|
+
[`iw-chip-${color}`]: color !== "default",
|
|
20
|
+
[`iw-chip-${size}`]: size !== "md",
|
|
21
|
+
[`iw-chip-shape-${shape}`]: shape !== "pill",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return html`<span class=${classMap(classes)}>
|
|
25
|
+
<span class="iw-chip-label">${children}</span>
|
|
26
|
+
${isRemovable
|
|
27
|
+
? html`<button type="button" class="iw-chip-remove" @click=${onClick}>
|
|
28
|
+
×
|
|
29
|
+
</button>`
|
|
30
|
+
: null}
|
|
31
|
+
</span>`
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
@import "./avatar/style.css";
|
|
2
|
+
@import "./badge/style.css";
|
|
3
|
+
@import "./chip/style.css";
|
|
4
|
+
@import "./data-grid/style.css";
|
|
5
|
+
@import "./divider/style.css";
|
|
6
|
+
@import "./icon/style.css";
|
|
7
|
+
@import "./list/style.css";
|
|
8
|
+
@import "./material-icon/style.css";
|
|
9
|
+
@import "./table/style.css";
|
|
10
|
+
@import "./tooltip/style.css";
|
|
11
|
+
@import "./typography/style.css";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
.iw-data-grid {
|
|
2
|
+
user-select: none;
|
|
3
|
+
|
|
4
|
+
.iw-data-grid-header {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.iw-data-grid-header-row {
|
|
10
|
+
display: flex;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.iw-data-grid-header-column {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
position: relative;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.iw-data-grid-toolbar {
|
|
20
|
+
display: flex;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.iw-data-grid-searchbar {
|
|
24
|
+
flex: 1 1 auto;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.iw-data-grid-filter-input,
|
|
28
|
+
.iw-data-grid-filter-select {
|
|
29
|
+
width: 100%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.iw-data-grid-filter-range {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
gap: var(--iw-space-2);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.iw-data-grid-filter-range-input {
|
|
39
|
+
min-width: 0;
|
|
40
|
+
flex: 1 1 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.iw-data-grid-row {
|
|
44
|
+
display: flex;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.iw-data-grid-footer-row {
|
|
48
|
+
display: flex;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.iw-data-grid-column-resizer {
|
|
52
|
+
position: absolute;
|
|
53
|
+
inset: 0 0 0 auto;
|
|
54
|
+
width: 1rem;
|
|
55
|
+
cursor: col-resize;
|
|
56
|
+
touch-action: none;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createEntityRender,
|
|
3
|
+
notifyActionArgType,
|
|
4
|
+
} from "../../stories/notifyStory.js"
|
|
5
|
+
import { dataGrid } from "."
|
|
6
|
+
|
|
7
|
+
const baseRows = [
|
|
8
|
+
{ id: 1, name: "Charlie", age: 35, active: true, role: "Admin" },
|
|
9
|
+
{ id: 2, name: "Alice", age: 30, active: true, role: "User" },
|
|
10
|
+
{ id: 3, name: "Bob", age: 25, active: false, role: "User" },
|
|
11
|
+
{ id: 4, name: "David", age: 40, active: true, role: "Admin" },
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
const baseColumns = [
|
|
15
|
+
{
|
|
16
|
+
id: "id",
|
|
17
|
+
title: "Id",
|
|
18
|
+
type: "number",
|
|
19
|
+
isSortable: true,
|
|
20
|
+
isFilterable: true,
|
|
21
|
+
filter: { type: "number" },
|
|
22
|
+
},
|
|
23
|
+
{ id: "name", title: "Name", isSortable: true, isFilterable: true },
|
|
24
|
+
{
|
|
25
|
+
id: "age",
|
|
26
|
+
title: "Age",
|
|
27
|
+
type: "number",
|
|
28
|
+
isSortable: true,
|
|
29
|
+
isFilterable: true,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: "active",
|
|
33
|
+
title: "Active",
|
|
34
|
+
type: "boolean",
|
|
35
|
+
isFilterable: true,
|
|
36
|
+
width: 100,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "role",
|
|
40
|
+
title: "Role",
|
|
41
|
+
isFilterable: true,
|
|
42
|
+
filter: { type: "select", options: ["", "Admin", "User"] },
|
|
43
|
+
width: 100,
|
|
44
|
+
},
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
function createRows(count) {
|
|
48
|
+
return Array.from({ length: count }, (_, index) => ({
|
|
49
|
+
id: index + 1,
|
|
50
|
+
name: `User ${index + 1}`,
|
|
51
|
+
age: 20 + (index % 35),
|
|
52
|
+
active: index % 3 !== 0,
|
|
53
|
+
role: index % 4 === 0 ? "Admin" : "User",
|
|
54
|
+
}))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
title: "Data Display/DataGrid",
|
|
59
|
+
tags: ["autodocs"],
|
|
60
|
+
render: createEntityRender({ dataGrid }),
|
|
61
|
+
argTypes: {
|
|
62
|
+
...notifyActionArgType,
|
|
63
|
+
id: { control: "text", description: "Optional grid id" },
|
|
64
|
+
},
|
|
65
|
+
parameters: {
|
|
66
|
+
docs: {
|
|
67
|
+
description: {
|
|
68
|
+
component:
|
|
69
|
+
"Data grid primitive with overridable `renderHeaderCell`, `renderRow`, and `renderCell` sub-renders.",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const Default = {
|
|
76
|
+
args: {
|
|
77
|
+
id: "dataGrid",
|
|
78
|
+
type: "dataGrid",
|
|
79
|
+
rows: baseRows,
|
|
80
|
+
columns: baseColumns,
|
|
81
|
+
search: {},
|
|
82
|
+
selection: [2],
|
|
83
|
+
isStriped: true,
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const Paginated = {
|
|
88
|
+
args: {
|
|
89
|
+
...Default.args,
|
|
90
|
+
rows: createRows(48),
|
|
91
|
+
selection: [],
|
|
92
|
+
pagination: {
|
|
93
|
+
page: 0,
|
|
94
|
+
pageSize: 10,
|
|
95
|
+
pageSizes: [10, 20, 50],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
parameters: {
|
|
99
|
+
docs: {
|
|
100
|
+
description: {
|
|
101
|
+
story:
|
|
102
|
+
"Shows the grid with enough rows to exercise pagination, footer controls, and the global search toolbar.",
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const FlexibleWidths = {
|
|
109
|
+
args: {
|
|
110
|
+
...Default.args,
|
|
111
|
+
columns: [
|
|
112
|
+
{ ...baseColumns[0], width: "auto" },
|
|
113
|
+
{ ...baseColumns[1], width: "2fr" },
|
|
114
|
+
{ ...baseColumns[2], width: "1fr" },
|
|
115
|
+
{ ...baseColumns[3], width: 100 },
|
|
116
|
+
{ ...baseColumns[4], width: "40%" },
|
|
117
|
+
],
|
|
118
|
+
selection: [],
|
|
119
|
+
},
|
|
120
|
+
parameters: {
|
|
121
|
+
docs: {
|
|
122
|
+
description: {
|
|
123
|
+
story:
|
|
124
|
+
"Demonstrates mixed column sizing with `auto`, fractional `fr`, percentage, and fixed widths before any manual resizing.",
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const Virtualized = {
|
|
131
|
+
args: {
|
|
132
|
+
id: "virtualizedGrid",
|
|
133
|
+
type: "dataGrid",
|
|
134
|
+
rows: createRows(1000),
|
|
135
|
+
columns: baseColumns,
|
|
136
|
+
search: null,
|
|
137
|
+
selection: [],
|
|
138
|
+
pagination: null,
|
|
139
|
+
isStriped: true,
|
|
140
|
+
isVirtualized: true,
|
|
141
|
+
virtualization: {
|
|
142
|
+
viewportHeight: 480,
|
|
143
|
+
estimatedHeight: 44,
|
|
144
|
+
bufferSize: 6,
|
|
145
|
+
visibleRange: { start: 0, end: 20 },
|
|
146
|
+
itemHeight: null,
|
|
147
|
+
scrollTop: 0,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
parameters: {
|
|
151
|
+
docs: {
|
|
152
|
+
description: {
|
|
153
|
+
story:
|
|
154
|
+
"Renders 1000 rows with virtualization enabled and pagination disabled.",
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function format(value, type) {
|
|
2
|
+
if (type === "number") return Number(value)
|
|
3
|
+
if (type === "boolean")
|
|
4
|
+
return value === "true" ? true : value === "false" ? false : null
|
|
5
|
+
if (["date", "time", "datetime"].includes(type))
|
|
6
|
+
return new Date(value).getTime()
|
|
7
|
+
return value
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { choose, html } from "@inglorious/web"
|
|
2
|
+
|
|
3
|
+
import { inputFilter } from "./input.js"
|
|
4
|
+
import { rangeFilter } from "./range.js"
|
|
5
|
+
import { selectFilter } from "./select.js"
|
|
6
|
+
|
|
7
|
+
export const filters = {
|
|
8
|
+
render(entity, column) {
|
|
9
|
+
return html`${choose(
|
|
10
|
+
column.filter.type,
|
|
11
|
+
[
|
|
12
|
+
["range", () => rangeFilter.render(entity, column)],
|
|
13
|
+
["date", () => rangeFilter.render(entity, column)],
|
|
14
|
+
["time", () => rangeFilter.render(entity, column)],
|
|
15
|
+
["datetime", () => rangeFilter.render(entity, column)],
|
|
16
|
+
["select", () => selectFilter.render(entity, column)],
|
|
17
|
+
],
|
|
18
|
+
() => inputFilter.render(entity, column),
|
|
19
|
+
)}`
|
|
20
|
+
},
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { input } from "../../../controls/input"
|
|
2
|
+
import { format } from "./helpers"
|
|
3
|
+
|
|
4
|
+
const DEFAULT_PLACEHOLDER = {
|
|
5
|
+
number: "=",
|
|
6
|
+
text: "Contains...",
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const inputFilter = {
|
|
10
|
+
render(entity, column) {
|
|
11
|
+
return input.render({
|
|
12
|
+
name: column.id,
|
|
13
|
+
inputType: column.filter.type,
|
|
14
|
+
placeholder:
|
|
15
|
+
column.filter.placeholder ?? DEFAULT_PLACEHOLDER[column.filter.type],
|
|
16
|
+
size: "sm",
|
|
17
|
+
isFullWidth: true,
|
|
18
|
+
onChange: (value) => {
|
|
19
|
+
const formattedValue = value ? format(value, column.type) : null
|
|
20
|
+
entity.onFilterChange?.({ columnId: column.id, value: formattedValue })
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
},
|
|
24
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { html } from "@inglorious/web"
|
|
2
|
+
|
|
3
|
+
import { input } from "../../../controls/input"
|
|
4
|
+
import { format } from "./helpers"
|
|
5
|
+
|
|
6
|
+
const RANGE_TYPE = {
|
|
7
|
+
range: "number",
|
|
8
|
+
date: "date",
|
|
9
|
+
time: "time",
|
|
10
|
+
datetime: "datetime-local",
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const rangeFilter = {
|
|
14
|
+
render(entity, column) {
|
|
15
|
+
return html`<div class="iw-data-grid-filter-range">
|
|
16
|
+
${input.render({
|
|
17
|
+
name: `${column.id}Min`,
|
|
18
|
+
inputType: RANGE_TYPE[column.filter.type],
|
|
19
|
+
placeholder: column.filter.placeholder ?? "≥",
|
|
20
|
+
size: "sm",
|
|
21
|
+
isFullWidth: true,
|
|
22
|
+
className: "iw-data-grid-filter-range-input",
|
|
23
|
+
onChange: (value) => {
|
|
24
|
+
const formattedValue = value ? format(value, column.type) : null
|
|
25
|
+
entity.onFilterChange?.({
|
|
26
|
+
columnId: column.id,
|
|
27
|
+
value: { ...entity.filters[column.id], min: formattedValue },
|
|
28
|
+
})
|
|
29
|
+
},
|
|
30
|
+
})}
|
|
31
|
+
${input.render({
|
|
32
|
+
name: `${column.id}Max`,
|
|
33
|
+
inputType: RANGE_TYPE[column.filter.type],
|
|
34
|
+
placeholder: column.filter.placeholder ?? "≤",
|
|
35
|
+
size: "sm",
|
|
36
|
+
isFullWidth: true,
|
|
37
|
+
className: "iw-data-grid-filter-range-input",
|
|
38
|
+
onChange: (value) => {
|
|
39
|
+
const formattedValue = value ? format(value, column.type) : null
|
|
40
|
+
entity.onFilterChange?.({
|
|
41
|
+
columnId: column.id,
|
|
42
|
+
value: { ...entity.filters[column.id], max: formattedValue },
|
|
43
|
+
})
|
|
44
|
+
},
|
|
45
|
+
})}
|
|
46
|
+
</div>`
|
|
47
|
+
},
|
|
48
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { select } from "../../../controls/select"
|
|
2
|
+
import { format } from "./helpers"
|
|
3
|
+
|
|
4
|
+
export const selectFilter = {
|
|
5
|
+
render(entity, column) {
|
|
6
|
+
return select.render({
|
|
7
|
+
name: column.id,
|
|
8
|
+
size: "sm",
|
|
9
|
+
isFullWidth: true,
|
|
10
|
+
options: column.filter.options,
|
|
11
|
+
onChange: (value) => {
|
|
12
|
+
const formattedValue = value ? format(value, column.type) : null
|
|
13
|
+
entity.onFilterChange?.({ columnId: column.id, value: formattedValue })
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
},
|
|
17
|
+
}
|