@inglorious/ui 0.1.0 → 1.0.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/README.md +45 -0
- package/package.json +191 -16
- 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
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { html } from "@inglorious/web"
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
makeStoryRender,
|
|
5
|
-
notifyActionArgType,
|
|
6
|
-
} from "../../stories/notifyStory.js"
|
|
3
|
+
import { createRender } from "../../stories/notifyStory.js"
|
|
7
4
|
import { fab } from "."
|
|
8
5
|
|
|
9
6
|
export default {
|
|
10
7
|
title: "Controls/Fab",
|
|
11
8
|
tags: ["autodocs"],
|
|
12
|
-
render:
|
|
9
|
+
render: createRender(fab),
|
|
13
10
|
argTypes: {
|
|
14
|
-
...notifyActionArgType,
|
|
15
11
|
children: { control: "text", description: "Content of the FAB." },
|
|
16
12
|
color: {
|
|
17
13
|
control: "select",
|
|
@@ -23,8 +19,12 @@ export default {
|
|
|
23
19
|
options: ["sm", "md", "lg"],
|
|
24
20
|
description: "Button size.",
|
|
25
21
|
},
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
isExtended: {
|
|
23
|
+
control: "boolean",
|
|
24
|
+
description: "Use extended pill shape.",
|
|
25
|
+
},
|
|
26
|
+
isDisabled: { control: "boolean", description: "Disables interaction." },
|
|
27
|
+
onClick: { action: "onClick" },
|
|
28
28
|
},
|
|
29
29
|
parameters: {
|
|
30
30
|
docs: {
|
|
@@ -40,13 +40,13 @@ Default.args = {
|
|
|
40
40
|
children: "+",
|
|
41
41
|
color: "primary",
|
|
42
42
|
size: "md",
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
isExtended: false,
|
|
44
|
+
isDisabled: false,
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export const Extended = {}
|
|
48
48
|
Extended.args = {
|
|
49
49
|
...Default.args,
|
|
50
|
-
|
|
50
|
+
isExtended: true,
|
|
51
51
|
children: html`<span>+</span><span>Create</span>`,
|
|
52
52
|
}
|
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../../../types/controls/fab').
|
|
3
|
-
* @typedef {import('@inglorious/web').Api} Api
|
|
2
|
+
* @typedef {import('../../../types/controls/fab').FabProps} FabProps
|
|
4
3
|
* @typedef {import('@inglorious/web').TemplateResult} TemplateResult
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
6
|
import { html } from "@inglorious/web"
|
|
8
7
|
|
|
9
|
-
import {
|
|
8
|
+
import { button } from "../button/index.js"
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Floating action button for primary contextual actions.
|
|
13
12
|
*
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {Api} api
|
|
13
|
+
* @param {FabProps} props
|
|
16
14
|
* @returns {TemplateResult}
|
|
17
15
|
*/
|
|
18
|
-
export function render(
|
|
19
|
-
const {
|
|
16
|
+
export function render(props) {
|
|
17
|
+
const {
|
|
18
|
+
children,
|
|
19
|
+
isExtended = false,
|
|
20
|
+
className = "",
|
|
21
|
+
onClick,
|
|
22
|
+
...rest
|
|
23
|
+
} = props
|
|
20
24
|
|
|
21
|
-
return button.render(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
className
|
|
26
|
-
|
|
27
|
-
children
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
api,
|
|
32
|
-
)
|
|
25
|
+
return button.render({
|
|
26
|
+
...rest,
|
|
27
|
+
shape: isExtended ? "pill" : "round",
|
|
28
|
+
className:
|
|
29
|
+
`iw-fab ${isExtended ? "iw-fab-extended" : ""} ${className}`.trim(),
|
|
30
|
+
children: isExtended
|
|
31
|
+
? children
|
|
32
|
+
: html`<span class="iw-fab-content">${children}</span>`,
|
|
33
|
+
onClick,
|
|
34
|
+
})
|
|
33
35
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
makeStoryRender,
|
|
3
|
-
notifyActionArgType,
|
|
4
|
-
} from "../../stories/notifyStory.js"
|
|
1
|
+
import { createRender } from "../../stories/notifyStory.js"
|
|
5
2
|
import { iconButton } from "."
|
|
6
3
|
|
|
7
4
|
export default {
|
|
8
5
|
title: "Controls/IconButton",
|
|
9
6
|
tags: ["autodocs"],
|
|
10
|
-
render:
|
|
7
|
+
render: createRender(iconButton),
|
|
11
8
|
argTypes: {
|
|
12
|
-
...notifyActionArgType,
|
|
13
9
|
icon: { control: "text", description: "Leading icon content." },
|
|
14
10
|
label: { control: "text", description: "Optional button label." },
|
|
15
11
|
iconAfter: { control: "text", description: "Trailing icon content." },
|
|
@@ -18,10 +14,6 @@ export default {
|
|
|
18
14
|
options: ["row", "column"],
|
|
19
15
|
description: "Layout direction for icon and label.",
|
|
20
16
|
},
|
|
21
|
-
iconOnly: {
|
|
22
|
-
control: "boolean",
|
|
23
|
-
description: "Renders icon-only content.",
|
|
24
|
-
},
|
|
25
17
|
ariaLabel: {
|
|
26
18
|
control: "text",
|
|
27
19
|
description: "Accessible name when used as icon-only button.",
|
|
@@ -36,6 +28,12 @@ export default {
|
|
|
36
28
|
options: ["primary", "secondary", "success", "warning", "error", "info"],
|
|
37
29
|
description: "Semantic color inherited from button.",
|
|
38
30
|
},
|
|
31
|
+
size: {
|
|
32
|
+
control: "select",
|
|
33
|
+
options: ["sm", "md", "lg"],
|
|
34
|
+
description: "Size scale for paddings and font-size.",
|
|
35
|
+
},
|
|
36
|
+
onClick: { action: "onClick" },
|
|
39
37
|
},
|
|
40
38
|
parameters: {
|
|
41
39
|
docs: {
|
|
@@ -1,47 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../../../types/controls/icon-button').
|
|
3
|
-
* @typedef {import('@inglorious/web').Api} Api
|
|
2
|
+
* @typedef {import('../../../types/controls/icon-button').IconButtonProps} IconButtonProps
|
|
4
3
|
* @typedef {import('@inglorious/web').TemplateResult} TemplateResult
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
6
|
import { html } from "@inglorious/web"
|
|
8
7
|
|
|
9
|
-
import {
|
|
8
|
+
import { button } from "../button/index.js"
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Icon button wrapper built on top of the base button renderer.
|
|
13
12
|
*
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {Api} api
|
|
13
|
+
* @param {IconButtonProps} props
|
|
16
14
|
* @returns {TemplateResult}
|
|
17
15
|
*/
|
|
18
|
-
export function render(
|
|
16
|
+
export function render(props) {
|
|
19
17
|
const {
|
|
18
|
+
type, // eslint-disable-line no-unused-vars
|
|
20
19
|
icon,
|
|
21
20
|
label,
|
|
22
21
|
iconAfter,
|
|
23
22
|
direction = "row",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} = entity
|
|
23
|
+
onClick,
|
|
24
|
+
} = props
|
|
27
25
|
|
|
28
26
|
const children = html`
|
|
29
27
|
<span class="iw-icon-button-content iw-icon-button-content-${direction}">
|
|
30
28
|
${icon ? html`<span class="iw-button-icon">${icon}</span>` : null}
|
|
31
|
-
${
|
|
29
|
+
${label}
|
|
32
30
|
${iconAfter
|
|
33
31
|
? html`<span class="iw-button-icon">${iconAfter}</span>`
|
|
34
32
|
: null}
|
|
35
33
|
</span>
|
|
36
34
|
`
|
|
37
35
|
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
ariaLabel,
|
|
44
|
-
},
|
|
45
|
-
api,
|
|
46
|
-
)
|
|
36
|
+
return button.render({
|
|
37
|
+
...props,
|
|
38
|
+
children,
|
|
39
|
+
onClick,
|
|
40
|
+
})
|
|
47
41
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
makeStoryRender,
|
|
3
|
-
notifyActionArgType,
|
|
4
|
-
} from "../../stories/notifyStory.js"
|
|
1
|
+
import { createRender } from "../../stories/notifyStory.js"
|
|
5
2
|
import { input } from "."
|
|
6
3
|
|
|
7
4
|
export default {
|
|
8
5
|
title: "Controls/Input",
|
|
9
6
|
tags: ["autodocs"],
|
|
10
|
-
render:
|
|
7
|
+
render: createRender(input),
|
|
11
8
|
argTypes: {
|
|
12
|
-
...notifyActionArgType,
|
|
9
|
+
// ...notifyActionArgType,
|
|
13
10
|
label: {
|
|
14
11
|
control: "text",
|
|
15
12
|
description: "Field label rendered above the input.",
|
|
@@ -58,22 +55,25 @@ export default {
|
|
|
58
55
|
options: ["sm", "md", "lg"],
|
|
59
56
|
description: "Size scale for paddings and font-size.",
|
|
60
57
|
},
|
|
61
|
-
|
|
58
|
+
isDisabled: {
|
|
62
59
|
control: "boolean",
|
|
63
60
|
description: "Disables user input and interaction.",
|
|
64
61
|
},
|
|
65
|
-
|
|
62
|
+
isReadOnly: {
|
|
66
63
|
control: "boolean",
|
|
67
64
|
description: "Prevents editing while keeping the field focusable.",
|
|
68
65
|
},
|
|
69
|
-
|
|
66
|
+
isRequired: {
|
|
70
67
|
control: "boolean",
|
|
71
68
|
description: "Marks the field as required.",
|
|
72
69
|
},
|
|
73
|
-
|
|
70
|
+
isFullWidth: {
|
|
74
71
|
control: "boolean",
|
|
75
72
|
description: "Expands input width to 100% of its container.",
|
|
76
73
|
},
|
|
74
|
+
onChange: { action: "onChange" },
|
|
75
|
+
onBlur: { action: "onBlur" },
|
|
76
|
+
onFocus: { action: "onFocus" },
|
|
77
77
|
},
|
|
78
78
|
parameters: {
|
|
79
79
|
docs: {
|
|
@@ -84,27 +84,28 @@ export default {
|
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
86
|
}
|
|
87
|
+
|
|
87
88
|
export const Default = {}
|
|
88
89
|
Default.args = {
|
|
89
90
|
label: "Username",
|
|
90
91
|
placeholder: "Enter your username",
|
|
91
92
|
name: "username",
|
|
92
|
-
|
|
93
|
+
inputType: "text",
|
|
93
94
|
value: "",
|
|
94
95
|
hint: "",
|
|
95
96
|
error: "",
|
|
96
97
|
size: "md",
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
isDisabled: false,
|
|
99
|
+
isReadOnly: false,
|
|
100
|
+
isRequired: false,
|
|
101
|
+
isFullWidth: false,
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
export const WithHint = {}
|
|
104
105
|
WithHint.args = {
|
|
105
106
|
...Default.args,
|
|
106
107
|
label: "Email",
|
|
107
|
-
|
|
108
|
+
inputType: "email",
|
|
108
109
|
placeholder: "you@example.com",
|
|
109
110
|
hint: "We'll never share your email",
|
|
110
111
|
}
|
|
@@ -113,7 +114,7 @@ export const WithError = {}
|
|
|
113
114
|
WithError.args = {
|
|
114
115
|
...Default.args,
|
|
115
116
|
label: "Email",
|
|
116
|
-
|
|
117
|
+
inputType: "email",
|
|
117
118
|
value: "invalid-email",
|
|
118
119
|
error: "Please enter a valid email address",
|
|
119
120
|
}
|
|
@@ -122,16 +123,16 @@ export const Required = {}
|
|
|
122
123
|
Required.args = {
|
|
123
124
|
...Default.args,
|
|
124
125
|
label: "Password",
|
|
125
|
-
|
|
126
|
+
inputType: "password",
|
|
126
127
|
placeholder: "Enter your password",
|
|
127
|
-
|
|
128
|
+
isRequired: true,
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
export const Disabled = {}
|
|
131
132
|
Disabled.args = {
|
|
132
133
|
...Default.args,
|
|
133
134
|
label: "Disabled Input",
|
|
134
|
-
|
|
135
|
+
isDisabled: true,
|
|
135
136
|
value: "Cannot edit",
|
|
136
137
|
}
|
|
137
138
|
|
|
@@ -139,7 +140,7 @@ export const Readonly = {}
|
|
|
139
140
|
Readonly.args = {
|
|
140
141
|
...Default.args,
|
|
141
142
|
label: "Readonly Input",
|
|
142
|
-
|
|
143
|
+
isReadOnly: true,
|
|
143
144
|
value: "Read-only value",
|
|
144
145
|
}
|
|
145
146
|
|
|
@@ -162,14 +163,14 @@ FullWidth.args = {
|
|
|
162
163
|
...Default.args,
|
|
163
164
|
label: "Full Width Input",
|
|
164
165
|
placeholder: "This input takes full width",
|
|
165
|
-
|
|
166
|
+
isFullWidth: true,
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
export const Number = {}
|
|
169
170
|
Number.args = {
|
|
170
171
|
...Default.args,
|
|
171
172
|
label: "Amount",
|
|
172
|
-
|
|
173
|
+
inputType: "number",
|
|
173
174
|
value: "1234.56",
|
|
174
175
|
placeholder: "0.00",
|
|
175
176
|
min: "0",
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
gap: var(--iw-space-1);
|
|
5
5
|
font-family: var(--iw-font-family-sans);
|
|
6
6
|
|
|
7
|
-
&.iw-input-full-width {
|
|
7
|
+
&.iw-input-full-width .iw-input {
|
|
8
8
|
width: 100%;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.iw-input-label {
|
|
12
12
|
font-size: var(--iw-font-size-sm);
|
|
13
|
-
font-weight: var(--iw-font-weight-
|
|
13
|
+
font-weight: var(--iw-font-weight-normal);
|
|
14
14
|
color: var(--iw-color-text);
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
.iw-input {
|
|
29
|
-
|
|
30
|
-
padding:
|
|
29
|
+
height: 2.25rem;
|
|
30
|
+
padding: 0 var(--iw-space-3);
|
|
31
31
|
font-family: inherit;
|
|
32
32
|
font-size: var(--iw-font-size-base);
|
|
33
|
-
line-height:
|
|
33
|
+
line-height: 1.2;
|
|
34
34
|
color: var(--iw-input-text);
|
|
35
35
|
background-color: var(--iw-input-bg);
|
|
36
36
|
border: 1px solid var(--iw-input-border);
|
|
@@ -72,12 +72,14 @@
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
&.iw-input-sm {
|
|
75
|
-
|
|
75
|
+
height: 2rem;
|
|
76
|
+
padding: 0 var(--iw-space-2);
|
|
76
77
|
font-size: var(--iw-font-size-sm);
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
&.iw-input-lg {
|
|
80
|
-
|
|
81
|
+
height: 2.75rem;
|
|
82
|
+
padding: 0 var(--iw-space-4);
|
|
81
83
|
font-size: var(--iw-font-size-lg);
|
|
82
84
|
}
|
|
83
85
|
}
|
|
@@ -1,54 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../../../types/controls/input').
|
|
3
|
-
* @typedef {import('@inglorious/web').Api} Api
|
|
2
|
+
* @typedef {import('../../../types/controls/input').InputProps} InputProps
|
|
4
3
|
* @typedef {import('@inglorious/web').TemplateResult} TemplateResult
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
6
|
import { classMap, html, ref } from "@inglorious/web"
|
|
8
7
|
|
|
9
|
-
import { applyElementProps } from "
|
|
8
|
+
import { applyElementProps } from "../../shared/applyElementProps.js"
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Input component for Inglorious Web.
|
|
13
12
|
*
|
|
14
13
|
* @example
|
|
15
14
|
* // Stateless usage
|
|
16
|
-
* input.render({ label: 'Email', type: 'email', placeholder: 'you@example.com' }
|
|
15
|
+
* input.render({ label: 'Email', type: 'email', placeholder: 'you@example.com' })
|
|
17
16
|
*
|
|
18
|
-
* @
|
|
19
|
-
* // Stateful usage with event handling
|
|
20
|
-
* // Entity: { type: 'input', id: 'emailInput', label: 'Email' }
|
|
21
|
-
* // In store: api.render('emailInput')
|
|
22
|
-
*
|
|
23
|
-
* @param {InputEntity} entity
|
|
24
|
-
* @param {Api} api
|
|
17
|
+
* @param {InputProps} props
|
|
25
18
|
* @returns {TemplateResult}
|
|
26
19
|
*/
|
|
27
|
-
export function render(
|
|
20
|
+
export function render(props) {
|
|
28
21
|
const {
|
|
22
|
+
id,
|
|
23
|
+
type, // eslint-disable-line no-unused-vars
|
|
29
24
|
name = "",
|
|
30
|
-
|
|
25
|
+
inputType = "text",
|
|
31
26
|
value = "",
|
|
32
27
|
placeholder = "",
|
|
33
28
|
label,
|
|
34
29
|
hint,
|
|
35
30
|
error,
|
|
36
31
|
size = "md",
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
isDisabled = false,
|
|
33
|
+
isReadOnly = false,
|
|
34
|
+
isRequired = false,
|
|
35
|
+
isFullWidth = false,
|
|
41
36
|
icon,
|
|
42
37
|
iconAfter,
|
|
38
|
+
onChange,
|
|
39
|
+
onBlur,
|
|
40
|
+
onFocus,
|
|
43
41
|
...rest
|
|
44
|
-
} =
|
|
42
|
+
} = props
|
|
45
43
|
|
|
46
|
-
const inputId =
|
|
44
|
+
const inputId = id || name
|
|
47
45
|
|
|
48
46
|
const wrapperClasses = {
|
|
49
47
|
"iw-input-field": true,
|
|
50
|
-
"iw-input-full-width":
|
|
51
|
-
"iw-input-disabled":
|
|
48
|
+
"iw-input-full-width": isFullWidth,
|
|
49
|
+
"iw-input-disabled": isDisabled,
|
|
52
50
|
"iw-input-has-error": !!error,
|
|
53
51
|
"iw-input-has-icon": !!icon,
|
|
54
52
|
"iw-input-has-icon-after": !!iconAfter,
|
|
@@ -58,7 +56,7 @@ export function render(entity, api) {
|
|
|
58
56
|
"iw-input": true,
|
|
59
57
|
[`iw-input-${size}`]: size !== "md",
|
|
60
58
|
"iw-input-error": !!error,
|
|
61
|
-
"iw-input-number":
|
|
59
|
+
"iw-input-number": inputType === "number",
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
return html`
|
|
@@ -67,7 +65,7 @@ export function render(entity, api) {
|
|
|
67
65
|
? html`
|
|
68
66
|
<label for=${inputId} class="iw-input-label">
|
|
69
67
|
${label}
|
|
70
|
-
${
|
|
68
|
+
${isRequired
|
|
71
69
|
? html`<span class="iw-input-required">*</span>`
|
|
72
70
|
: null}
|
|
73
71
|
</label>
|
|
@@ -80,17 +78,16 @@ export function render(entity, api) {
|
|
|
80
78
|
<input
|
|
81
79
|
id=${inputId}
|
|
82
80
|
name=${name}
|
|
83
|
-
type=${
|
|
81
|
+
type=${inputType}
|
|
84
82
|
.value=${value}
|
|
85
83
|
placeholder=${placeholder}
|
|
86
|
-
?disabled=${
|
|
87
|
-
?readonly=${
|
|
88
|
-
?required=${
|
|
84
|
+
?disabled=${isDisabled}
|
|
85
|
+
?readonly=${isReadOnly}
|
|
86
|
+
?required=${isRequired}
|
|
89
87
|
class=${classMap(inputClasses)}
|
|
90
|
-
@input=${(event) =>
|
|
91
|
-
|
|
92
|
-
@
|
|
93
|
-
@focus=${() => api.notify(`#${entity.id}:focus`)}
|
|
88
|
+
@input=${(event) => onChange?.(event.target.value)}
|
|
89
|
+
@blur=${onBlur}
|
|
90
|
+
@focus=${onFocus}
|
|
94
91
|
${ref((element) => applyElementProps(element, rest))}
|
|
95
92
|
/>
|
|
96
93
|
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
makeStoryRender,
|
|
3
|
-
notifyActionArgType,
|
|
4
|
-
} from "../../stories/notifyStory.js"
|
|
1
|
+
import { createRender } from "../../stories/notifyStory.js"
|
|
5
2
|
import { radioGroup } from "."
|
|
6
3
|
|
|
7
4
|
export default {
|
|
8
5
|
title: "Controls/RadioGroup",
|
|
9
6
|
tags: ["autodocs"],
|
|
10
|
-
render:
|
|
7
|
+
render: createRender(radioGroup),
|
|
11
8
|
argTypes: {
|
|
12
|
-
...notifyActionArgType,
|
|
13
9
|
label: { control: "text", description: "Fieldset label." },
|
|
14
10
|
name: { control: "text", description: "Native radio input name." },
|
|
15
11
|
value: { control: "text", description: "Selected option value." },
|
|
@@ -18,8 +14,14 @@ export default {
|
|
|
18
14
|
options: ["column", "row"],
|
|
19
15
|
description: "Layout direction for options.",
|
|
20
16
|
},
|
|
21
|
-
|
|
17
|
+
color: {
|
|
18
|
+
control: "select",
|
|
19
|
+
options: ["primary", "secondary", "success", "warning", "error", "info"],
|
|
20
|
+
description: "Semantic accent color.",
|
|
21
|
+
},
|
|
22
|
+
isDisabled: { control: "boolean", description: "Disables all options." },
|
|
22
23
|
options: { control: "object", description: "List of radio options." },
|
|
24
|
+
onChange: { action: "onChange" },
|
|
23
25
|
},
|
|
24
26
|
parameters: {
|
|
25
27
|
docs: {
|
|
@@ -36,7 +38,8 @@ Default.args = {
|
|
|
36
38
|
name: "priority",
|
|
37
39
|
value: "medium",
|
|
38
40
|
direction: "column",
|
|
39
|
-
|
|
41
|
+
color: "primary",
|
|
42
|
+
isDisabled: false,
|
|
40
43
|
options: [
|
|
41
44
|
{ label: "Low", value: "low" },
|
|
42
45
|
{ label: "Medium", value: "medium" },
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
.iw-radio-group {
|
|
2
|
+
--iw-radio-accent: var(--iw-color-primary);
|
|
2
3
|
border: 0;
|
|
3
4
|
margin: 0;
|
|
4
5
|
padding: 0;
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
|
|
21
22
|
.iw-radio {
|
|
22
23
|
margin: 0;
|
|
23
|
-
accent-color: var(--iw-
|
|
24
|
+
accent-color: var(--iw-radio-accent);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
&.iw-radio-group-column {
|
|
@@ -38,4 +39,24 @@
|
|
|
38
39
|
&.iw-radio-group-disabled {
|
|
39
40
|
opacity: 0.6;
|
|
40
41
|
}
|
|
42
|
+
|
|
43
|
+
&.iw-radio-group-secondary {
|
|
44
|
+
--iw-radio-accent: var(--iw-color-gray-600);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.iw-radio-group-success {
|
|
48
|
+
--iw-radio-accent: var(--iw-color-success);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&.iw-radio-group-warning {
|
|
52
|
+
--iw-radio-accent: var(--iw-color-warning);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&.iw-radio-group-error {
|
|
56
|
+
--iw-radio-accent: var(--iw-color-error);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&.iw-radio-group-info {
|
|
60
|
+
--iw-radio-accent: var(--iw-color-info);
|
|
61
|
+
}
|
|
41
62
|
}
|