@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.
Files changed (283) hide show
  1. package/README.md +45 -0
  2. package/package.json +191 -16
  3. package/src/all.css +7 -0
  4. package/src/controls/button/button.stories.js +35 -15
  5. package/src/controls/button/index.js +1 -3
  6. package/src/controls/button/style.css +80 -37
  7. package/src/controls/button/template.js +23 -26
  8. package/src/controls/button-group/button-group.stories.js +19 -15
  9. package/src/controls/button-group/index.js +1 -2
  10. package/src/controls/button-group/style.css +0 -7
  11. package/src/controls/button-group/template.js +46 -56
  12. package/src/controls/checkbox/checkbox.stories.js +16 -13
  13. package/src/controls/checkbox/index.js +1 -2
  14. package/src/controls/checkbox/style.css +23 -2
  15. package/src/controls/checkbox/template.js +20 -18
  16. package/src/controls/combobox/combobox.stories.js +92 -0
  17. package/src/controls/{select → combobox}/handlers.js +8 -5
  18. package/src/controls/combobox/helpers.js +91 -0
  19. package/src/controls/combobox/index.js +43 -0
  20. package/src/controls/combobox/style.css +203 -0
  21. package/src/controls/combobox/template.js +340 -0
  22. package/src/controls/controls.css +12 -0
  23. package/src/controls/fab/fab.stories.js +11 -11
  24. package/src/controls/fab/index.js +1 -2
  25. package/src/controls/fab/template.js +21 -19
  26. package/src/controls/icon-button/icon-button.stories.js +8 -10
  27. package/src/controls/icon-button/index.js +1 -2
  28. package/src/controls/icon-button/template.js +13 -19
  29. package/src/controls/input/index.js +1 -2
  30. package/src/controls/input/input.stories.js +24 -23
  31. package/src/controls/input/style.css +9 -7
  32. package/src/controls/input/template.js +28 -31
  33. package/src/controls/radio-group/index.js +1 -2
  34. package/src/controls/radio-group/radio-group.stories.js +11 -8
  35. package/src/controls/radio-group/style.css +22 -1
  36. package/src/controls/radio-group/template.js +20 -15
  37. package/src/controls/rating/index.js +1 -2
  38. package/src/controls/rating/rating.stories.js +7 -10
  39. package/src/controls/rating/style.css +1 -2
  40. package/src/controls/rating/template.js +20 -17
  41. package/src/controls/select/helpers.js +2 -21
  42. package/src/controls/select/index.js +1 -13
  43. package/src/controls/select/select.stories.js +68 -64
  44. package/src/controls/select/style.css +66 -189
  45. package/src/controls/select/template.js +77 -406
  46. package/src/controls/slider/index.js +1 -2
  47. package/src/controls/slider/slider.stories.js +15 -12
  48. package/src/controls/slider/style.css +24 -3
  49. package/src/controls/slider/template.js +30 -23
  50. package/src/controls/switch/index.js +1 -2
  51. package/src/controls/switch/style.css +23 -2
  52. package/src/controls/switch/switch.stories.js +14 -11
  53. package/src/controls/switch/template.js +18 -16
  54. package/src/data-display/avatar/avatar.stories.js +106 -0
  55. package/src/data-display/avatar/index.js +3 -0
  56. package/src/data-display/avatar/style.css +64 -0
  57. package/src/data-display/avatar/template.js +81 -0
  58. package/src/data-display/badge/badge.stories.js +64 -0
  59. package/src/data-display/badge/index.js +3 -0
  60. package/src/data-display/badge/style.css +84 -0
  61. package/src/data-display/badge/template.js +46 -0
  62. package/src/data-display/chip/chip.stories.js +57 -0
  63. package/src/data-display/chip/index.js +3 -0
  64. package/src/data-display/chip/style.css +84 -0
  65. package/src/data-display/chip/template.js +32 -0
  66. package/src/data-display/data-display.css +11 -0
  67. package/src/data-display/data-grid/base.css +58 -0
  68. package/src/data-display/data-grid/data-grid.stories.js +158 -0
  69. package/src/data-display/data-grid/filters/helpers.js +8 -0
  70. package/src/data-display/data-grid/filters/index.js +21 -0
  71. package/src/data-display/data-grid/filters/input.js +24 -0
  72. package/src/data-display/data-grid/filters/range.js +48 -0
  73. package/src/data-display/data-grid/filters/select.js +17 -0
  74. package/src/data-display/data-grid/handlers.js +523 -0
  75. package/src/data-display/data-grid/helpers.js +248 -0
  76. package/src/data-display/data-grid/index.js +64 -0
  77. package/src/data-display/data-grid/style.css +14 -0
  78. package/src/data-display/data-grid/template.js +458 -0
  79. package/src/data-display/data-grid/theme.css +148 -0
  80. package/src/data-display/divider/divider.stories.js +48 -0
  81. package/src/data-display/divider/index.js +3 -0
  82. package/src/data-display/divider/style.css +18 -0
  83. package/src/data-display/divider/template.js +17 -0
  84. package/src/data-display/icon/icon-implementations.mdx +160 -0
  85. package/src/data-display/icon/icon-utf8.stories.js +156 -0
  86. package/src/data-display/icon/icon.stories.js +38 -0
  87. package/src/data-display/icon/index.js +3 -0
  88. package/src/data-display/icon/style.css +17 -0
  89. package/src/data-display/icon/template.js +19 -0
  90. package/src/data-display/list/handlers.js +25 -0
  91. package/src/data-display/list/index.js +4 -0
  92. package/src/data-display/list/list.stories.js +187 -0
  93. package/src/data-display/list/style.css +119 -0
  94. package/src/data-display/list/template.js +302 -0
  95. package/src/data-display/material-icon/index.js +3 -0
  96. package/src/data-display/material-icon/material-icon.stories.js +99 -0
  97. package/src/data-display/material-icon/style.css +27 -0
  98. package/src/data-display/material-icon/template.js +21 -0
  99. package/src/data-display/table/index.js +1 -0
  100. package/src/data-display/table/style.css +42 -0
  101. package/src/data-display/table/table.stories.js +40 -0
  102. package/src/data-display/table/template.js +114 -0
  103. package/src/data-display/tooltip/index.js +3 -0
  104. package/src/data-display/tooltip/style.css +57 -0
  105. package/src/data-display/tooltip/template.js +58 -0
  106. package/src/data-display/tooltip/tooltip.stories.js +44 -0
  107. package/src/data-display/typography/index.js +3 -0
  108. package/src/data-display/typography/style.css +49 -0
  109. package/src/data-display/typography/template.js +110 -0
  110. package/src/data-display/typography/typography.stories.js +48 -0
  111. package/src/data-display/virtual-list/handlers.js +68 -0
  112. package/src/data-display/virtual-list/index.js +4 -0
  113. package/src/data-display/virtual-list/template.js +101 -0
  114. package/src/examples/dashboard/app-drawer.js +255 -0
  115. package/src/examples/dashboard/app-header.js +149 -0
  116. package/src/examples/dashboard/dashboard.js +85 -0
  117. package/src/examples/dashboard/dashboard.stories.js +47 -0
  118. package/src/examples/dashboard/data.js +205 -0
  119. package/src/examples/dashboard/mode.js +27 -0
  120. package/src/examples/dashboard/primitive-content.js +1325 -0
  121. package/src/examples/dashboard/primitive-section.js +158 -0
  122. package/src/examples/dashboard/router.js +13 -0
  123. package/src/examples/dashboard/social-card.js +73 -0
  124. package/src/examples/dashboard/stat-card.js +84 -0
  125. package/src/examples/dashboard/style.css +339 -0
  126. package/src/examples/dashboard/theme-utils.js +95 -0
  127. package/src/examples/dashboard/theme.js +27 -0
  128. package/src/examples/dashboard/traffic-card.js +108 -0
  129. package/src/examples/dashboard/traffic-sales-card.js +267 -0
  130. package/src/feedback/alert/alert.stories.js +70 -0
  131. package/src/feedback/alert/index.js +3 -0
  132. package/src/feedback/alert/style.css +98 -0
  133. package/src/feedback/alert/template.js +74 -0
  134. package/src/feedback/backdrop/backdrop.stories.js +21 -0
  135. package/src/feedback/backdrop/index.js +3 -0
  136. package/src/feedback/backdrop/style.css +25 -0
  137. package/src/feedback/backdrop/template.js +31 -0
  138. package/src/feedback/dialog/dialog.stories.js +27 -0
  139. package/src/feedback/dialog/index.js +3 -0
  140. package/src/feedback/dialog/style.css +68 -0
  141. package/src/feedback/dialog/template.js +64 -0
  142. package/src/feedback/feedback.css +6 -0
  143. package/src/feedback/progress/index.js +3 -0
  144. package/src/feedback/progress/progress.stories.js +54 -0
  145. package/src/feedback/progress/style.css +95 -0
  146. package/src/feedback/progress/template.js +88 -0
  147. package/src/feedback/skeleton/index.js +3 -0
  148. package/src/feedback/skeleton/skeleton.stories.js +44 -0
  149. package/src/feedback/skeleton/style.css +41 -0
  150. package/src/feedback/skeleton/template.js +48 -0
  151. package/src/feedback/snackbar/index.js +3 -0
  152. package/src/feedback/snackbar/snackbar.stories.js +25 -0
  153. package/src/feedback/snackbar/style.css +64 -0
  154. package/src/feedback/snackbar/template.js +55 -0
  155. package/src/index.js +32 -1
  156. package/src/layout/container/container.stories.js +105 -0
  157. package/src/layout/container/index.js +3 -0
  158. package/src/layout/container/style.css +34 -0
  159. package/src/layout/container/template.js +119 -0
  160. package/src/layout/flex/flex.stories.js +28 -10
  161. package/src/layout/flex/index.js +1 -2
  162. package/src/layout/flex/style.css +20 -0
  163. package/src/layout/flex/template.js +40 -13
  164. package/src/layout/grid/grid.stories.js +46 -30
  165. package/src/layout/grid/index.js +1 -2
  166. package/src/layout/grid/style.css +20 -0
  167. package/src/layout/grid/template.js +100 -20
  168. package/src/layout/layout.css +3 -0
  169. package/src/navigation/bottom-navigation/bottom-navigation.stories.js +33 -0
  170. package/src/navigation/bottom-navigation/index.js +1 -0
  171. package/src/navigation/bottom-navigation/style.css +32 -0
  172. package/src/navigation/bottom-navigation/template.js +74 -0
  173. package/src/navigation/breadcrumbs/breadcrumbs.stories.js +33 -0
  174. package/src/navigation/breadcrumbs/index.js +1 -0
  175. package/src/navigation/breadcrumbs/style.css +27 -0
  176. package/src/navigation/breadcrumbs/template.js +79 -0
  177. package/src/navigation/drawer/drawer.stories.js +60 -0
  178. package/src/navigation/drawer/index.js +3 -0
  179. package/src/navigation/drawer/style.css +125 -0
  180. package/src/navigation/drawer/template.js +131 -0
  181. package/src/navigation/link/index.js +3 -0
  182. package/src/navigation/link/link.stories.js +53 -0
  183. package/src/navigation/link/style.css +40 -0
  184. package/src/navigation/link/template.js +53 -0
  185. package/src/navigation/menu/index.js +1 -0
  186. package/src/navigation/menu/menu.stories.js +36 -0
  187. package/src/navigation/menu/style.css +44 -0
  188. package/src/navigation/menu/template.js +81 -0
  189. package/src/navigation/navigation.css +9 -0
  190. package/src/navigation/pagination/index.js +1 -0
  191. package/src/navigation/pagination/pagination.stories.js +61 -0
  192. package/src/navigation/pagination/style.css +29 -0
  193. package/src/navigation/pagination/template.js +140 -0
  194. package/src/navigation/speed-dial/index.js +1 -0
  195. package/src/navigation/speed-dial/speed-dial.stories.js +40 -0
  196. package/src/navigation/speed-dial/style.css +38 -0
  197. package/src/navigation/speed-dial/template.js +68 -0
  198. package/src/navigation/stepper/index.js +1 -0
  199. package/src/navigation/stepper/stepper.stories.js +35 -0
  200. package/src/navigation/stepper/style.css +49 -0
  201. package/src/navigation/stepper/template.js +61 -0
  202. package/src/navigation/tabs/index.js +1 -0
  203. package/src/navigation/tabs/style.css +35 -0
  204. package/src/navigation/tabs/tabs.stories.js +40 -0
  205. package/src/navigation/tabs/template.js +79 -0
  206. package/src/overview.mdx +39 -0
  207. package/src/stories/notifyStory.js +22 -25
  208. package/src/styles/base.css +2 -0
  209. package/src/styles/reset.css +15 -0
  210. package/src/{themes → styles/themes}/bootstrap.css +2 -0
  211. package/src/{themes → styles/themes}/inglorious.css +9 -1
  212. package/src/{themes → styles/themes}/material.css +2 -0
  213. package/src/{tokens/index.css → styles/tokens.css} +9 -0
  214. package/src/surfaces/accordion/accordion.stories.js +60 -0
  215. package/src/surfaces/accordion/index.js +1 -0
  216. package/src/surfaces/accordion/style.css +64 -0
  217. package/src/surfaces/accordion/template.js +85 -0
  218. package/src/surfaces/app-bar/app-bar.stories.js +109 -0
  219. package/src/surfaces/app-bar/index.js +3 -0
  220. package/src/surfaces/app-bar/style.css +109 -0
  221. package/src/surfaces/app-bar/template.js +78 -0
  222. package/src/surfaces/card/card.stories.js +108 -0
  223. package/src/surfaces/card/index.js +1 -0
  224. package/src/surfaces/card/style.css +107 -0
  225. package/src/surfaces/card/template.js +163 -0
  226. package/src/surfaces/paper/index.js +3 -0
  227. package/src/surfaces/paper/paper.stories.js +97 -0
  228. package/src/surfaces/paper/style.css +73 -0
  229. package/src/surfaces/paper/template.js +76 -0
  230. package/src/surfaces/surfaces.css +4 -0
  231. package/types/controls/button-group.d.ts +8 -7
  232. package/types/controls/button.d.ts +10 -7
  233. package/types/controls/checkbox.d.ts +8 -6
  234. package/types/controls/combobox.d.ts +66 -0
  235. package/types/controls/fab.d.ts +6 -5
  236. package/types/controls/icon-button.d.ts +8 -7
  237. package/types/controls/input.d.ts +18 -11
  238. package/types/controls/radio-group.d.ts +7 -5
  239. package/types/controls/rating.d.ts +6 -5
  240. package/types/controls/select.d.ts +11 -34
  241. package/types/controls/slider.d.ts +8 -6
  242. package/types/controls/switch.d.ts +7 -5
  243. package/types/data-display/avatar.d.ts +30 -0
  244. package/types/data-display/badge.d.ts +20 -0
  245. package/types/data-display/chip.d.ts +25 -0
  246. package/types/data-display/data-grid.d.ts +151 -0
  247. package/types/data-display/divider.d.ts +14 -0
  248. package/types/data-display/icon.d.ts +16 -0
  249. package/types/data-display/list.d.ts +66 -0
  250. package/types/data-display/material-icon.d.ts +15 -0
  251. package/types/data-display/table.d.ts +45 -0
  252. package/types/data-display/tooltip.d.ts +20 -0
  253. package/types/data-display/typography.d.ts +28 -0
  254. package/types/data-display/virtual-list.d.ts +94 -0
  255. package/types/feedback/alert.d.ts +22 -0
  256. package/types/feedback/backdrop.d.ts +17 -0
  257. package/types/feedback/dialog.d.ts +21 -0
  258. package/types/feedback/progress.d.ts +18 -0
  259. package/types/feedback/skeleton.d.ts +18 -0
  260. package/types/feedback/snackbar.d.ts +19 -0
  261. package/types/index.d.ts +92 -14
  262. package/types/layout/container.d.ts +28 -0
  263. package/types/layout/flex.d.ts +16 -5
  264. package/types/layout/grid.d.ts +15 -4
  265. package/types/navigation/bottom-navigation.d.ts +33 -0
  266. package/types/navigation/breadcrumbs.d.ts +29 -0
  267. package/types/navigation/drawer.d.ts +23 -0
  268. package/types/navigation/link.d.ts +22 -0
  269. package/types/navigation/menu.d.ts +32 -0
  270. package/types/navigation/pagination.d.ts +50 -0
  271. package/types/navigation/speed-dial.d.ts +35 -0
  272. package/types/navigation/stepper.d.ts +26 -0
  273. package/types/navigation/tabs.d.ts +31 -0
  274. package/types/surfaces/accordion.d.ts +32 -0
  275. package/types/surfaces/app-bar.d.ts +25 -0
  276. package/types/surfaces/card.d.ts +39 -0
  277. package/types/surfaces/paper.d.ts +28 -0
  278. package/src/shared/withRenderValidation.js +0 -19
  279. package/src/widgets/card/card.stories.js +0 -135
  280. package/src/widgets/card/index.js +0 -4
  281. package/src/widgets/card/style.css +0 -53
  282. package/src/widgets/card/template.js +0 -97
  283. package/types/widgets/card.d.ts +0 -21
