@allxsmith/bestax-bulma 5.32.0 → 5.33.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 (41) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Avatars.js +4 -21
  4. package/dist/esm/components/Avatars.js.map +1 -1
  5. package/dist/esm/components/Collapses.js +1 -20
  6. package/dist/esm/components/Collapses.js.map +1 -1
  7. package/dist/esm/elements/Kbd.js +86 -0
  8. package/dist/esm/elements/Kbd.js.map +1 -0
  9. package/dist/esm/form/Autocomplete.js +59 -14
  10. package/dist/esm/form/Autocomplete.js.map +1 -1
  11. package/dist/esm/helpers/flattenChildren.js +35 -0
  12. package/dist/esm/helpers/flattenChildren.js.map +1 -0
  13. package/dist/esm/helpers/statusRegion.js +19 -12
  14. package/dist/esm/helpers/statusRegion.js.map +1 -1
  15. package/dist/extras.css +1 -1
  16. package/dist/extras.css.map +1 -1
  17. package/dist/index.cjs +254 -134
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.esm.js +1 -0
  20. package/dist/index.esm.js.map +1 -1
  21. package/dist/types/elements/Kbd.d.ts +100 -0
  22. package/dist/types/form/Autocomplete.d.ts +18 -3
  23. package/dist/types/helpers/flattenChildren.d.ts +16 -0
  24. package/dist/types/helpers/statusRegion.d.ts +4 -4
  25. package/dist/types/index.d.ts +1 -0
  26. package/dist/types-cjs/elements/Kbd.d.ts +100 -0
  27. package/dist/types-cjs/form/Autocomplete.d.ts +18 -3
  28. package/dist/types-cjs/helpers/flattenChildren.d.ts +16 -0
  29. package/dist/types-cjs/helpers/statusRegion.d.ts +4 -4
  30. package/dist/types-cjs/index.d.ts +1 -0
  31. package/dist/versions/bestax-no-dark-mode.css +1 -1
  32. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  33. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  34. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  35. package/dist/versions/bestax-no-helpers.css +1 -1
  36. package/dist/versions/bestax-no-helpers.css.map +1 -1
  37. package/dist/versions/bestax-prefixed.css +1 -1
  38. package/dist/versions/bestax-prefixed.css.map +1 -1
  39. package/package.json +1 -1
  40. package/src/scss/elements/_index.scss +1 -0
  41. package/src/scss/elements/_kbd.scss +86 -0
package/dist/index.esm.js CHANGED
@@ -43,6 +43,7 @@ export { Figure } from './esm/elements/Figure.js';
43
43
  export { Icon } from './esm/elements/Icon.js';
44
44
  export { IconText } from './esm/elements/IconText.js';
45
45
  export { Image } from './esm/elements/Image.js';
46
+ export { Kbd, KbdGroup } from './esm/elements/Kbd.js';
46
47
  export { Link } from './esm/elements/Link.js';
47
48
  export { ListItem } from './esm/elements/ListItem.js';
48
49
  export { Loader } from './esm/elements/Loader.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,100 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
