@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.
Files changed (283) hide show
  1. package/README.md +45 -0
  2. package/package.json +190 -15
  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,114 @@
1
+ /**
2
+ * @typedef {import('../../../types/data-display/table').TableProps} TableProps
3
+ * @typedef {import('../../../types/data-display/table').TableColumn} TableColumn
4
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
5
+ */
6
+
7
+ import { classMap, html, ref, repeat } from "@inglorious/web"
8
+
9
+ import { applyElementProps } from "../../shared/applyElementProps.js"
10
+
11
+ const EVEN_ROW_DIVISOR = 2
12
+ const STRIPED_OFFSET = 1
13
+
14
+ export const table = {
15
+ /**
16
+ * @param {TableProps} props
17
+ * @returns {TemplateResult}
18
+ */
19
+ render(props) {
20
+ const {
21
+ columns = [],
22
+ rows = [],
23
+ isFullWidth = false,
24
+ isStriped = false,
25
+ onRowClick,
26
+ ...rest
27
+ } = props
28
+
29
+ const classes = {
30
+ "iw-table": true,
31
+ "iw-table-full-width": isFullWidth,
32
+ "iw-table-striped": isStriped,
33
+ }
34
+
35
+ return html`
36
+ <div class="iw-table-wrap">
37
+ <table
38
+ class=${classMap(classes)}
39
+ ${ref((el) => applyElementProps(el, rest))}
40
+ >
41
+ <thead>
42
+ <tr>
43
+ ${repeat(
44
+ columns,
45
+ (column, index) => column.id ?? `${index}`,
46
+ (column, index) =>
47
+ this.renderHeaderCell(props, { column, index }),
48
+ )}
49
+ </tr>
50
+ </thead>
51
+ <tbody>
52
+ ${repeat(
53
+ rows,
54
+ (row, index) => row?.id ?? `${index}`,
55
+ (row, index) => this.renderRow(props, { row, index, onRowClick }),
56
+ )}
57
+ </tbody>
58
+ </table>
59
+ </div>
60
+ `
61
+ },
62
+
63
+ /**
64
+ * @param {TableProps} _props
65
+ * @param {{column: TableColumn, index: number}} payload
66
+ * @returns {TemplateResult}
67
+ */
68
+ renderHeaderCell(_props, { column }) {
69
+ const title = column.label ?? column.title ?? column.id
70
+ return html`<th class="iw-table-header-cell">${title}</th>`
71
+ },
72
+
73
+ /**
74
+ * @param {TableProps} props
75
+ * @param {{row: Record<string, unknown>, index: number}} payload
76
+ * @returns {TemplateResult}
77
+ */
78
+ renderRow(props, { row, index, onRowClick }) {
79
+ const columns = props.columns ?? []
80
+
81
+ return html`<tr
82
+ class=${classMap({
83
+ "iw-table-row": true,
84
+ "iw-table-row-even": index % EVEN_ROW_DIVISOR === STRIPED_OFFSET,
85
+ })}
86
+ @click=${() => onRowClick(row)}
87
+ >
88
+ ${repeat(
89
+ columns,
90
+ (column, columnIndex) => column.id ?? `${columnIndex}`,
91
+ (column, columnIndex) =>
92
+ this.renderCell(props, { column, row, index, columnIndex }),
93
+ )}
94
+ </tr>`
95
+ },
96
+
97
+ /**
98
+ * @param {TableProps} _props
99
+ * @param {{column: TableColumn, row: Record<string, unknown>}} payload
100
+ * @returns {TemplateResult}
101
+ */
102
+ renderCell(_props, { column, row }) {
103
+ const value = row?.[column.id]
104
+
105
+ return html`<td
106
+ class=${classMap({
107
+ "iw-table-cell": true,
108
+ "iw-table-cell-number": column.align === "right",
109
+ })}
110
+ >
111
+ ${value}
112
+ </td>`
113
+ },
114
+ }
@@ -0,0 +1,3 @@
1
+ import * as renderers from "./template.js"
2
+
3
+ export const tooltip = { ...renderers }
@@ -0,0 +1,57 @@
1
+ .iw-tooltip {
2
+ position: relative;
3
+ display: inline-flex;
4
+ align-items: center;
5
+
6
+ .iw-tooltip-bubble {
7
+ position: absolute;
8
+ z-index: var(--iw-z-tooltip);
9
+ opacity: 0;
10
+ pointer-events: none;
11
+ background: var(--iw-color-bg-elevated, var(--iw-color-surface));
12
+ color: var(--iw-color-text);
13
+ border: 1px solid var(--iw-color-border);
14
+ border-radius: var(--iw-radius-sm);
15
+ padding: var(--iw-space-2) var(--iw-space-3);
16
+ box-shadow: var(--iw-shadow-md);
17
+ transition: opacity 150ms ease;
18
+ left: 50%;
19
+ bottom: calc(100% + var(--iw-space-2));
20
+ transform: translateX(-50%);
21
+ white-space: normal;
22
+ }
23
+
24
+ &.iw-tooltip-size-sm .iw-tooltip-bubble {
25
+ font-size: var(--iw-font-size-sm);
26
+ padding: var(--iw-space-1) var(--iw-space-2);
27
+ }
28
+
29
+ &.iw-tooltip-size-lg .iw-tooltip-bubble {
30
+ font-size: var(--iw-font-size-lg);
31
+ padding: var(--iw-space-3) var(--iw-space-4);
32
+ }
33
+
34
+ &:hover .iw-tooltip-bubble,
35
+ &:focus-within .iw-tooltip-bubble,
36
+ &.iw-tooltip-open .iw-tooltip-bubble {
37
+ opacity: 1;
38
+ }
39
+
40
+ &.iw-tooltip-bottom .iw-tooltip-bubble {
41
+ top: calc(100% + var(--iw-space-2));
42
+ bottom: auto;
43
+ }
44
+
45
+ &.iw-tooltip-left .iw-tooltip-bubble {
46
+ left: auto;
47
+ right: calc(100% + var(--iw-space-2));
48
+ bottom: 50%;
49
+ transform: translateY(50%);
50
+ }
51
+
52
+ &.iw-tooltip-right .iw-tooltip-bubble {
53
+ left: calc(100% + var(--iw-space-2));
54
+ bottom: 50%;
55
+ transform: translateY(50%);
56
+ }
57
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @typedef {import('../../../types/data-display/tooltip').TooltipProps} TooltipProps
3
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
4
+ */
5
+
6
+ import { classMap, html, ref } from "@inglorious/web"
7
+
8
+ import { applyElementProps } from "../../shared/applyElementProps.js"
9
+
10
+ /**
11
+ * @param {TooltipProps} props
12
+ * @returns {TemplateResult}
13
+ */
14
+ export function render(props) {
15
+ const {
16
+ children,
17
+ content,
18
+ position = "top",
19
+ size = "md",
20
+ isOpen = false,
21
+ maxWidth = "20rem",
22
+ className = "",
23
+ onClick,
24
+ ...rest
25
+ } = props
26
+
27
+ const extraClasses = Object.fromEntries(
28
+ className
29
+ .split(/\s+/)
30
+ .filter(Boolean)
31
+ .map((name) => [name, true]),
32
+ )
33
+
34
+ const classes = {
35
+ "iw-tooltip": true,
36
+ "iw-tooltip-open": isOpen,
37
+ [`iw-tooltip-${position}`]: position !== "top",
38
+ [`iw-tooltip-size-${size}`]: size !== "md",
39
+ ...extraClasses,
40
+ }
41
+
42
+ return html`
43
+ <span
44
+ class=${classMap(classes)}
45
+ ${ref((el) => applyElementProps(el, rest))}
46
+ @click=${onClick}
47
+ >
48
+ <span class="iw-tooltip-trigger">${children ?? "?"}</span>
49
+ <span
50
+ class="iw-tooltip-bubble"
51
+ role="tooltip"
52
+ style=${`max-width: ${maxWidth};`}
53
+ >
54
+ ${content}
55
+ </span>
56
+ </span>
57
+ `
58
+ }
@@ -0,0 +1,44 @@
1
+ import { html } from "@inglorious/web"
2
+
3
+ import { createRender } from "../../stories/notifyStory.js"
4
+ import { tooltip } from "."
5
+
6
+ export default {
7
+ title: "Data Display/Tooltip",
8
+ tags: ["autodocs"],
9
+ render: createRender(tooltip),
10
+ argTypes: {
11
+ content: { control: "text", description: "Tooltip text." },
12
+ position: {
13
+ control: "select",
14
+ options: ["top", "right", "bottom", "left"],
15
+ description: "Tooltip placement.",
16
+ },
17
+ size: {
18
+ control: "select",
19
+ options: ["sm", "md", "lg"],
20
+ description: "Tooltip size scale.",
21
+ },
22
+ isOpen: { control: "boolean", description: "Force tooltip visible." },
23
+ maxWidth: { control: "text", description: "Max width CSS value." },
24
+ onClick: { action: "onClick" },
25
+ },
26
+ parameters: {
27
+ docs: {
28
+ description: {
29
+ component: "Hover/focus tooltip primitive with configurable placement.",
30
+ },
31
+ },
32
+ },
33
+ }
34
+
35
+ export const Default = {
36
+ args: {
37
+ children: html`<button type="button">Hover me</button>`,
38
+ content: "Tooltip content",
39
+ position: "bottom",
40
+ size: "md",
41
+ isOpen: false,
42
+ maxWidth: "20rem",
43
+ },
44
+ }
@@ -0,0 +1,3 @@
1
+ import * as renderers from "./template.js"
2
+
3
+ export const typography = { ...renderers }
@@ -0,0 +1,49 @@
1
+ .iw-typography {
2
+ margin: 0;
3
+ color: var(--iw-color-text);
4
+ line-height: 1.45;
5
+
6
+ &.iw-typography-h1 {
7
+ font-size: var(--iw-font-size-4xl);
8
+ line-height: 1.1;
9
+ }
10
+
11
+ &.iw-typography-h2 {
12
+ font-size: var(--iw-font-size-3xl);
13
+ line-height: 1.15;
14
+ }
15
+
16
+ &.iw-typography-h3 {
17
+ font-size: var(--iw-font-size-2xl);
18
+ line-height: 1.2;
19
+ }
20
+
21
+ &.iw-typography-caption {
22
+ font-size: var(--iw-font-size-sm);
23
+ opacity: 0.85;
24
+ }
25
+
26
+ &.iw-typography-overline {
27
+ font-size: var(--iw-font-size-xs);
28
+ text-transform: uppercase;
29
+ letter-spacing: 0.08em;
30
+ }
31
+
32
+ &.iw-typography-align-center {
33
+ text-align: center;
34
+ }
35
+
36
+ &.iw-typography-align-right {
37
+ text-align: right;
38
+ }
39
+
40
+ &.iw-typography-nowrap {
41
+ white-space: nowrap;
42
+ overflow: hidden;
43
+ text-overflow: ellipsis;
44
+ }
45
+
46
+ &.iw-typography-gutter-bottom {
47
+ margin-bottom: var(--iw-space-3);
48
+ }
49
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * @typedef {import('../../../types/data-display/typography').TypographyProps} TypographyProps
3
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
4
+ */
5
+
6
+ import { classMap, html, ref } from "@inglorious/web"
7
+
8
+ import { applyElementProps } from "../../shared/applyElementProps.js"
9
+
10
+ /**
11
+ * @param {TypographyProps} props
12
+ * @returns {TemplateResult}
13
+ */
14
+ export function render(props) {
15
+ const {
16
+ children,
17
+ variant = "body",
18
+ align = "left",
19
+ weight,
20
+ color,
21
+ isNoWrap = false,
22
+ hasGutterBottom = false,
23
+ className = "",
24
+ ...rest
25
+ } = props
26
+
27
+ const extraClasses = Object.fromEntries(
28
+ className
29
+ .split(/\s+/)
30
+ .filter(Boolean)
31
+ .map((name) => [name, true]),
32
+ )
33
+
34
+ const classes = {
35
+ "iw-typography": true,
36
+ [`iw-typography-${variant}`]: variant !== "body",
37
+ [`iw-typography-align-${align}`]: align !== "left",
38
+ "iw-typography-nowrap": isNoWrap,
39
+ "iw-typography-gutter-bottom": hasGutterBottom,
40
+ ...extraClasses,
41
+ }
42
+
43
+ return renderTag(variant, classes, children, { weight, color, rest })
44
+ }
45
+
46
+ function renderTag(variant, classes, children, options) {
47
+ const { weight, color, rest } = options
48
+
49
+ if (variant === "h1") {
50
+ return html`<h1
51
+ class=${classMap(classes)}
52
+ style=${buildStyle(weight, color)}
53
+ ${ref((el) => applyElementProps(el, rest))}
54
+ >
55
+ ${children}
56
+ </h1>`
57
+ }
58
+
59
+ if (variant === "h2") {
60
+ return html`<h2
61
+ class=${classMap(classes)}
62
+ style=${buildStyle(weight, color)}
63
+ ${ref((el) => applyElementProps(el, rest))}
64
+ >
65
+ ${children}
66
+ </h2>`
67
+ }
68
+
69
+ if (variant === "h3") {
70
+ return html`<h3
71
+ class=${classMap(classes)}
72
+ style=${buildStyle(weight, color)}
73
+ ${ref((el) => applyElementProps(el, rest))}
74
+ >
75
+ ${children}
76
+ </h3>`
77
+ }
78
+
79
+ if (variant === "caption" || variant === "overline") {
80
+ return html`<span
81
+ class=${classMap(classes)}
82
+ style=${buildStyle(weight, color)}
83
+ ${ref((el) => applyElementProps(el, rest))}
84
+ >
85
+ ${children}
86
+ </span>`
87
+ }
88
+
89
+ return html`<p
90
+ class=${classMap(classes)}
91
+ style=${buildStyle(weight, color)}
92
+ ${ref((el) => applyElementProps(el, rest))}
93
+ >
94
+ ${children}
95
+ </p>`
96
+ }
97
+
98
+ function buildStyle(weight, color) {
99
+ const parts = []
100
+
101
+ if (weight) {
102
+ parts.push(`font-weight: ${weight};`)
103
+ }
104
+
105
+ if (color) {
106
+ parts.push(`color: ${color};`)
107
+ }
108
+
109
+ return parts.join(" ")
110
+ }
@@ -0,0 +1,48 @@
1
+ import { createRender } from "../../stories/notifyStory.js"
2
+ import { typography } from "."
3
+
4
+ export default {
5
+ title: "Data Display/Typography",
6
+ tags: ["autodocs"],
7
+ render: createRender(typography),
8
+ argTypes: {
9
+ children: { control: "text", description: "Text content." },
10
+ variant: {
11
+ control: "select",
12
+ options: ["body", "h1", "h2", "h3", "caption", "overline"],
13
+ description: "Visual text variant.",
14
+ },
15
+ align: {
16
+ control: "select",
17
+ options: ["left", "center", "right"],
18
+ description: "Horizontal text alignment.",
19
+ },
20
+ weight: { control: "text", description: "Optional CSS font-weight value." },
21
+ color: { control: "text", description: "Optional CSS color value." },
22
+ isNoWrap: {
23
+ control: "boolean",
24
+ description: "Single-line ellipsis behavior.",
25
+ },
26
+ hasGutterBottom: {
27
+ control: "boolean",
28
+ description: "Add bottom spacing.",
29
+ },
30
+ },
31
+ parameters: {
32
+ docs: {
33
+ description: {
34
+ component: "Typography primitive for headings, body text, and labels.",
35
+ },
36
+ },
37
+ },
38
+ }
39
+
40
+ export const Default = {
41
+ args: {
42
+ children: "The quick brown fox jumps over the lazy dog.",
43
+ variant: "body",
44
+ align: "left",
45
+ isNoWrap: false,
46
+ hasGutterBottom: false,
47
+ },
48
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @typedef {import('../../../types/data-display/virtual-list').VirtualListEntity} VirtualListEntity
3
+ */
4
+
5
+ const LIST_START = 0
6
+
7
+ /**
8
+ * Initializes the virtual list entity with default state.
9
+ * @param {VirtualListEntity} entity
10
+ */
11
+ export function create(entity) {
12
+ resetList(entity)
13
+ }
14
+
15
+ /**
16
+ * Handles the scroll event to update the visible range.
17
+ * @param {VirtualListEntity} entity
18
+ * @param {HTMLElement} containerEl
19
+ */
20
+ export function scroll(entity, containerEl) {
21
+ const scrollTop = containerEl.scrollTop
22
+ const { items, bufferSize, itemHeight, estimatedHeight, viewportHeight } =
23
+ entity
24
+ const height = itemHeight || estimatedHeight
25
+
26
+ const start = Math.max(
27
+ LIST_START,
28
+ Math.floor(scrollTop / height) - bufferSize,
29
+ )
30
+ const visibleCount = Math.ceil(viewportHeight / height)
31
+ const end = Math.min(start + visibleCount + bufferSize, items.length)
32
+
33
+ if (entity.visibleRange.start === start && entity.visibleRange.end === end) {
34
+ return
35
+ }
36
+
37
+ entity.scrollTop = scrollTop
38
+ entity.visibleRange = { start, end }
39
+ }
40
+
41
+ /**
42
+ * Mounts the list, measuring the first item to determine item height.
43
+ * @param {VirtualListEntity} entity
44
+ * @param {HTMLElement} containerEl
45
+ */
46
+ export function mount(entity, containerEl) {
47
+ const firstItem = containerEl.querySelector("[data-index]")
48
+ if (!firstItem) return
49
+
50
+ entity.itemHeight = firstItem.offsetHeight
51
+ entity.visibleRange = {
52
+ start: 0,
53
+ end: Math.ceil(entity.viewportHeight / entity.itemHeight),
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Resets the list entity state.
59
+ * @param {VirtualListEntity} entity
60
+ */
61
+ function resetList(entity) {
62
+ entity.scrollTop = 0
63
+ entity.visibleRange ??= { start: 0, end: 20 }
64
+ entity.viewportHeight ??= 600
65
+ entity.bufferSize ??= 5
66
+ entity.itemHeight ??= null
67
+ entity.estimatedHeight ??= 50
68
+ }
@@ -0,0 +1,4 @@
1
+ import * as handlers from "./handlers.js"
2
+ import * as renderers from "./template.js"
3
+
4
+ export const virtualList = { ...handlers, ...renderers }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @typedef {import('../../../types/data-display/virtual-list').VirtualListEntity} VirtualListEntity
3
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
4
+ * @typedef {import('@inglorious/web').Api} Api
5
+ */
6
+
7
+ import { html, ref, repeat, styleMap } from "@inglorious/web"
8
+
9
+ const PRETTY_INDEX = 1
10
+
11
+ /**
12
+ * Renders the virtualized list component.
13
+ * @param {VirtualListEntity} entity The list entity state.
14
+ * @param {Api} api The API object.
15
+ * @returns {TemplateResult} The rendered list.
16
+ */
17
+ export function render(entity, api) {
18
+ const {
19
+ items,
20
+ visibleRange,
21
+ viewportHeight,
22
+ itemHeight,
23
+ estimatedHeight,
24
+ className,
25
+ } = entity
26
+ const type = api.getType(entity.type)
27
+
28
+ if (!items) {
29
+ console.warn(`virtual list entity ${entity.id} needs 'items'`)
30
+ return html``
31
+ }
32
+
33
+ if (!type.renderItem) {
34
+ console.warn(`type ${entity.type} needs 'renderItem' method`)
35
+ return html``
36
+ }
37
+
38
+ const visibleItems = items.slice(visibleRange.start, visibleRange.end)
39
+ const height = itemHeight || estimatedHeight
40
+ const totalHeight = items.length * height
41
+
42
+ return html`
43
+ <div
44
+ class=${className ?? ""}
45
+ style=${styleMap({ height: `${viewportHeight}px`, overflow: "auto" })}
46
+ @scroll=${(e) => api.notify(`#${entity.id}:scroll`, e.currentTarget)}
47
+ ${ref((el) => {
48
+ if (el && !itemHeight) {
49
+ queueMicrotask(() => {
50
+ api.notify(`#${entity.id}:mount`, el)
51
+ })
52
+ }
53
+ })}
54
+ >
55
+ <div
56
+ style=${styleMap({
57
+ height: `${totalHeight}px`,
58
+ position: "relative",
59
+ })}
60
+ >
61
+ ${repeat(
62
+ visibleItems,
63
+ (item) => item.id,
64
+ (item, index) => {
65
+ const absoluteIndex = visibleRange.start + index
66
+ const top = absoluteIndex * height
67
+
68
+ return html`
69
+ <div
70
+ style=${styleMap({
71
+ position: "absolute",
72
+ top: `${top}px`,
73
+ width: "100%",
74
+ })}
75
+ data-index=${absoluteIndex}
76
+ >
77
+ ${type.renderItem(entity, { item, index: absoluteIndex }, api)}
78
+ </div>
79
+ `
80
+ },
81
+ )}
82
+ </div>
83
+ </div>
84
+ `
85
+ }
86
+
87
+ /**
88
+ * Default item renderer.
89
+ * @param {VirtualListEntity} entity The list entity.
90
+ * @param {object} payload The payload for rendering the item.
91
+ * @param {any} payload.item The item data.
92
+ * @param {number} payload.index The item's absolute index in the full list.
93
+ * @param {Api} api The API object.
94
+ * @returns {TemplateResult} The rendered list item.
95
+ */
96
+ // eslint-disable-next-line no-unused-vars
97
+ export function renderItem(entity, { item, index }, api) {
98
+ return html`<div class="iw-list-item">
99
+ ${index + PRETTY_INDEX}. ${JSON.stringify(item)}
100
+ </div>`
101
+ }