@allxsmith/bestax-bulma 5.32.0 → 5.33.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 (33) 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/helpers/flattenChildren.js +35 -0
  10. package/dist/esm/helpers/flattenChildren.js.map +1 -0
  11. package/dist/extras.css +1 -1
  12. package/dist/extras.css.map +1 -1
  13. package/dist/index.cjs +177 -108
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.esm.js +1 -0
  16. package/dist/index.esm.js.map +1 -1
  17. package/dist/types/elements/Kbd.d.ts +100 -0
  18. package/dist/types/helpers/flattenChildren.d.ts +16 -0
  19. package/dist/types/index.d.ts +1 -0
  20. package/dist/types-cjs/elements/Kbd.d.ts +100 -0
  21. package/dist/types-cjs/helpers/flattenChildren.d.ts +16 -0
  22. package/dist/types-cjs/index.d.ts +1 -0
  23. package/dist/versions/bestax-no-dark-mode.css +1 -1
  24. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  25. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  26. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  27. package/dist/versions/bestax-no-helpers.css +1 -1
  28. package/dist/versions/bestax-no-helpers.css.map +1 -1
  29. package/dist/versions/bestax-prefixed.css +1 -1
  30. package/dist/versions/bestax-prefixed.css.map +1 -1
  31. package/package.json +1 -1
  32. package/src/scss/elements/_index.scss +1 -0
  33. 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;
@@ -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[];
@@ -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;
@@ -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[];
@@ -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';