@inglorious/ui 9.8.2 → 9.10.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 (39) hide show
  1. package/package.json +28 -3
  2. package/src/controls/chip-picker/chip-picker.stories.js +22 -0
  3. package/src/controls/chip-picker/index.js +3 -0
  4. package/src/controls/chip-picker/style.css +26 -0
  5. package/src/controls/chip-picker/template.js +53 -0
  6. package/src/controls/combobox/combobox.stories.js +14 -0
  7. package/src/controls/combobox/handlers.js +87 -20
  8. package/src/controls/combobox/helpers.js +50 -4
  9. package/src/controls/combobox/index.js +1 -0
  10. package/src/controls/combobox/template.js +13 -14
  11. package/src/controls/controls.css +3 -2
  12. package/src/data-display/data-display.css +1 -0
  13. package/src/data-display/lightbox/index.js +3 -0
  14. package/src/data-display/lightbox/lightbox.stories.js +25 -0
  15. package/src/data-display/lightbox/style.css +97 -0
  16. package/src/data-display/lightbox/template.js +153 -0
  17. package/src/feedback/confirm-dialog/confirm-dialog.stories.js +33 -0
  18. package/src/feedback/confirm-dialog/index.js +3 -0
  19. package/src/feedback/confirm-dialog/style.css +16 -0
  20. package/src/feedback/confirm-dialog/template.js +70 -0
  21. package/src/feedback/crop-dialog/index.js +3 -0
  22. package/src/feedback/crop-dialog/style.css +43 -0
  23. package/src/feedback/crop-dialog/template.js +82 -0
  24. package/src/feedback/dialog/style.css +2 -1
  25. package/src/feedback/dialog/template.js +5 -2
  26. package/src/feedback/feedback.css +3 -0
  27. package/src/feedback/load-status/index.js +3 -0
  28. package/src/feedback/load-status/load-status.stories.js +16 -0
  29. package/src/feedback/load-status/style.css +10 -0
  30. package/src/feedback/load-status/template.js +43 -0
  31. package/src/index.js +5 -0
  32. package/src/shared/icons.js +12 -0
  33. package/types/controls/chip-picker.d.ts +23 -0
  34. package/types/controls/combobox.d.ts +38 -2
  35. package/types/data-display/lightbox.d.ts +35 -0
  36. package/types/feedback/confirm-dialog.d.ts +34 -0
  37. package/types/feedback/crop-dialog.d.ts +35 -0
  38. package/types/feedback/load-status.d.ts +22 -0
  39. package/types/index.d.ts +17 -0
@@ -0,0 +1,23 @@
1
+ import type { TemplateResult } from "@inglorious/web"
2
+
3
+ import type { ComboboxOption } from "./combobox"
4
+
5
+ export interface ChipPickerProps {
6
+ /** The fieldset's legend. */
7
+ label?: TemplateResult | string
8
+ hint?: TemplateResult | string
9
+ /** Strings, numbers or `{ value, label, isDisabled }`, as in Combobox. */
10
+ options?: ComboboxOption[]
11
+ /** The values picked. */
12
+ value?: (string | number)[]
13
+ isDisabled?: boolean
14
+ className?: string
15
+ /** Called with the value of the chip pressed, picked or not. */
16
+ onToggle?: (value: string | number) => void
17
+ }
18
+
19
+ export type ChipPickerType = {
20
+ render(props: ChipPickerProps): TemplateResult
21
+ }
22
+
23
+ export declare const ChipPicker: ChipPickerType
@@ -10,6 +10,10 @@ export type ComboboxOption =
10
10
  error?: string
11
11
  isDisabled?: boolean
12
12
  isRequired?: boolean
13
+ /** Other names a search finds this option by. */
14
+ keywords?: string[]
15
+ /** Set on the option that adds a searched term. */
16
+ isCreated?: boolean
13
17
  [key: string]: unknown
14
18
  }
15
19
 
