@inglorious/ui 9.1.0 → 9.2.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 (37) hide show
  1. package/package.json +2 -2
  2. package/src/controls/button/template.js +13 -12
  3. package/src/controls/button-group/template.js +6 -6
  4. package/src/controls/checkbox/checkbox.stories.js +16 -0
  5. package/src/controls/checkbox/style.css +24 -0
  6. package/src/controls/checkbox/template.js +23 -8
  7. package/src/controls/file-upload/template.js +27 -26
  8. package/src/controls/icon-button/template.js +6 -6
  9. package/src/controls/image-cropper/template.js +3 -1
  10. package/src/controls/radio-group/radio-group.stories.js +19 -0
  11. package/src/controls/radio-group/style.css +30 -0
  12. package/src/controls/radio-group/template.js +27 -15
  13. package/src/controls/select/template.js +5 -6
  14. package/src/controls/slider/template.js +47 -44
  15. package/src/controls/switch/template.js +14 -10
  16. package/src/controls/textarea/template.js +29 -26
  17. package/src/data-display/avatar/template.js +6 -5
  18. package/src/data-display/chip/chip.stories.js +13 -0
  19. package/src/data-display/chip/style.css +22 -0
  20. package/src/data-display/chip/template.js +33 -9
  21. package/src/data-display/data-grid/template.js +1 -1
  22. package/src/data-display/list/template.js +4 -5
  23. package/src/examples/dashboard/primitive-section.js +18 -18
  24. package/src/feedback/alert/template.js +26 -26
  25. package/src/feedback/dialog/template.js +31 -29
  26. package/src/feedback/snackbar/template.js +14 -13
  27. package/src/navigation/bottom-navigation/template.js +11 -12
  28. package/src/navigation/breadcrumbs/template.js +28 -25
  29. package/src/navigation/menu/template.js +9 -10
  30. package/src/navigation/pagination/template.js +15 -18
  31. package/src/navigation/stepper/template.js +5 -5
  32. package/src/navigation/tabs/template.js +2 -1
  33. package/src/surfaces/accordion/template.js +2 -1
  34. package/src/surfaces/card/template.js +3 -2
  35. package/types/controls/checkbox.d.ts +4 -0
  36. package/types/controls/radio-group.d.ts +4 -0
  37. package/types/data-display/chip.d.ts +7 -0
@@ -7,6 +7,7 @@
7
7
 
8
8
  import { html } from "@inglorious/web"
9
9
  import { classMap } from "@inglorious/web/directives/class-map"
10
+ import { when } from "@inglorious/web/directives/when"
10
11
 
11
12
  import { Button } from "../../controls/button/index.js"
12
13
 
