@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
@@ -1,41 +1,46 @@
1
1
  /**
2
- * @typedef {import('../../../types/controls/radio-group').RadioGroupEntity} RadioGroupEntity
3
- * @typedef {import('@inglorious/web').Api} Api
2
+ * @typedef {import('../../../types/controls/radio-group').RadioGroupProps} RadioGroupProps
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 "@/shared/applyElementProps.js"
8
+ import { applyElementProps } from "../../shared/applyElementProps.js"
10
9
 
11
10
  /**
12
11
  * Radio group control for selecting one option.
13
12
  *
14
- * @param {RadioGroupEntity} entity
15
- * @param {Api} api
13
+ * @param {RadioGroupProps} props
16
14
  * @returns {TemplateResult}
17
15
  */
18
- export function render(entity, api) {
16
+ export function render(props) {
19
17
  const {
20
- name = entity.id || "radio",
18
+ id,
19
+ type, // eslint-disable-line no-unused-vars
20
+ name = "",
21
21
  label,
22
22
  value,
23
23
  options = [],
24
24
  direction = "column",
25
- disabled = false,
25
+ color = "primary",
26
+ isDisabled = false,
27
+ onChange,
26
28
  ...rest
27
- } = entity
29
+ } = props
30
+
31
+ const inputId = id || name
28
32
 
29
33
  const rootClasses = {
30
34
  "iw-radio-group": true,
31
35
  [`iw-radio-group-${direction}`]: true,
32
- "iw-radio-group-disabled": disabled,
36
+ [`iw-radio-group-${color}`]: color !== "primary",
37
+ "iw-radio-group-disabled": isDisabled,
33
38
  }
34
39
 
35
40
  return html`
36
41
  <fieldset
37
42
  class=${classMap(rootClasses)}
38
- ?disabled=${disabled}
43
+ ?disabled=${isDisabled}
39
44
  ${ref((element) => applyElementProps(element, rest))}
40
45
  >
41
46
  ${label
@@ -45,21 +50,21 @@ export function render(entity, api) {
45
50
  const {
46
51
  label: optionLabel,
47
52
  value: optionValue,
48
- disabled: optionDisabled = false,
53
+ isDisabled: optionDisabled = false,
49
54
  ...optionRest
50
55
  } = option
51
56
 
52
57
  return html`
53
58
  <label class="iw-radio-option">
54
59
  <input
60
+ id=${inputId}
55
61
  class="iw-radio"
56
62
  type="radio"
57
63
  name=${name}
58
64
  value=${optionValue}
59
65
  .checked=${value === optionValue}
60
- ?disabled=${disabled || optionDisabled}
61
- @change=${(event) =>
62
- api.notify(`#${entity.id}:change`, event.target.value)}
66
+ ?disabled=${isDisabled || optionDisabled}
67
+ @change=${(event) => onChange?.(event.target.value)}
63
68
  ${ref((element) => applyElementProps(element, optionRest))}
64
69
  />
65
70
  <span>${optionLabel}</span>
@@ -1,4 +1,3 @@
1
- import { withRenderValidation } from "../../shared/withRenderValidation.js"
2
1
  import * as renderers from "./template.js"
3
2
 
4
- export const rating = [{ ...renderers }, withRenderValidation]
3
+ export const rating = { ...renderers }
@@ -1,19 +1,15 @@
1
- import {
2
- makeStoryRender,
3
- notifyActionArgType,
4
- } from "../../stories/notifyStory.js"
1
+ import { createRender } from "../../stories/notifyStory.js"
5
2
  import { rating } from "."
6
3
 
7
4
  export default {
8
5
  title: "Controls/Rating",
9
6
  tags: ["autodocs"],
10
- render: makeStoryRender(rating, "story-rating"),
7
+ render: createRender(rating),
11
8
  argTypes: {
12
- ...notifyActionArgType,
13
9
  value: { control: "number", description: "Current rating value." },
14
10
  max: { control: "number", description: "Maximum rating value." },
15
- disabled: { control: "boolean", description: "Disables interaction." },
16
- readonly: {
11
+ isDisabled: { control: "boolean", description: "Disables interaction." },
12
+ isReadOnly: {
17
13
  control: "boolean",
18
14
  description: "Shows value without interaction.",
19
15
  },
@@ -24,6 +20,7 @@ export default {
24
20
  options: ["sm", "md", "lg"],
25
21
  description: "Symbol size.",
26
22
  },
23
+ onChange: { action: "onChange" },
27
24
  },
28
25
  parameters: {
29
26
  docs: {
@@ -39,8 +36,8 @@ export const Default = {}
39
36
  Default.args = {
40
37
  value: 3,
41
38
  max: 5,
42
- disabled: false,
43
- readonly: false,
39
+ isDisabled: false,
40
+ isReadOnly: false,
44
41
  symbol: "★",
45
42
  emptySymbol: "☆",
46
43
  size: "md",
@@ -22,8 +22,7 @@
22
22
  font-size: 1.5rem;
23
23
  }
24
24
 
25
- &.iw-rating-disabled,
26
- &.iw-rating-readonly {
25
+ &.iw-rating-disabled {
27
26
  opacity: 0.6;
28
27
  }
29
28
  }
@@ -1,50 +1,53 @@
1
1
  /**
2
- * @typedef {import('../../../types/controls/rating').RatingEntity} RatingEntity
3
- * @typedef {import('@inglorious/web').Api} Api
2
+ * @typedef {import('../../../types/controls/rating').RatingProps} RatingProps
4
3
  * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
5
4
  */
6
5
 
7
6
  import { classMap, html } from "@inglorious/web"
8
7
 
8
+ const DEFAULT_VALUE = 0
9
+ const DEFAULT_MAX = 5
10
+ const INDEX_TO_RATING = 1
11
+
9
12
  /**
10
13
  * Rating control rendered as clickable symbols.
11
14
  *
12
- * @param {RatingEntity} entity
13
- * @param {Api} api
15
+ * @param {RatingProps} props
14
16
  * @returns {TemplateResult}
15
17
  */
16
- export function render(entity, api) {
18
+ export function render(props) {
17
19
  const {
18
- value = 0,
19
- max = 5,
20
- disabled = false,
21
- readonly = false,
20
+ value = DEFAULT_VALUE,
21
+ max = DEFAULT_MAX,
22
+ isDisabled = false,
23
+ isReadOnly = false,
22
24
  symbol = "★",
23
25
  emptySymbol = "☆",
24
26
  size = "md",
25
- } = entity
27
+ onChange,
28
+ } = props
26
29
 
27
30
  const classes = {
28
31
  "iw-rating": true,
29
32
  [`iw-rating-${size}`]: size !== "md",
30
- "iw-rating-disabled": disabled,
31
- "iw-rating-readonly": readonly,
33
+ "iw-rating-disabled": isDisabled,
34
+ "iw-rating-readonly": isReadOnly,
32
35
  }
33
36
 
34
37
  return html`
35
38
  <div class=${classMap(classes)} role="radiogroup" aria-label="rating">
36
39
  ${Array.from({ length: max }, (_, index) => {
37
- const ratingValue = index + 1
38
- const active = ratingValue <= value
40
+ const ratingValue = index + INDEX_TO_RATING
41
+ const isActive = ratingValue <= value
39
42
  return html`
40
43
  <button
41
44
  type="button"
42
45
  class="iw-rating-item"
43
46
  aria-label=${`rate-${ratingValue}`}
44
- ?disabled=${disabled || readonly}
45
- @click=${() => api.notify(`#${entity.id}:change`, ratingValue)}
47
+ ?disabled=${isDisabled || isReadOnly}
48
+ @click=${() => onChange?.(ratingValue)}
46
49
  >
47
- ${active ? symbol : emptySymbol}
50
+ ${isActive ? symbol : emptySymbol}
48
51
  </button>
49
52
  `
50
53
  })}
@@ -32,25 +32,6 @@ export function getOptionLabel(option) {
32
32
  return String(option)
33
33
  }
34
34
 
35
- /**
36
- * Filter options based on search term.
37
- * @param {SelectOption[]} options
38
- * @param {string} searchTerm
39
- * @returns {SelectOption[]}
40
- */
41
- export function filterOptions(options, searchTerm) {
42
- if (!searchTerm || searchTerm.trim() === "") {
43
- return options
44
- }
45
-
46
- const searchLower = String(searchTerm).toLowerCase().trim()
47
-
48
- return options.filter((option) => {
49
- const label = getOptionLabel(option)
50
- return label.toLowerCase().includes(searchLower)
51
- })
52
- }
53
-
54
35
  /**
55
36
  * Check whether an option is selected.
56
37
  * @param {SelectOption} option
@@ -71,7 +52,7 @@ export function isOptionSelected(option, selectedValue, isMulti) {
71
52
  /**
72
53
  * Normalize option to object shape used in rendering/handlers.
73
54
  * @param {SelectOption} option
74
- * @returns {{ value: string|number, label: string, disabled?: boolean }}
55
+ * @returns {{ value: string|number, label: string, isDisabled?: boolean }}
75
56
  */
76
57
  export function formatOption(option) {
77
58
  if (typeof option === "string" || typeof option === "number") {
@@ -82,7 +63,7 @@ export function formatOption(option) {
82
63
  return {
83
64
  value: option.value ?? option,
84
65
  label: option.label ?? String(option.value ?? option),
85
- disabled: option.disabled ?? option.isDisabled ?? false,
66
+ isDisabled: option.isDisabled ?? option.disabled ?? false,
86
67
  ...option,
87
68
  }
88
69
  }
@@ -1,15 +1,3 @@
1
- import { withRenderValidation } from "../../shared/withRenderValidation.js"
2
- import * as handlers from "./handlers.js"
3
- import * as helpers from "./helpers.js"
4
1
  import * as renderers from "./template.js"
5
2
 
6
- export const selectPrimitive = { ...handlers, ...renderers }
7
- export const select = [selectPrimitive, withRenderValidation]
8
-
9
- export const {
10
- filterOptions,
11
- formatOption,
12
- getOptionLabel,
13
- getOptionValue,
14
- isOptionSelected,
15
- } = helpers
3
+ export const select = { ...renderers }
@@ -1,90 +1,94 @@
1
- import {
2
- makeStoryRender,
3
- notifyActionArgType,
4
- } from "../../stories/notifyStory.js"
5
- import { select } from "."
6
-
7
- const options = [
8
- { label: "Italy", value: "it" },
9
- { label: "France", value: "fr" },
10
- { label: "Spain", value: "es" },
11
- { label: "Germany", value: "de" },
12
- ]
1
+ import { createRender } from "../../stories/notifyStory.js"
2
+ import { select } from "./index.js"
13
3
 
14
4
  export default {
15
5
  title: "Controls/Select",
16
6
  tags: ["autodocs"],
17
- render: makeStoryRender(select, "story-select"),
7
+ render: createRender(select),
18
8
  argTypes: {
19
- ...notifyActionArgType,
20
- label: { control: "text", description: "Field label." },
21
- selectedValue: {
22
- control: "object",
23
- description: "Current selection. Value or array of values in multi mode.",
9
+ name: {
10
+ control: "text",
11
+ description: "Native HTML input name attribute.",
24
12
  },
25
- isMulti: { control: "boolean", description: "Enable multiple selection." },
26
- isOpen: {
27
- control: "boolean",
28
- description: "Controls dropdown visibility.",
29
- },
30
- isSearchable: { control: "boolean", description: "Show search input." },
31
- isClearable: { control: "boolean", description: "Show clear button." },
32
- isDisabled: { control: "boolean", description: "Disable the control." },
33
- isLoading: { control: "boolean", description: "Show loading state." },
34
- searchTerm: { control: "text", description: "Current search filter." },
35
- placeholder: { control: "text", description: "Placeholder text." },
36
- noOptionsMessage: { control: "text", description: "No results message." },
37
- loadingMessage: { control: "text", description: "Loading message." },
38
- fullWidth: {
39
- control: "boolean",
40
- description: "Expand to container width.",
13
+ value: {
14
+ control: "text",
15
+ description: "Current select value.",
41
16
  },
42
17
  size: {
43
18
  control: "select",
44
19
  options: ["sm", "md", "lg"],
45
- description: "Control size.",
20
+ description: "Size scale for paddings and font-size.",
46
21
  },
47
- options: { control: "object", description: "Available options." },
22
+ isDisabled: {
23
+ control: "boolean",
24
+ description: "Disables user input and interaction.",
25
+ },
26
+ isFullWidth: {
27
+ control: "boolean",
28
+ description: "Expands input width to 100% of its container.",
29
+ },
30
+ onChange: { action: "onChange" },
31
+ onBlur: { action: "onBlur" },
32
+ onFocus: { action: "onFocus" },
48
33
  },
49
34
  parameters: {
50
35
  docs: {
51
36
  description: {
52
- component:
53
- "Theme-aware custom select with searchable dropdown, clear action, and optional multi-selection.",
37
+ component: "Select field control.",
54
38
  },
55
39
  },
56
40
  },
57
41
  }
58
42
 
59
- export const SingleClosed = {}
60
- SingleClosed.args = {
61
- label: "Country",
62
- selectedValue: "it",
63
- isMulti: false,
64
- isOpen: false,
65
- isSearchable: true,
66
- isClearable: true,
67
- isDisabled: false,
68
- isLoading: false,
69
- searchTerm: "",
70
- placeholder: "Select...",
71
- noOptionsMessage: "No options",
72
- loadingMessage: "Loading...",
73
- fullWidth: false,
43
+ export const Default = {}
44
+ Default.args = {
45
+ name: "animals",
46
+ options: ["Cat", "Dog", "Seal"],
47
+ value: "",
74
48
  size: "md",
75
- options,
49
+ isDisabled: false,
50
+ isFullWidth: false,
51
+ }
52
+
53
+ export const ComplexOptions = {}
54
+ ComplexOptions.args = {
55
+ ...Default.args,
56
+ options: [
57
+ { value: "cat", label: "Cat" },
58
+ { value: "dog", label: "Dog" },
59
+ { value: "seal", label: "Seal" },
60
+ ],
61
+ }
62
+
63
+ export const Disabled = {}
64
+ Disabled.args = {
65
+ ...Default.args,
66
+ value: "Cat",
67
+ isDisabled: true,
68
+ }
69
+
70
+ export const DisabledOption = {}
71
+ DisabledOption.args = {
72
+ ...ComplexOptions.args,
73
+ options: ComplexOptions.args.options.map((option, index) =>
74
+ index % 2 ? { ...option, isDisabled: true } : option,
75
+ ),
76
+ }
77
+
78
+ export const Small = {}
79
+ Small.args = {
80
+ ...Default.args,
81
+ size: "sm",
76
82
  }
77
83
 
78
- export const SingleOpen = {}
79
- SingleOpen.args = {
80
- ...SingleClosed.args,
81
- isOpen: true,
84
+ export const Large = {}
85
+ Large.args = {
86
+ ...Default.args,
87
+ size: "lg",
82
88
  }
83
89
 
84
- export const MultiOpen = {}
85
- MultiOpen.args = {
86
- ...SingleClosed.args,
87
- isMulti: true,
88
- selectedValue: ["it", "fr"],
89
- isOpen: true,
90
+ export const FullWidth = {}
91
+ FullWidth.args = {
92
+ ...Default.args,
93
+ isFullWidth: true,
90
94
  }