3
+ /**
4
+ * Props for the Kbd component. The helper props, the other attributes and
5
+ * the `ref` land on the `<kbd>`.
6
+ *
7
+ * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<kbd>`.
8
+ */
9
+ export interface KbdProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
10
+ /** Additional CSS classes to apply. */
11
+ className?: string;
12
+ /**
13
+ * The key as it's printed on the keyboard: a word (`Ctrl`, `Esc`), a
14
+ * letter, or a symbol (`⌘`).
15
+ */
16
+ children?: React.ReactNode;
17
+ /**
18
+ * What a screen reader says in place of a symbol, in your app's language:
19
+ * `label="Command"` on `⌘`. The symbol is hidden from assistive tech with
20
+ * `aria-hidden`, and the label is read in its place, from text that's
21
+ * visually hidden. Use it for a glyph that isn't a word, such as `⌘`, `⌥`,
22
+ * `⇧`, `⌃` or `⏎`, and leave it off a key written as a word. Copying the
23
+ * key copies the label along with the glyph. Don't reach for `aria-label`
24
+ * instead: ARIA in HTML prohibits naming a `<kbd>`, so nothing obliges a
25
+ * screen reader to read it.
26
+ */
27
+ label?: string;
28
+ /**
29
+ * Text color helper. The key's edge and fill are mixed from its text
30
+ * color, so they follow it.
31
+ */
32
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
33
+ /**
34
+ * Background color helper. It replaces the key's faint fill, and the text
35
+ * still follows the text around it, which turns light in dark mode, so pair
36
+ * it with a `textColor` that reads on that color in both schemes, such as
37
+ * `textColor="black"` on `bgColor="warning"`.
38
+ */
39
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
40
+ }
41
+ /**
42
+ * Props for Kbd.Group, keys pressed together or one after another. The
43
+ * group renders the outer `<kbd>` of a combination, and the helper props,
44
+ * the other attributes and the `ref` land on it.
45
+ *
46
+ * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the outer `<kbd>`.
47
+ */
48
+ export interface KbdGroupProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
49
+ /** Additional CSS classes to apply. */
50
+ className?: string;
51
+ /**
52
+ * The keys, a `Kbd` each, in the order they're pressed. The group renders
53
+ * the outer `<kbd>` around them, so it doesn't go inside a `Kbd` of its
54
+ * own, and it puts the separator between them, so don't type one: a `+`
55
+ * of your own doubles up. A `null` or `false` child, or an empty Fragment,
56
+ * gets no separator, and the keys in a Fragment are separated like the
57
+ * rest. A component that renders nothing still gets one, since the group
58
+ * can't see what a child renders, so write a conditional key inline
59
+ * (`{isMac && <Kbd label="Command">⌘</Kbd>}`), not in a component of its
60
+ * own.
61
+ */
62
+ children?: React.ReactNode;
63
+ /**
64
+ * What goes between the keys, shown and read aloud, with a space either
65
+ * side. Use `'then'` for a sequence pressed one key after another. It's a
66
+ * string because a screen reader has to read it.
67
+ */
68
+ separator?: string;
69
+ /** Text color helper. The keys and separators inside follow it. */
70
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
71
+ }
72
+ /**
73
+ * Keys pressed together or one after another, in the outer `<kbd>` HTML gives a combination, with the separator between each pair as text.
74
+ *
75
+ * It doesn't wrap in the middle and isn't drawn as a key itself. It sets no
76
+ * font size, so the keys in it are the size of a key on its own.
77
+ *
78
+ * @function
79
+ * @param {KbdGroupProps} props - Props for Kbd.Group.
80
+ * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the outer `<kbd>`.
81
+ * @returns {JSX.Element} The rendered combination.
82
+ *
83
+ * @example
84
+ * <Kbd.Group>
85
+ * <Kbd>Ctrl</Kbd>
86
+ * <Kbd>Shift</Kbd>
87
+ * <Kbd>P</Kbd>
88
+ * </Kbd.Group>
89
+ *
90
+ * @example
91
+ * <Kbd.Group separator="then">
92
+ * <Kbd>G</Kbd>
93
+ * <Kbd>I</Kbd>
94
+ * </Kbd.Group>
95
+ */
96
+ export declare const KbdGroup: React.ForwardRefExoticComponent<KbdGroupProps & React.RefAttributes<HTMLElement>>;
97
+ export declare const Kbd: React.ForwardRefExoticComponent<KbdProps & React.RefAttributes<HTMLElement>> & {
98
+ Group: React.ForwardRefExoticComponent<KbdGroupProps & React.RefAttributes<HTMLElement>>;
99
+ };
100
+ export default Kbd;
@@ -88,11 +88,26 @@ export interface AutocompleteProps extends Omit<React.HTMLAttributes<HTMLDivElem
88
88
  onInfiniteScroll?: () => void;
89
89
  /** Custom render for items. */
90
90
  itemTemplate?: (item: AutocompleteItem | string) => React.ReactNode;