@@ -30,6 +34,10 @@ export interface ComboboxProps {
30
34
  isDisabled?: boolean
31
35
  isSearchable?: boolean
32
36
  isClearable?: boolean
37
+ /** Offers to add a searched term that matches no option. Needs `isSearchable`. */
38
+ isCreatable?: boolean
39
+ /** Text of the option that adds the term. Defaults to `Add "term"`. */
40
+ formatCreateLabel?: (term: string) => string
33
41
 
34
42
  placeholder?: string
35
43
  /** Placeholder of the search box in the panel. Defaults to "Search...". */
@@ -37,6 +45,16 @@ export interface ComboboxProps {
37
45
  noOptionsMessage?: string
38
46
  loadingMessage?: string
39
47
 
48
+ /** A validation message, shown under the control. */
49
+ error?: string | null
50
+ /**
51
+ * An event to notify when the user picks or clears a value, such as
52
+ * `"#form:fieldChange"`. The payload is `changePayload` with the new `value`.
53
+ */
54
+ changeEvent?: string
55
+ /** Merged into `changeEvent`'s payload, such as `{ path: "country" }`. */
56
+ changePayload?: Record<string, unknown>
57
+
40
58
  isFullWidth?: boolean
41
59
  size?: "sm" | "md" | "lg"
42
60
  onToggle?: () => void
@@ -60,13 +78,21 @@ export type ComboboxType = {
60
78
  open(entity: ComboboxProps): void
61
79
  close(entity: ComboboxProps): void
62
80
  toggle(entity: ComboboxProps): void
63
- optionSelect(entity: ComboboxProps, option: ComboboxOption): void
64
- clear(entity: ComboboxProps): void
81
+ optionSelect(entity: ComboboxProps, option: ComboboxOption, api?: Api): void
82
+ clear(entity: ComboboxProps, payload?: unknown, api?: Api): void
65
83
  searchChange(entity: ComboboxProps, searchTerm: string): void
66
84
  focusNext(entity: ComboboxProps): void
67
85
  focusPrev(entity: ComboboxProps): void
68
86
  focusFirst(entity: ComboboxProps): void
69
87
  focusLast(entity: ComboboxProps): void
88
+ focusSet(entity: ComboboxProps, index: number): void
89
+ /** Sets the value from outside, without notifying `changeEvent`. An empty string is no value. */
90
+ valueSet(
91
+ entity: ComboboxProps,
92
+ value: string | number | (string | number)[] | null,
93
+ ): void
94
+ optionsSet(entity: ComboboxProps, options: ComboboxOption[]): void
95
+ errorSet(entity: ComboboxProps, error: string | null): void
70
96
  }
71
97
 
72
98
  export declare const Combobox: ComboboxType
@@ -83,3 +109,13 @@ export declare function filterOptions(
83
109
  options: ComboboxOption[],
84
110
  searchTerm: string,
85
111
  ): ComboboxOption[]
112
+ export declare function visibleOptions(
113
+ props: Pick<
114
+ ComboboxProps,
115
+ | "options"
116
+ | "searchTerm"
117
+ | "selectedValue"
118
+ | "isCreatable"
119
+ | "formatCreateLabel"
120
+ >,
121
+ ): ComboboxOption[]
@@ -0,0 +1,35 @@
1
+ import type { TemplateResult, nothing } from "@inglorious/web"
2
+
3
+ export interface LightboxImage {
4
+ src: string
5
+ /** Defaults to empty, for images the page describes already. */
6
+ alt?: string
7
+ }
8
+
9
+ export interface LightboxProps {
10
+ id?: string
11
+ /** URLs, or `{ src, alt }`. Renders nothing when empty. */
12
+ images?: (string | LightboxImage)[]
13
+ /** The image shown. Any integer: it wraps around. */
14
+ index?: number
15
+ isOpen?: boolean
16
+ /** The dialog's accessible name. Defaults to `"Photos"`. */
17
+ label?: string
18
+ /** Defaults to `"Close"`. */
19
+ closeLabel?: string
20
+ /** Defaults to `"Previous photo"`. */
21
+ previousLabel?: string
22
+ /** Defaults to `"Next photo"`. */
23
+ nextLabel?: string
24
+ className?: string
25
+ /** `1` for the next image, `-1` for the previous. Without it there is no navigation. */
26
+ onStep?: (step: 1 | -1) => void
27
+ /** Called by the close button, Esc and a press outside the image. */
28
+ onClose?: () => void
29
+ }
30
+
31
+ export type LightboxType = {
32
+ render(props: LightboxProps): TemplateResult | typeof nothing
33
+ }
34
+
35
+ export declare const Lightbox: LightboxType
@@ -0,0 +1,34 @@
1
+ import type { TemplateResult } from "@inglorious/web"
2
+
3
+ import type { Renderable } from "../shared/renderable"
4
+
5
+ export interface ConfirmDialogProps {
6
+ id?: string
7
+ isOpen?: boolean
8
+ /** The question, such as "Delete this event?". */
9
+ message?: TemplateResult | string | number
10
+ /** Anything more to show under the message, such as an error. */
11
+ children?: Renderable
12
+ confirmLabel: string
13
+ /** The confirm button's text while `isBusy`. Defaults to `confirmLabel`. */
14
+ busyLabel?: string
15
+ /** Defaults to `"Cancel"`. */
16
+ cancelLabel?: string
17
+ /** The close button's accessible name. Defaults to `"Close"`. */
18
+ closeLabel?: string
19
+ /** `"danger"` (default) for an action that cannot be undone, `"primary"` otherwise. */
20
+ tone?: "danger" | "primary"
21
+ /** The action is running: nothing can be pressed and the sheet stays open. */
22
+ isBusy?: boolean
23
+ isDisabled?: boolean
24
+ className?: string
25
+ onConfirm?: () => void
26
+ /** Called by the cancel button, Esc and the backdrop. */
27
+ onCancel?: () => void
28
+ }
29
+
30
+ export type ConfirmDialogType = {
31
+ render(props: ConfirmDialogProps): TemplateResult
32
+ }
33
+
34
+ export declare const ConfirmDialog: ConfirmDialogType
@@ -0,0 +1,35 @@
1
+ import type { Api, TemplateResult } from "@inglorious/web"
2
+
3
+ import type { CropRect } from "../controls/image-cropper"
4
+
5
+ export interface CropDialogProps {
6
+ id?: string
7
+ isOpen?: boolean
8
+ /** The id of the ImageCropper entity to show. */
9
+ cropperId: string
10
+ title?: TemplateResult | string
11
+ description?: TemplateResult | string
12
+ /** Defaults to `"Apply"`. */
13
+ applyLabel?: string
14
+ /** The apply button's text while `isSaving`. Defaults to `"Saving…"`. */
15
+ savingLabel?: string
16
+ /** Defaults to `"Cancel"`. */
17
+ cancelLabel?: string
18
+ /** The close button's accessible name. Defaults to `"Close"`. */
19
+ closeLabel?: string
20
+ /** Shown when the cropper cannot load its image. */
21
+ loadErrorText?: string
22
+ /** An error of the caller's, such as a failed upload. Wins over `loadErrorText`. */
23
+ error?: TemplateResult | string | null
24
+ isSaving?: boolean
25
+ className?: string
26
+ onCancel?: () => void
27
+ /** Receives the cropper's `rect`. */
28
+ onApply?: (rect: CropRect) => void
29
+ }
30
+
31
+ export type CropDialogType = {
32
+ render(props: CropDialogProps, api: Api): TemplateResult
33
+ }
34
+
35
+ export declare const CropDialog: CropDialogType
@@ -0,0 +1,22 @@
1
+ import type { Renderable } from "../shared/renderable"
2
+
3
+ export interface LoadStatusProps {
4
+ isError?: boolean
5
+ error?: Renderable
6
+ isLoading?: boolean
7
+ /** Replaces the circular progress, such as with the app's own animation. */
8
+ loader?: Renderable
9
+ /** The progress indicator's accessible name. Defaults to `"Loading…"`. */
10
+ loadingLabel?: string
11
+ isEmpty?: boolean
12
+ emptyText?: Renderable
13
+ /** What to render when there is no status to show. Runs only then, so it can read data still loading. */
14
+ content?: () => Renderable
15
+ className?: string
16
+ }
17
+
18
+ export type LoadStatusType = {
19
+ render(props: LoadStatusProps): Renderable
20
+ }
21
+
22
+ export declare const LoadStatus: LoadStatusType
package/types/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { Button } from "./controls/button"
2
2
  export { ButtonGroup } from "./controls/button-group"
3
3
  export { Checkbox } from "./controls/checkbox"
4
+ export { ChipPicker } from "./controls/chip-picker"
4
5
  export { Fab } from "./controls/fab"
5
6
  export { FileUpload } from "./controls/file-upload"
6
7
  export { IconButton } from "./controls/icon-button"
@@ -18,6 +19,7 @@ export { BeforeAfter } from "./data-display/before-after"
18
19
  export { Carousel } from "./data-display/carousel"
19
20
  export { Chat } from "./data-display/chat"
20
21
  export { Chip } from "./data-display/chip"
22
+ export { Lightbox } from "./data-display/lightbox"
21
23
  export { DataGrid } from "./data-display/data-grid"
22
24
  export { Divider } from "./data-display/divider"
23
25
  export { Icon } from "./data-display/icon"
@@ -28,7 +30,10 @@ export { Typography } from "./data-display/typography"
28
30
  export { VirtualList } from "./data-display/virtual-list"
29
31
  export { Alert } from "./feedback/alert"
30
32
  export { Backdrop } from "./feedback/backdrop"
33
+ export { ConfirmDialog } from "./feedback/confirm-dialog"
34
+ export { CropDialog } from "./feedback/crop-dialog"
31
35
  export { Dialog } from "./feedback/dialog"
36
+ export { LoadStatus } from "./feedback/load-status"
32
37
  export { Progress } from "./feedback/progress"
33
38
  export { Skeleton } from "./feedback/skeleton"
34
39
  export { Snackbar } from "./feedback/snackbar"
@@ -53,6 +58,7 @@ export { Paper } from "./surfaces/paper"
53
58
  export type { ButtonProps, ButtonType } from "./controls/button"
54
59
  export type { ButtonGroupProps, ButtonGroupType } from "./controls/button-group"
55
60
  export type { CheckboxProps, CheckboxType } from "./controls/checkbox"
61
+ export type { ChipPickerProps, ChipPickerType } from "./controls/chip-picker"
56
62
  export type {
57
63
  ComboboxProps,
58
64
  ComboboxType,
@@ -119,6 +125,11 @@ export type { PaperProps, PaperType } from "./surfaces/paper"
119
125
  export type { AvatarProps, AvatarType } from "./data-display/avatar"
120
126
  export type { BadgeProps, BadgeType } from "./data-display/badge"
121
127
  export type { ChipProps, ChipType } from "./data-display/chip"
128
+ export type {
129
+ LightboxImage,
130
+ LightboxProps,
131
+ LightboxType,
132
+ } from "./data-display/lightbox"
122
133
  export type {
123
134
  DataGridProps,
124
135
  DataGridType,
@@ -148,7 +159,13 @@ export type {
148
159
  } from "./data-display/typography"
149
160
  export type { AlertProps, AlertType } from "./feedback/alert"
150
161
  export type { BackdropProps, BackdropType } from "./feedback/backdrop"
162
+ export type {
163
+ ConfirmDialogProps,
164
+ ConfirmDialogType,
165
+ } from "./feedback/confirm-dialog"
166
+ export type { CropDialogProps, CropDialogType } from "./feedback/crop-dialog"
151
167
  export type { DialogProps, DialogType } from "./feedback/dialog"
168
+ export type { LoadStatusProps, LoadStatusType } from "./feedback/load-status"
152
169
  export type { ProgressProps, ProgressType } from "./feedback/progress"
153
170
  export type { SkeletonProps, SkeletonType } from "./feedback/skeleton"
154
171
  export type { SnackbarProps, SnackbarType } from "./feedback/snackbar"