@@ -0,0 +1,119 @@
1
+ .iw-list {
2
+ margin: 0;
3
+ padding: 0;
4
+ color: var(--iw-color-text);
5
+ list-style: none;
6
+
7
+ &.iw-list-padding-sm {
8
+ padding: var(--iw-space-2);
9
+ }
10
+
11
+ &.iw-list-padding-md {
12
+ padding: var(--iw-space-4);
13
+ }
14
+
15
+ &.iw-list-padding-lg {
16
+ padding: var(--iw-space-6);
17
+ }
18
+
19
+ &.iw-list-padding-xl {
20
+ padding: var(--iw-space-8);
21
+ }
22
+
23
+ &.iw-list-dense {
24
+ .iw-list-item {
25
+ padding-block: var(--iw-space-2);
26
+ }
27
+ }
28
+
29
+ &.iw-list-divided {
30
+ .iw-list-divider {
31
+ display: block;
32
+ }
33
+ }
34
+ }
35
+
36
+ .iw-list-item {
37
+ padding: var(--iw-space-3);
38
+ border-radius: var(--iw-radius-sm);
39
+ transition:
40
+ background-color 0.15s ease,
41
+ color 0.15s ease;
42
+ }
43
+
44
+ .iw-list-item-inset .iw-list-item-content {
45
+ margin-left: calc(var(--iw-space-3) + var(--iw-list-icon-size, 1.25rem));
46
+ }
47
+
48
+ .iw-list-title {
49
+ padding: var(--iw-space-3);
50
+ font-size: var(--iw-font-size-xs);
51
+ font-weight: var(--iw-font-weight-semibold);
52
+ text-transform: uppercase;
53
+ color: var(--iw-color-text-muted, var(--iw-color-text));
54
+ }
55
+
56
+ .iw-list-item-action {
57
+ display: inline-flex;
58
+ align-items: center;
59
+ gap: var(--iw-space-2);
60
+ }
61
+
62
+ .iw-list-item-trailing {
63
+ margin-left: auto;
64
+ display: inline-flex;
65
+ align-items: center;
66
+ gap: var(--iw-space-2);
67
+ }
68
+
69
+ .iw-list-item-toggle {
70
+ .iw-list-item-caret {
71
+ transition: transform 0.15s ease;
72
+ }
73
+
74
+ &[aria-expanded] .iw-list-item-caret {
75
+ transform: rotate(90deg);
76
+ }
77
+ }
78
+
79
+ .iw-list-item-primary {
80
+ font-weight: 500;
81
+ }
82
+
83
+ .iw-list-item-secondary {
84
+ font-size: 0.9em;
85
+ color: var(--iw-color-text-muted, var(--iw-color-text));
86
+ }
87
+
88
+ .iw-list-item-clickable {
89
+ cursor: pointer;
90
+ }
91
+
92
+ .iw-list-item-clickable:hover {
93
+ background-color: var(--iw-color-surface, rgba(0, 0, 0, 0.05));
94
+ }
95
+
96
+ .iw-list-item-selected {
97
+ background-color: var(--iw-color-surface-active, rgba(0, 0, 0, 0.08));
98
+
99
+ .iw-list-item-icon {
100
+ color: var(--iw-color-text);
101
+ }
102
+ }
103
+
104
+ .iw-list-item-disabled {
105
+ opacity: 0.6;
106
+ cursor: not-allowed;
107
+ }
108
+
109
+ .iw-list-divider {
110
+ display: none;
111
+ height: 1px;
112
+ background: var(--iw-color-border);
113
+ margin: 0 var(--iw-space-3);
114
+ }
115
+
116
+ .iw-list-nested {
117
+ margin-top: var(--iw-space-1);
118
+ padding-left: var(--iw-space-4);
119
+ }
@@ -0,0 +1,302 @@
1
+ /**
2
+ * @typedef {import('../../../types/data-display/list').ListProps} ListProps
3
+ * @typedef {import('../../../types/data-display/list').ListItem} ListItem
4
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
5
+ * @typedef {{
6
+ * id: string | number,
7
+ * primary: TemplateResult | string | number,
8
+ * secondary?: TemplateResult | string | number,
9
+ * icon?: TemplateResult | string | number,
10
+ * action?: TemplateResult | string | number,
11
+ * isExpanded?: boolean,
12
+ * onToggle?: (item: ListItem, path: number[]) => void,
13
+ * isDisabled?: boolean,
14
+ * isSelected?: boolean,
15
+ * hasDivider?: boolean,
16
+ * onClick?: (item: ListItem, path: number[]) => void,
17
+ * children?: ListItem[] | TemplateResult | string | number | null,
18
+ * raw?: ListItem,
19
+ * }} ListItemMeta
20
+ */
21
+
22
+ import { classMap, html, ref, repeat, when } from "@inglorious/web"
23
+
24
+ import { iconButton } from "../../controls/icon-button"
25
+ import { flex } from "../../layout/flex"
26
+ import { applyElementProps } from "../../shared/applyElementProps.js"
27
+
28
+ const PRETTY_INDEX = 1
29
+
30
+ export const list = {
31
+ /**
32
+ * @param {ListProps} props
33
+ * @returns {TemplateResult}
34
+ */
35
+ render(props) {
36
+ const {
37
+ type, // eslint-disable-line no-unused-vars
38
+ items = [],
39
+ children,
40
+ isOrdered = false,
41
+ isDense = false,
42
+ isDivided = false,
43
+ isInset = false,
44
+ padding = "none",
45
+ path = [],
46
+ className = "",
47
+ ...rest
48
+ } = props
49
+
50
+ const extraClasses = Object.fromEntries(
51
+ className
52
+ .split(/\s+/)
53
+ .filter(Boolean)
54
+ .map((name) => [name, true]),
55
+ )
56
+
57
+ const classes = {
58
+ "iw-list": true,
59
+ "iw-list-ordered": isOrdered,
60
+ "iw-list-dense": isDense,
61
+ "iw-list-divided": isDivided,
62
+ "iw-list-inset": isInset,
63
+ [`iw-list-padding-${padding}`]: padding !== "none",
64
+ ...extraClasses,
65
+ }
66
+
67
+ const content =
68
+ children ??
69
+ repeat(
70
+ items,
71
+ (item, index) => item?.id ?? `${index}`,
72
+ (item, index) => {
73
+ const meta = getItemMeta(item, index)
74
+ const shouldDivide =
75
+ (isDivided || meta.hasDivider) && index < items.length - 1
76
+
77
+ return html`${this.renderItem(props, {
78
+ item,
79
+ meta,
80
+ index,
81
+ path: [...path, index],
82
+ })}${shouldDivide
83
+ ? html`<li class="iw-list-divider" role="separator"></li>`
84
+ : null}`
85
+ },
86
+ )
87
+
88
+ if (isOrdered) {
89
+ return html`
90
+ <ol
91
+ class=${classMap(classes)}
92
+ ${ref((el) => applyElementProps(el, rest))}
93
+ >
94
+ ${content}
95
+ </ol>
96
+ `
97
+ }
98
+
99
+ return html`
100
+ <ul
101
+ class=${classMap(classes)}
102
+ ${ref((el) => applyElementProps(el, rest))}
103
+ >
104
+ ${content}
105
+ </ul>
106
+ `
107
+ },
108
+
109
+ /**
110
+ * @param {ListProps} props
111
+ * @param {{
112
+ * item: ListItem,
113
+ * meta: ListItemMeta,
114
+ * index: number,
115
+ * path: number[]
116
+ * }} payload
117
+ * @returns {TemplateResult}
118
+ */
119
+ renderItem(props, { item, meta, path }) {
120
+ const {
121
+ primary,
122
+ secondary,
123
+ icon,
124
+ isDisabled,
125
+ isSelected,
126
+ onClick,
127
+ raw,
128
+ children,
129
+ action,
130
+ isExpanded,
131
+ onToggle,
132
+ } = meta
133
+
134
+ if (meta.title) {
135
+ return html`<li class="iw-list-title">${meta.title}</li>`
136
+ }
137
+
138
+ const isClickable = !!props.onItemClick || !!onClick
139
+ const hasChildren = Array.isArray(children) && children.length > 0
140
+ const hasAction = !!action
141
+
142
+ const listItemClassName = [
143
+ "iw-list-item",
144
+ isClickable && "iw-list-item-clickable",
145
+ isDisabled && "iw-list-item-disabled",
146
+ isSelected && "iw-list-item-selected",
147
+ props.isInset && !icon && "iw-list-item-inset",
148
+ ]
149
+ .filter(Boolean)
150
+ .join(" ")
151
+
152
+ return flex.render({
153
+ element: "li",
154
+ padding: "sm",
155
+ direction: "column",
156
+ className: listItemClassName,
157
+ onClick: (event) => {
158
+ event.stopPropagation()
159
+ if (isDisabled) return
160
+ onClick?.(raw ?? item, path)
161
+ props.onItemClick?.(raw ?? item, path)
162
+ },
163
+ children: [
164
+ flex.render({
165
+ align: "center",
166
+ gap: "sm",
167
+ children: [
168
+ when(icon, () =>
169
+ iconButton.render({
170
+ icon,
171
+ size: "sm",
172
+ color: "secondary",
173
+ variant: "ghost",
174
+ shape: "square",
175
+ className: "iw-list-item-icon",
176
+ }),
177
+ ),
178
+ flex.render({
179
+ direction: "column",
180
+ gap: "sm",
181
+ className: "iw-list-item-content",
182
+ children: [
183
+ html`<div class="iw-list-item-primary">${primary}</div>`,
184
+ when(
185
+ secondary,
186
+ () =>
187
+ html`<div class="iw-list-item-secondary">
188
+ ${secondary}
189
+ </div>`,
190
+ ),
191
+ ],
192
+ }),
193
+ when(
194
+ hasChildren || hasAction,
195
+ () =>
196
+ html`<span class="iw-list-item-trailing">
197
+ ${when(hasChildren, () =>
198
+ iconButton.render({
199
+ variant: "ghost",
200
+ color: "secondary",
201
+ size: "sm",
202
+ shape: "square",
203
+ className: "iw-list-item-toggle",
204
+ isDisabled,
205
+ ariaLabel: "Toggle section",
206
+ "aria-expanded": isExpanded,
207
+ onClick: (event) => {
208
+ event.stopPropagation()
209
+ if (isDisabled) return
210
+ onToggle?.(raw ?? item, path)
211
+ props.onItemToggle?.(raw ?? item, path)
212
+ },
213
+ icon: html`<span
214
+ class="iw-list-item-caret"
215
+ aria-hidden="true"
216
+ >❯</span
217
+ >`,
218
+ label: "",
219
+ }),
220
+ )}
221
+ ${when(
222
+ action,
223
+ () =>
224
+ html`<span
225
+ class="iw-list-item-action"
226
+ @click=${(event) => event.stopPropagation()}
227
+ >
228
+ ${action}
229
+ </span>`,
230
+ )}
231
+ </span>`,
232
+ ),
233
+ ],
234
+ }),
235
+ when(hasChildren, () =>
236
+ when(isExpanded, () =>
237
+ this.render({
238
+ ...props,
239
+ items: children,
240
+ className: `${props.className ?? ""} iw-list-nested`.trim(),
241
+ path,
242
+ }),
243
+ ),
244
+ ),
245
+ ],
246
+ })
247
+ },
248
+ }
249
+
250
+ function getItemMeta(item, index) {
251
+ if (!item || typeof item !== "object") {
252
+ return {
253
+ id: `${index}`,
254
+ primary: item ?? `${index + PRETTY_INDEX}`,
255
+ }
256
+ }
257
+
258
+ const {
259
+ id,
260
+ label,
261
+ primary,
262
+ secondary,
263
+ icon,
264
+ title,
265
+ isDisabled = false,
266
+ isSelected = false,
267
+ hasDivider = false,
268
+ onClick,
269
+ children,
270
+ action,
271
+ isExpanded = false,
272
+ onToggle,
273
+ } = item
274
+
275
+ const hasNestedChildren = Array.isArray(children)
276
+ const normalizedChildren = hasNestedChildren
277
+ ? children
278
+ : typeof children === "string" || typeof children === "number"
279
+ ? children
280
+ : null
281
+
282
+ return {
283
+ id: id ?? `${index}`,
284
+ primary:
285
+ primary ??
286
+ label ??
287
+ (hasNestedChildren ? "" : normalizedChildren) ??
288
+ `${index + PRETTY_INDEX}`,
289
+ secondary,
290
+ icon,
291
+ title,
292
+ isDisabled,
293
+ isSelected,
294
+ hasDivider,
295
+ onClick,
296
+ children: hasNestedChildren ? children : normalizedChildren,
297
+ action,
298
+ isExpanded,
299
+ onToggle,
300
+ raw: item,
301
+ }
302
+ }
@@ -0,0 +1,3 @@
1
+ import * as renderers from "./template.js"
2
+
3
+ export const materialIcon = { ...renderers }
@@ -0,0 +1,99 @@
1
+ import { html, repeat } from "@inglorious/web"
2
+
3
+ import { materialIcon } from "."
4
+
5
+ const materialIcons = [
6
+ "search",
7
+ "home",
8
+ "menu",
9
+ "settings",
10
+ "favorite",
11
+ "visibility",
12
+ "notifications",
13
+ "shopping_cart",
14
+ "person",
15
+ "calendar_today",
16
+ "mail",
17
+ "chat",
18
+ "help",
19
+ "info",
20
+ "warning",
21
+ "check_circle",
22
+ "cancel",
23
+ "delete",
24
+ "download",
25
+ "upload",
26
+ "lock",
27
+ "star",
28
+ "play_arrow",
29
+ "pause",
30
+ "stop",
31
+ "cloud",
32
+ "camera_alt",
33
+ "bolt",
34
+ "palette",
35
+ "code",
36
+ "analytics",
37
+ "schedule",
38
+ ]
39
+
40
+ export default {
41
+ title: "Data Display/Material Icon",
42
+ tags: ["autodocs"],
43
+ argTypes: {
44
+ size: {
45
+ control: "select",
46
+ options: ["sm", "md", "lg"],
47
+ },
48
+ isFilled: {
49
+ control: "boolean",
50
+ },
51
+ columns: {
52
+ control: "number",
53
+ },
54
+ },
55
+ parameters: {
56
+ docs: {
57
+ description: {
58
+ component:
59
+ "Material Symbols icon set (requires Material Symbols font to be loaded).",
60
+ },
61
+ },
62
+ },
63
+ }
64
+
65
+ export const Gallery = {
66
+ args: {
67
+ size: "lg",
68
+ isFilled: false,
69
+ columns: 6,
70
+ },
71
+ render: (args) => {
72
+ const columns = Math.max(4, Number(args.columns ?? 6))
73
+ const size = args.size ?? "lg"
74
+ const isFilled = Boolean(args.isFilled)
75
+
76
+ return html`
77
+ <div
78
+ style=${[
79
+ "display: grid",
80
+ `grid-template-columns: repeat(${columns}, minmax(0, 1fr))`,
81
+ "gap: 1rem",
82
+ "align-items: center",
83
+ "justify-items: center",
84
+ ].join("; ")}
85
+ >
86
+ ${repeat(
87
+ materialIcons,
88
+ (name) => name,
89
+ (name) =>
90
+ materialIcon.render({
91
+ name,
92
+ size,
93
+ isFilled,
94
+ }),
95
+ )}
96
+ </div>
97
+ `
98
+ },
99
+ }
@@ -0,0 +1,27 @@
1
+ .iw-material-icon {
2
+ font-family: "Material Symbols Outlined", "Material Symbols";
3
+ font-variation-settings:
4
+ "FILL" 0,
5
+ "wght" 400,
6
+ "GRAD" 0,
7
+ "opsz" 24;
8
+ line-height: 1;
9
+ display: inline-flex;
10
+ cursor: pointer;
11
+
12
+ &.iw-material-icon-filled {
13
+ font-variation-settings:
14
+ "FILL" 1,
15
+ "wght" 400,
16
+ "GRAD" 0,
17
+ "opsz" 24;
18
+ }
19
+
20
+ &.iw-material-icon-sm {
21
+ font-size: 0.875rem;
22
+ }
23
+
24
+ &.iw-material-icon-lg {
25
+ font-size: 1.5rem;
26
+ }
27
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @typedef {import('../../../types/data-display/material-icon').MaterialIconProps} MaterialIconProps
3
+ */
4
+
5
+ import { classMap, html } from "@inglorious/web"
6
+
7
+ export function render(props) {
8
+ const { name = "help", size = "md", isFilled = true, onClick } = props
9
+
10
+ return html`<span
11
+ class=${classMap({
12
+ "iw-material-icon": true,
13
+ "material-symbols-outlined": true,
14
+ "iw-material-icon-filled": isFilled,
15
+ [`iw-material-icon-${size}`]: size !== "md",
16
+ })}
17
+ aria-hidden="true"
18
+ @click=${onClick}
19
+ >${name}</span
20
+ >`
21
+ }
@@ -0,0 +1 @@
1
+ export { table } from "./template.js"
@@ -0,0 +1,42 @@
1
+ .iw-table-wrap {
2
+ width: 100%;
3
+ overflow-x: auto;
4
+ }
5
+
6
+ .iw-table {
7
+ width: 100%;
8
+ min-width: max-content;
9
+ border-collapse: collapse;
10
+ border: 1px solid var(--iw-color-border);
11
+ background: var(--iw-color-surface);
12
+ color: var(--iw-color-text);
13
+
14
+ &.iw-table-full-width {
15
+ width: 100%;
16
+ }
17
+
18
+ &.iw-table-striped {
19
+ .iw-table-row-even {
20
+ background: color-mix(
21
+ in srgb,
22
+ var(--iw-color-surface) 88%,
23
+ var(--iw-color-bg)
24
+ );
25
+ }
26
+ }
27
+ }
28
+
29
+ .iw-table-header-cell,
30
+ .iw-table-cell {
31
+ padding: var(--iw-space-3) var(--iw-space-4);
32
+ text-align: left;
33
+ border-bottom: 1px solid var(--iw-color-border);
34
+ }
35
+
36
+ .iw-table-header-cell {
37
+ font-weight: var(--iw-font-weight-semibold);
38
+ }
39
+
40
+ .iw-table-cell-number {
41
+ text-align: right;
42
+ }
@@ -0,0 +1,40 @@
1
+ import { createRender } from "../../stories/notifyStory.js"
2
+ import { table } from "."
3
+
4
+ export default {
5
+ title: "Data Display/Table",
6
+ tags: ["autodocs"],
7
+ render: createRender(table),
8
+ argTypes: {
9
+ columns: { control: "object", description: "Column definitions." },
10
+ rows: { control: "object", description: "Row records." },
11
+ isFullWidth: { control: "boolean", description: "Stretch table width." },
12
+ isStriped: { control: "boolean", description: "Enable zebra rows." },
13
+ onRowClick: { action: "onRowClick" },
14
+ },
15
+ parameters: {
16
+ docs: {
17
+ description: {
18
+ component:
19
+ "Base table primitive with overridable `renderHeaderCell`, `renderRow`, and `renderCell` sub-renders.",
20
+ },
21
+ },
22
+ },
23
+ }
24
+
25
+ export const Default = {
26
+ args: {
27
+ columns: [
28
+ { id: "name", label: "Name" },
29
+ { id: "role", label: "Role" },
30
+ { id: "score", label: "Score", align: "right" },
31
+ ],
32
+ rows: [
33
+ { id: "u1", name: "Ada", role: "Maintainer", score: 98 },
34
+ { id: "u2", name: "Max", role: "Contributor", score: 87 },
35
+ { id: "u3", name: "Lin", role: "Designer", score: 91 },
36
+ ],
37
+ isFullWidth: true,
38
+ isStriped: true,
39
+ },
40
+ }