91
- /** Custom header in dropdown. */
91
+ /** Custom header at the top of the dropdown. It sits above the list of options rather than in it, so assistive technology doesn't count it as one. */
92
92
  header?: React.ReactNode;
93
- /** Custom footer in dropdown. */
93
+ /** Custom footer at the bottom of the dropdown. It sits below the list of options rather than in it, so assistive technology doesn't count it as one. */
94
94
  footer?: React.ReactNode;
95
- /** Content to show when no results. */
95
+ /**
96
+ * A message the dropdown shows in place of the options when nothing
97
+ * matches. Keep it to text: `Tab` closes the list, so a keyboard user
98
+ * can't reach a link or button in it. It sits beside the list of options
99
+ * rather than in it, so the input's `aria-expanded` stays false while it
100
+ * shows. When the user's typing leaves nothing that matches, a polite
101
+ * status region announces its text: once each time the matches run out.
102
+ * The text is read when they first run out, and isn't read again as it
103
+ * changes while they stay out, so a message that names the query is heard
104
+ * for that first query only. Keep it static.
105
+ * Opening the list without typing, or emptying the field, announces
106
+ * nothing. While `loading`, or a `Control` with `isLoading` around the
107
+ * Autocomplete, is on, it waits, and it's announced once loading ends
108
+ * with nothing matching. Without `empty`, the dropdown closes when nothing
109
+ * matches and nothing is announced.
110
+ */
96
111
  empty?: React.ReactNode;
97
112
  }
98
113
  /**
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ /**
3
+ * A component's children as a flat list, with each Fragment opened up
4
+ * (recursively) so the items inside one count one by one rather than as the
5
+ * Fragment. `Children.toArray` already drops `null`, `undefined` and
6
+ * booleans and flattens arrays, but it keeps a Fragment whole, so an empty
7
+ * one would still count as an item and two items in one would count as one.
8
+ *
9
+ * `Children.toArray` keys restart at ".0" inside each Fragment, so the items
10
+ * in one are re-keyed with the Fragment's own key as a prefix. Otherwise an
11
+ * item in a Fragment and a sibling outside it could share a key.
12
+ *
13
+ * Text and numbers pass through as they are, so a caller that wants only
14
+ * elements filters with `React.isValidElement`.
15
+ */
16
+ export declare function flattenChildren(children: React.ReactNode, keyPrefix?: string): React.ReactNode[];
@@ -43,10 +43,10 @@ export interface StatusRegionProps<Item extends {
43
43
  describe: (item: Item) => string | null;
44
44
  }