@@ -52,15 +53,13 @@ export const Pagination = {
52
53
  class=${classMap({ "iw-pagination": true, ...extraClasses })}
53
54
  aria-label="Pagination"
54
55
  >
55
- ${
56
- isFirstButtonVisible
57
- ? this.renderControl(props, {
58
- label: "«",
59
- target: 1,
60
- isDisabled: page <= PRETTY_PAGE || isDisabled,
61
- })
62
- : null
63
- }
56
+ ${when(isFirstButtonVisible, () =>
57
+ this.renderControl(props, {
58
+ label: "«",
59
+ target: 1,
60
+ isDisabled: page <= PRETTY_PAGE || isDisabled,
61
+ }),
62
+ )}
64
63
  ${this.renderControl(props, {
65
64
  label: "‹",
66
65
  target: Math.max(PRETTY_PAGE, page - PRETTY_PAGE),
@@ -72,15 +71,13 @@ export const Pagination = {
72
71
  target: Math.min(count, page + PRETTY_PAGE),
73
72
  isDisabled: page >= count || isDisabled,
74
73
  })}
75
- ${
76
- isLastButtonVisible
77
- ? this.renderControl(props, {
78
- label: "»",
79
- target: count,
80
- isDisabled: page >= count || isDisabled,
81
- })
82
- : null
83
- }
74
+ ${when(isLastButtonVisible, () =>
75
+ this.renderControl(props, {
76
+ label: "»",
77
+ target: count,
78
+ isDisabled: page >= count || isDisabled,
79
+ }),
80
+ )}
84
81
  </nav>`
85
82
  },
86
83
 
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { html } from "@inglorious/web"
8
8
  import { classMap } from "@inglorious/web/directives/class-map"
9
+ import { when } from "@inglorious/web/directives/when"
9
10
 
10
11
  export const Stepper = {
11
12
  /**
@@ -67,11 +68,10 @@ export const Stepper = {
67
68
  <span class="iw-stepper-indicator">${completed ? "✓" : index + 1}</span>
68
69
  <span class="iw-stepper-content">
69
70
  <span class="iw-stepper-label">${step.label}</span>
70
- ${
71
- step.optional
72
- ? html`<span class="iw-stepper-optional">${step.optional}</span>`
73
- : null
74
- }
71
+ ${when(
72
+ step.optional,
73
+ () => html`<span class="iw-stepper-optional">${step.optional}</span>`,
74
+ )}
75
75
  </span>
76
76
  </li>`
77
77
  },
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { html, nothing } from "@inglorious/web"
8
8
  import { classMap } from "@inglorious/web/directives/class-map"
9
+ import { when } from "@inglorious/web/directives/when"
9
10
 
10
11
  export const Tabs = {
11
12
  /**
@@ -88,7 +89,7 @@ export const Tabs = {
88
89
  props.onChange?.(tabValue)
89
90
  }}
90
91
  >
91
- ${item.icon ? html`<span class="iw-tab-icon">${item.icon}</span>` : null}
92
+ ${when(item.icon, () => html`<span class="iw-tab-icon">${item.icon}</span>`)}
92
93
  <span>${item.label}</span>
93
94
  </button>`
94
95
  },
@@ -7,6 +7,7 @@
7
7
  import { html, nothing } from "@inglorious/web"
8
8
  import { classMap } from "@inglorious/web/directives/class-map"
9
9
  import { ref } from "@inglorious/web/directives/ref"
10
+ import { when } from "@inglorious/web/directives/when"
10
11
 
11
12
  import { applyElementProps } from "../../shared/apply-element-props.js"
12
13
 
@@ -104,7 +105,7 @@ export const Accordion = {
104
105
  if (isDisabled) event.preventDefault()
105
106
  }}
106
107
  >
107
- ${icon ? html`<span class="iw-accordion-icon">${icon}</span>` : null}
108
+ ${when(icon, () => html`<span class="iw-accordion-icon">${icon}</span>`)}
108
109
  <span class="iw-accordion-title">${title}</span>
109
110
  <span class="iw-accordion-caret" aria-hidden="true">▾</span>
110
111
  </summary>
@@ -6,6 +6,7 @@
6
6
  import { html } from "@inglorious/web"
7
7
  import { classMap } from "@inglorious/web/directives/class-map"
8
8
  import { ref } from "@inglorious/web/directives/ref"
9
+ import { when } from "@inglorious/web/directives/when"
9
10
 
10
11
  import { applyElementProps } from "../../shared/apply-element-props.js"
11
12
 
@@ -95,8 +96,8 @@ export const Card = {
95
96
  [`iw-card-header-padding-${headerPadding}`]: headerPadding !== "md",
96
97
  })}
97
98
  >
98
- ${title ? html`<h3 class="iw-card-title">${title}</h3>` : null}
99
- ${subtitle ? html`<p class="iw-card-subtitle">${subtitle}</p>` : null}
99
+ ${when(title, () => html`<h3 class="iw-card-title">${title}</h3>`)}
100
+ ${when(subtitle, () => html`<p class="iw-card-subtitle">${subtitle}</p>`)}
100
101
  </div>`
101
102
  },
102
103
 
@@ -6,6 +6,10 @@ export interface CheckboxProps {
6
6
  label?: string
7
7
  /** A line of detail under the label. */
8
8
  description?: string
9
+ /** Shown above the label, such as an icon or an image. */
10
+ media?: TemplateResult
11
+ /** `"card"` draws the checkbox as a card, outlined while checked. */
12
+ variant?: "default" | "card"
9
13
  isChecked?: boolean
10
14
  isDisabled?: boolean
11
15
  isRequired?: boolean
@@ -4,6 +4,8 @@ export interface RadioOption {
4
4
  label: string
5
5
  /** A line of detail under the label. */
6
6
  description?: string
7
+ /** Shown above the label, such as an icon or an image. */
8
+ media?: TemplateResult
7
9
  value: string
8
10
  isDisabled?: boolean
9
11
  [key: string]: unknown
@@ -16,6 +18,8 @@ export interface RadioGroupProps {
16
18
  value?: string
17
19
  options?: RadioOption[]
18
20
  direction?: "column" | "row"
21
+ /** `"card"` draws each option as a card in a grid, outlined while checked. */
22
+ variant?: "default" | "card"
19
23
  color?: "primary" | "secondary" | "success" | "warning" | "error" | "info"
20
24
  isDisabled?: boolean
21
25
  onChange?: (value: string) => void
@@ -16,6 +16,13 @@ export interface ChipProps {
16
16
  | "info"
17
17
  size?: "sm" | "md" | "lg"
18
18
  shape?: "pill" | "rounded" | "square"
19
+ /**
20
+ * Makes the chip a toggle button, pressed while true, for picking options:
21
+ * `onClick` toggles it. Left out, the chip is a plain label.
22
+ */
23
+ isSelected?: boolean
24
+ /** Only for a chip with `isSelected`. */
25
+ isDisabled?: boolean
19
26
  onClick?: () => void
20
27
  [key: string]: unknown
21
28
  }