45
45
  /**
46
- * A visually hidden, polite `status` live region that a programmatic
47
- * container announces its items through. The container renders it from the
48
- * moment it mounts, whether or not it has anything to show, so the region is
49
- * already in the page when an announcement is written into it.
46
+ * A visually hidden, polite `status` live region that a container announces
47
+ * its items through. The container renders it from the moment it mounts,
48
+ * whether or not it has anything to show, so the region is already in the
49
+ * page when an announcement is written into it.
50
50
  *
51
51
  * The announcements are this component's own state, so writing and clearing
52
52
  * them re-renders the region and leaves the container's items alone. Each one
@@ -42,6 +42,7 @@ export * from './elements/Figure.js';
42
42
  export * from './elements/Icon.js';
43
43
  export * from './elements/IconText.js';
44
44
  export * from './elements/Image.js';
45
+ export * from './elements/Kbd.js';
45
46
  export * from './elements/Link.js';
46
47
  export * from './elements/ListItem.js';
47
48
  export * from './elements/Loader.js';
@@ -0,0 +1,100 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
3
+ /**
4
+ * Props for the Kbd component. The helper props, the other attributes and
5
+ * the `ref` land on the `<kbd>`.
6
+ *
7
+ * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<kbd>`.
8
+ */
9
+ export interface KbdProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
10
+ /** Additional CSS classes to apply. */
11
+ className?: string;
12
+ /**
13
+ * The key as it's printed on the keyboard: a word (`Ctrl`, `Esc`), a
14
+ * letter, or a symbol (`⌘`).
15
+ */
16
+ children?: React.ReactNode;
17
+ /**
18
+ * What a screen reader says in place of a symbol, in your app's language:
19
+ * `label="Command"` on `⌘`. The symbol is hidden from assistive tech with
20
+ * `aria-hidden`, and the label is read in its place, from text that's
21
+ * visually hidden. Use it for a glyph that isn't a word, such as `⌘`, `⌥`,
22
+ * `⇧`, `⌃` or `⏎`, and leave it off a key written as a word. Copying the
23
+ * key copies the label along with the glyph. Don't reach for `aria-label`
24
+ * instead: ARIA in HTML prohibits naming a `<kbd>`, so nothing obliges a
25
+ * screen reader to read it.
26
+ */
27
+ label?: string;
28
+ /**
29
+ * Text color helper. The key's edge and fill are mixed from its text
30
+ * color, so they follow it.
31
+ */
32
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
33
+ /**
34
+ * Background color helper. It replaces the key's faint fill, and the text
35
+ * still follows the text around it, which turns light in dark mode, so pair
36
+ * it with a `textColor` that reads on that color in both schemes, such as
37
+ * `textColor="black"` on `bgColor="warning"`.
38
+ */
39
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
40
+ }
41
+ /**
42
+ * Props for Kbd.Group, keys pressed together or one after another. The
43
+ * group renders the outer `<kbd>` of a combination, and the helper props,
44
+ * the other attributes and the `ref` land on it.
45
+ *
46
+ * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the outer `<kbd>`.
47
+ */
48
+ export interface KbdGroupProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
49
+ /** Additional CSS classes to apply. */
50
+ className?: string;
51
+ /**
52
+ * The keys, a `Kbd` each, in the order they're pressed. The group renders
53
+ * the outer `<kbd>` around them, so it doesn't go inside a `Kbd` of its
54
+ * own, and it puts the separator between them, so don't type one: a `+`
55
+ * of your own doubles up. A `null` or `false` child, or an empty Fragment,
56
+ * gets no separator, and the keys in a Fragment are separated like the
57
+ * rest. A component that renders nothing still gets one, since the group
58
+ * can't see what a child renders, so write a conditional key inline
59
+ * (`{isMac && <Kbd label="Command">⌘</Kbd>}`), not in a component of its
60
+ * own.
61
+ */
62
+ children?: React.ReactNode;
63
+ /**
64
+ * What goes between the keys, shown and read aloud, with a space either
65
+ * side. Use `'then'` for a sequence pressed one key after another. It's a
66
+ * string because a screen reader has to read it.
67
+ */
68
+ separator?: string;
69
+ /** Text color helper. The keys and separators inside follow it. */
70
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
71
+ }
72
+ /**
73
+ * Keys pressed together or one after another, in the outer `<kbd>` HTML gives a combination, with the separator between each pair as text.
74
+ *
75
+ * It doesn't wrap in the middle and isn't drawn as a key itself. It sets no
76
+ * font size, so the keys in it are the size of a key on its own.
77
+ *
78
+ * @function
79
+ * @param {KbdGroupProps} props - Props for Kbd.Group.
80
+ * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the outer `<kbd>`.
81
+ * @returns {JSX.Element} The rendered combination.
82
+ *
83
+ * @example
84
+ * <Kbd.Group>
85
+ * <Kbd>Ctrl</Kbd>
86
+ * <Kbd>Shift</Kbd>
87
+ * <Kbd>P</Kbd>
88
+ * </Kbd.Group>
89
+ *
90
+ * @example
91
+ * <Kbd.Group separator="then">
92
+ * <Kbd>G</Kbd>
93
+ * <Kbd>I</Kbd>
94
+ * </Kbd.Group>
95
+ */
96
+ export declare const KbdGroup: React.ForwardRefExoticComponent<KbdGroupProps & React.RefAttributes<HTMLElement>>;
97
+ export declare const Kbd: React.ForwardRefExoticComponent<KbdProps & React.RefAttributes<HTMLElement>> & {
98
+ Group: React.ForwardRefExoticComponent<KbdGroupProps & React.RefAttributes<HTMLElement>>;
99
+ };
100
+ export default Kbd;
@@ -88,11 +88,26 @@ export interface AutocompleteProps extends Omit<React.HTMLAttributes<HTMLDivElem
88
88
  onInfiniteScroll?: () => void;
89
89
  /** Custom render for items. */
90
90
  itemTemplate?: (item: AutocompleteItem | string) => React.ReactNode;
91
- /** Custom header in dropdown. */
91
+ /** Custom header at the top of the dropdown. It sits above the list of options rather than in it, so assistive technology doesn't count it as one. */
92
92
  header?: React.ReactNode;
93
- /** Custom footer in dropdown. */
93
+ /** Custom footer at the bottom of the dropdown. It sits below the list of options rather than in it, so assistive technology doesn't count it as one. */
94
94
  footer?: React.ReactNode;
95
- /** Content to show when no results. */
95
+ /**
96
+ * A message the dropdown shows in place of the options when nothing
97
+ * matches. Keep it to text: `Tab` closes the list, so a keyboard user
98
+ * can't reach a link or button in it. It sits beside the list of options
99
+ * rather than in it, so the input's `aria-expanded` stays false while it
100
+ * shows. When the user's typing leaves nothing that matches, a polite
101
+ * status region announces its text: once each time the matches run out.
102
+ * The text is read when they first run out, and isn't read again as it
103
+ * changes while they stay out, so a message that names the query is heard
104
+ * for that first query only. Keep it static.
105
+ * Opening the list without typing, or emptying the field, announces
106
+ * nothing. While `loading`, or a `Control` with `isLoading` around the
107
+ * Autocomplete, is on, it waits, and it's announced once loading ends
108
+ * with nothing matching. Without `empty`, the dropdown closes when nothing
109
+ * matches and nothing is announced.
110
+ */
96
111
  empty?: React.ReactNode;
97
112
  }
98
113
  /**
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ /**
3
+ * A component's children as a flat list, with each Fragment opened up
4
+ * (recursively) so the items inside one count one by one rather than as the
5
+ * Fragment. `Children.toArray` already drops `null`, `undefined` and
6
+ * booleans and flattens arrays, but it keeps a Fragment whole, so an empty
7
+ * one would still count as an item and two items in one would count as one.
8
+ *
9
+ * `Children.toArray` keys restart at ".0" inside each Fragment, so the items
10
+ * in one are re-keyed with the Fragment's own key as a prefix. Otherwise an
11
+ * item in a Fragment and a sibling outside it could share a key.
12
+ *
13
+ * Text and numbers pass through as they are, so a caller that wants only
14
+ * elements filters with `React.isValidElement`.
15
+ */
16
+ export declare function flattenChildren(children: React.ReactNode, keyPrefix?: string): React.ReactNode[];
@@ -43,10 +43,10 @@ export interface StatusRegionProps<Item extends {
43
43
  describe: (item: Item) => string | null;
44
44
  }
45
45
  /**
46
- * A visually hidden, polite `status` live region that a programmatic
47
- * container announces its items through. The container renders it from the
48
- * moment it mounts, whether or not it has anything to show, so the region is
49
- * already in the page when an announcement is written into it.
46
+ * A visually hidden, polite `status` live region that a container announces
47
+ * its items through. The container renders it from the moment it mounts,
48
+ * whether or not it has anything to show, so the region is already in the
49
+ * page when an announcement is written into it.
50
50
  *
51
51
  * The announcements are this component's own state, so writing and clearing
52
52
  * them re-renders the region and leaves the container's items alone. Each one
@@ -42,6 +42,7 @@ export * from './elements/Figure.js';
42
42
  export * from './elements/Icon.js';
43
43
  export * from './elements/IconText.js';
44
44
  export * from './elements/Image.js';
45
+ export * from './elements/Kbd.js';
45
46
  export * from './elements/Link.js';
46
47
  export * from './elements/ListItem.js';
47
48
  export * from './elements/Loader.js';