@allxsmith/bestax-bulma 5.48.1 → 5.49.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 (38) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/form/_pickerInternals/segmentMap.js +7 -7
  4. package/dist/esm/form/_pickerInternals/segmentMap.js.map +1 -1
  5. package/dist/esm/helpers/splitterLayout.js +166 -0
  6. package/dist/esm/helpers/splitterLayout.js.map +1 -0
  7. package/dist/esm/layout/Splitter.js +374 -0
  8. package/dist/esm/layout/Splitter.js.map +1 -0
  9. package/dist/extras.css +1 -1
  10. package/dist/extras.css.map +1 -1
  11. package/dist/index.cjs +533 -7
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.esm.js +1 -0
  14. package/dist/index.esm.js.map +1 -1
  15. package/dist/types/helpers/splitterLayout.d.ts +62 -0
  16. package/dist/types/index.d.ts +1 -0
  17. package/dist/types/layout/Splitter.d.ts +125 -0
  18. package/dist/types-cjs/helpers/splitterLayout.d.ts +62 -0
  19. package/dist/types-cjs/index.d.ts +1 -0
  20. package/dist/types-cjs/layout/Splitter.d.ts +125 -0
  21. package/dist/versions/bestax-no-dark-mode.css +1 -1
  22. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  23. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  24. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  25. package/dist/versions/bestax-no-helpers.css +1 -1
  26. package/dist/versions/bestax-no-helpers.css.map +1 -1
  27. package/dist/versions/bestax-prefixed.css +1 -1
  28. package/dist/versions/bestax-prefixed.css.map +1 -1
  29. package/package.json +1 -1
  30. package/src/scss/CLAUDE.md +1 -1
  31. package/src/scss/bestax.scss +1 -0
  32. package/src/scss/extras.scss +3 -0
  33. package/src/scss/layout/_index.scss +5 -0
  34. package/src/scss/layout/_splitter.scss +184 -0
  35. package/src/scss/versions/bestax-no-dark-mode.scss +1 -0
  36. package/src/scss/versions/bestax-no-helpers-prefixed.scss +1 -0
  37. package/src/scss/versions/bestax-no-helpers.scss +1 -0
  38. package/src/scss/versions/bestax-prefixed.scss +1 -0
package/dist/index.esm.js CHANGED
@@ -118,6 +118,7 @@ export { Hero, HeroBody, HeroFoot, HeroHead } from './esm/layout/Hero.js';
118
118
  export { Level, LevelItem, LevelLeft, LevelRight } from './esm/layout/Level.js';
119
119
  export { Media, MediaContent, MediaLeft, MediaRight } from './esm/layout/Media.js';
120
120
  export { Section } from './esm/layout/Section.js';
121
+ export { Splitter, SplitterPane } from './esm/layout/Splitter.js';
121
122
  export { useColorClasses, useColorStyles } from './esm/helpers/useColorClasses.js';
122
123
  export { useFlexboxClasses } from './esm/helpers/useFlexboxClasses.js';
123
124
  export { useOtherClasses } from './esm/helpers/useOtherClasses.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,62 @@
1
+ /** What one pane may be: its limits in percent, and whether it can shut. */
2
+ export interface PaneBounds {
3
+ min: number;
4
+ max: number;
5
+ collapsible: boolean;
6
+ }
7
+ /** A limit as written: a percentage, or a CSS length in px, rem or %. */
8
+ export type SplitterLimit = number | string;
9
+ /**
10
+ * A limit in percent of `length` pixels. A number or a `%` is already one. A
11
+ * `px` or `rem` length needs the length the panes share, and without it
12
+ * there's no answer yet, so it's `null`. Anything else is `null` too.
13
+ */
14
+ export declare function limitToPercent(limit: SplitterLimit | undefined, length: number | null, remPx: number): number | null;
15
+ /**
16
+ * The sizes panes start at: each its `defaultSize`, and the ones without
17
+ * one sharing what's left equally. When they all have one, or those that do
18
+ * take more than 100, the given ones are scaled to fit.
19
+ */
20
+ export declare function defaultSizes(defaults: (number | undefined)[]): number[];
21
+ /**
22
+ * Moves each pane into its limits, taking what it needs from the nearest
23
+ * panes with room to give, or giving what it has too much of to the nearest
24
+ * with room to take. A shut pane stays shut. Limits that can't all hold are
25
+ * met as far as they can be.
26
+ */
27
+ export declare function fitSizes(sizes: number[], bounds: PaneBounds[]): number[];
28
+ /** Whether two layouts are the same, to within rounding. */
29
+ export declare const sameSizes: (a: number[], b: number[]) => boolean;
30
+ /**
31
+ * The pane a handle speaks for: the one before it, unless only the one after
32
+ * it can shut, so that Enter shuts the pane you'd expect.
33
+ */
34
+ export declare const primaryOf: (handle: number, bounds: PaneBounds[]) => number;
35
+ /**
36
+ * How far the pane before handle `a`'s line can go, between the two panes
37
+ * beside it: `low` to `high` while both stay open, and `shut` and `full`
38
+ * when one of them can close.
39
+ */
40
+ export declare function pairRange(sizes: number[], a: number, bounds: PaneBounds[]): {
41
+ total: number;
42
+ low: number;
43
+ high: number;
44
+ shut: boolean;
45
+ full: boolean;
46
+ };
47
+ /**
48
+ * The layout with the line of handle `a` moved so the pane before it is
49
+ * `target`, within both panes' limits. A collapsible pane dragged below half
50
+ * its minimum shuts, and one that's shut opens at its minimum once dragged
51
+ * past that point.
52
+ */
53
+ export declare function resizePair(sizes: number[], a: number, target: number, bounds: PaneBounds[]): number[];
54
+ /**
55
+ * The aria value range of a handle's primary pane: zero at the bottom when
56
+ * it can shut, everything the pair holds at the top when the other pane can.
57
+ */
58
+ export declare function primaryRange(sizes: number[], a: number, primary: number, bounds: PaneBounds[]): {
59
+ now: number;
60
+ min: number;
61
+ max: number;
62
+ };
@@ -136,3 +136,4 @@ export * from './layout/Hero.js';
136
136
  export * from './layout/Level.js';
137
137
  export * from './layout/Media.js';
138
138
  export * from './layout/Section.js';
139
+ export * from './layout/Splitter.js';
@@ -0,0 +1,125 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
3
+ import { SplitterLimit } from '../helpers/splitterLayout.js';
4
+ /** The way the panes run: side by side, or one above the other. */
5
+ export type SplitterOrientation = 'horizontal' | 'vertical';
6
+ /**
7
+ * Props for Splitter.Pane, one of the panes. The helper props, the other
8
+ * attributes and the `ref` land on its `<div>`.
9
+ *
10
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the pane's `<div>`.
11
+ * @extraProp {string} [id] - The pane's id, which its handle's `aria-controls` points at. The splitter makes one when there's none.
12
+ */
13
+ export interface SplitterPaneProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
14
+ /** Additional CSS classes to apply. */
15
+ className?: string;
16
+ /**
17
+ * What the pane is, such as "Files". It names the handle that speaks for
18
+ * this pane, which is announced as "Files, separator, 25". That's the
19
+ * handle after it, or the one before it when only this pane, of the two
20
+ * beside that handle, can collapse. A development build warns when a
21
+ * handle's pane has none.
22
+ */
23
+ label?: string;
24
+ /**
25
+ * Its starting size, in percent of the room the panes share. Panes without
26
+ * one share what's left equally, and a total over 100 is scaled down.
27
+ */
28
+ defaultSize?: number;
29
+ /**
30
+ * The smallest it can be dragged: a percentage, or a CSS length in `px` or
31
+ * `rem` such as `"12rem"`. A length applies once the splitter has measured
32
+ * itself in the browser, so the server renders the default size.
33
+ */
34
+ minSize?: SplitterLimit;
35
+ /** The largest it can be dragged, in the same units as `minSize`. */
36
+ maxSize?: SplitterLimit;
37
+ /**
38
+ * Lets it collapse: dragging it below half its `minSize` shuts it, and
39
+ * Enter on its handle shuts it and brings it back at the size it had. It
40
+ * collapses only when the pane across its handle can take its room within
41
+ * that pane's `maxSize`, since a handle moves only the two panes beside it.
42
+ * A collapsed pane stays mounted, hidden, so it keeps its state.
43
+ */
44
+ collapsible?: boolean;
45
+ /**
46
+ * Whether it's collapsed, for a `collapsible` pane. With it, the state is
47
+ * yours: a drag, a key or a double-click that would collapse it or bring
48
+ * it back calls `onCollapsedChange` and leaves it as it is, and it changes
49
+ * when `collapsed` does.
50
+ */
51
+ collapsed?: boolean;
52
+ /** Whether a `collapsible` pane starts collapsed. */
53
+ defaultCollapsed?: boolean;
54
+ /**
55
+ * Called when a drag, a key or a double-click collapses it or brings it
56
+ * back, or, with `collapsed`, would. Not called for a change you made with
57
+ * `collapsed`.
58
+ */
59
+ onCollapsedChange?: (collapsed: boolean) => void;
60
+ /** What's in it. Content that scrolls belongs in a `ScrollArea`, so a keyboard can reach it. */
61
+ children?: React.ReactNode;
62
+ /** Text color helper. */
63
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
64
+ /** Background color helper. */
65
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
66
+ }
67
+ /**
68
+ * Props for the Splitter component. The helper props, the other attributes
69
+ * and the `ref` land on the root `<div>`.
70
+ *
71
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the root `<div>`.
72
+ */
73
+ export interface SplitterProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
74
+ /** Additional CSS classes to apply. */
75
+ className?: string;
76
+ /**
77
+ * `Splitter.Pane`s, two or more, each a direct child, with Fragments
78
+ * opened up. A handle goes between each pair. Changing which panes there
79
+ * are puts every pane back to its default size.
80
+ */
81
+ children?: React.ReactNode;
82
+ /**
83
+ * The way the panes run: side by side (`horizontal`) or one above the
84
+ * other (`vertical`).
85
+ */
86
+ orientation?: SplitterOrientation;
87
+ /**
88
+ * The splitter's height. A number is pixels, and a string any CSS length.
89
+ * A vertical splitter needs a height to split.
90
+ */
91
+ height?: number | string;
92
+ /**
93
+ * Each pane's size, in percent, in order, adding up to 100. With it, the
94
+ * sizes are yours: update them from `onSizesChange`. Without it, each
95
+ * pane starts at its `defaultSize`.
96
+ */
97
+ sizes?: number[];
98
+ /**
99
+ * Called with every pane's size, in percent, whenever they change: on
100
+ * each step of a drag or a key, on a collapse and on a reset.
101
+ */
102
+ onSizesChange?: (sizes: number[]) => void;
103
+ /**
104
+ * How far an arrow key moves a handle, in percent. Shift moves ten times
105
+ * as far.
106
+ */
107
+ step?: number;
108
+ /** Text color helper. */
109
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
110
+ /** Background color helper. */
111
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
112
+ }
113
+ /**
114
+ * One pane of a Splitter, sized by the splitter around it.
115
+ *
116
+ * @function
117
+ * @param {SplitterPaneProps} props - Props for Splitter.Pane.
118
+ * @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the pane's `<div>`.
119
+ * @returns {JSX.Element} The rendered pane.
120
+ */
121
+ export declare const SplitterPane: React.ForwardRefExoticComponent<SplitterPaneProps & React.RefAttributes<HTMLDivElement>>;
122
+ export declare const Splitter: React.ForwardRefExoticComponent<SplitterProps & React.RefAttributes<HTMLDivElement>> & {
123
+ Pane: React.ForwardRefExoticComponent<SplitterPaneProps & React.RefAttributes<HTMLDivElement>>;
124
+ };
125
+ export default Splitter;
@@ -0,0 +1,62 @@
1
+ /** What one pane may be: its limits in percent, and whether it can shut. */
2
+ export interface PaneBounds {
3
+ min: number;
4
+ max: number;
5
+ collapsible: boolean;
6
+ }
7
+ /** A limit as written: a percentage, or a CSS length in px, rem or %. */
8
+ export type SplitterLimit = number | string;
9
+ /**
10
+ * A limit in percent of `length` pixels. A number or a `%` is already one. A
11
+ * `px` or `rem` length needs the length the panes share, and without it
12
+ * there's no answer yet, so it's `null`. Anything else is `null` too.
13
+ */
14
+ export declare function limitToPercent(limit: SplitterLimit | undefined, length: number | null, remPx: number): number | null;
15
+ /**
16
+ * The sizes panes start at: each its `defaultSize`, and the ones without
17
+ * one sharing what's left equally. When they all have one, or those that do
18
+ * take more than 100, the given ones are scaled to fit.
19
+ */
20
+ export declare function defaultSizes(defaults: (number | undefined)[]): number[];
21
+ /**
22
+ * Moves each pane into its limits, taking what it needs from the nearest
23
+ * panes with room to give, or giving what it has too much of to the nearest
24
+ * with room to take. A shut pane stays shut. Limits that can't all hold are
25
+ * met as far as they can be.
26
+ */
27
+ export declare function fitSizes(sizes: number[], bounds: PaneBounds[]): number[];
28
+ /** Whether two layouts are the same, to within rounding. */
29
+ export declare const sameSizes: (a: number[], b: number[]) => boolean;
30
+ /**
31
+ * The pane a handle speaks for: the one before it, unless only the one after
32
+ * it can shut, so that Enter shuts the pane you'd expect.
33
+ */
34
+ export declare const primaryOf: (handle: number, bounds: PaneBounds[]) => number;
35
+ /**
36
+ * How far the pane before handle `a`'s line can go, between the two panes
37
+ * beside it: `low` to `high` while both stay open, and `shut` and `full`
38
+ * when one of them can close.
39
+ */
40
+ export declare function pairRange(sizes: number[], a: number, bounds: PaneBounds[]): {
41
+ total: number;
42
+ low: number;
43
+ high: number;
44
+ shut: boolean;
45
+ full: boolean;
46
+ };
47
+ /**
48
+ * The layout with the line of handle `a` moved so the pane before it is
49
+ * `target`, within both panes' limits. A collapsible pane dragged below half
50
+ * its minimum shuts, and one that's shut opens at its minimum once dragged
51
+ * past that point.
52
+ */
53
+ export declare function resizePair(sizes: number[], a: number, target: number, bounds: PaneBounds[]): number[];
54
+ /**
55
+ * The aria value range of a handle's primary pane: zero at the bottom when
56
+ * it can shut, everything the pair holds at the top when the other pane can.
57
+ */
58
+ export declare function primaryRange(sizes: number[], a: number, primary: number, bounds: PaneBounds[]): {
59
+ now: number;
60
+ min: number;
61
+ max: number;
62
+ };
@@ -136,3 +136,4 @@ export * from './layout/Hero.js';
136
136
  export * from './layout/Level.js';
137
137
  export * from './layout/Media.js';
138
138
  export * from './layout/Section.js';
139
+ export * from './layout/Splitter.js';
@@ -0,0 +1,125 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
3
+ import { SplitterLimit } from '../helpers/splitterLayout.js';
4
+ /** The way the panes run: side by side, or one above the other. */
5
+ export type SplitterOrientation = 'horizontal' | 'vertical';
6
+ /**
7
+ * Props for Splitter.Pane, one of the panes. The helper props, the other
8
+ * attributes and the `ref` land on its `<div>`.
9
+ *
10
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the pane's `<div>`.
11
+ * @extraProp {string} [id] - The pane's id, which its handle's `aria-controls` points at. The splitter makes one when there's none.
12
+ */
13
+ export interface SplitterPaneProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
14
+ /** Additional CSS classes to apply. */
15
+ className?: string;
16
+ /**
17
+ * What the pane is, such as "Files". It names the handle that speaks for
18
+ * this pane, which is announced as "Files, separator, 25". That's the
19
+ * handle after it, or the one before it when only this pane, of the two
20
+ * beside that handle, can collapse. A development build warns when a
21
+ * handle's pane has none.
22
+ */
23
+ label?: string;
24
+ /**
25
+ * Its starting size, in percent of the room the panes share. Panes without
26
+ * one share what's left equally, and a total over 100 is scaled down.
27
+ */
28
+ defaultSize?: number;
29
+ /**
30
+ * The smallest it can be dragged: a percentage, or a CSS length in `px` or
31
+ * `rem` such as `"12rem"`. A length applies once the splitter has measured
32
+ * itself in the browser, so the server renders the default size.
33
+ */
34
+ minSize?: SplitterLimit;
35
+ /** The largest it can be dragged, in the same units as `minSize`. */
36
+ maxSize?: SplitterLimit;
37
+ /**
38
+ * Lets it collapse: dragging it below half its `minSize` shuts it, and
39
+ * Enter on its handle shuts it and brings it back at the size it had. It
40
+ * collapses only when the pane across its handle can take its room within
41
+ * that pane's `maxSize`, since a handle moves only the two panes beside it.
42
+ * A collapsed pane stays mounted, hidden, so it keeps its state.
43
+ */
44
+ collapsible?: boolean;
45
+ /**
46
+ * Whether it's collapsed, for a `collapsible` pane. With it, the state is
47
+ * yours: a drag, a key or a double-click that would collapse it or bring
48
+ * it back calls `onCollapsedChange` and leaves it as it is, and it changes
49
+ * when `collapsed` does.
50
+ */
51
+ collapsed?: boolean;
52
+ /** Whether a `collapsible` pane starts collapsed. */
53
+ defaultCollapsed?: boolean;
54
+ /**
55
+ * Called when a drag, a key or a double-click collapses it or brings it
56
+ * back, or, with `collapsed`, would. Not called for a change you made with
57
+ * `collapsed`.
58
+ */
59
+ onCollapsedChange?: (collapsed: boolean) => void;
60
+ /** What's in it. Content that scrolls belongs in a `ScrollArea`, so a keyboard can reach it. */
61
+ children?: React.ReactNode;
62
+ /** Text color helper. */
63
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
64
+ /** Background color helper. */
65
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
66
+ }
67
+ /**
68
+ * Props for the Splitter component. The helper props, the other attributes
69
+ * and the `ref` land on the root `<div>`.
70
+ *
71
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the root `<div>`.
72
+ */
73
+ export interface SplitterProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
74
+ /** Additional CSS classes to apply. */
75
+ className?: string;
76
+ /**
77
+ * `Splitter.Pane`s, two or more, each a direct child, with Fragments
78
+ * opened up. A handle goes between each pair. Changing which panes there
79
+ * are puts every pane back to its default size.
80
+ */
81
+ children?: React.ReactNode;
82
+ /**
83
+ * The way the panes run: side by side (`horizontal`) or one above the
84
+ * other (`vertical`).
85
+ */
86
+ orientation?: SplitterOrientation;
87
+ /**
88
+ * The splitter's height. A number is pixels, and a string any CSS length.
89
+ * A vertical splitter needs a height to split.
90
+ */
91
+ height?: number | string;
92
+ /**
93
+ * Each pane's size, in percent, in order, adding up to 100. With it, the
94
+ * sizes are yours: update them from `onSizesChange`. Without it, each
95
+ * pane starts at its `defaultSize`.
96
+ */
97
+ sizes?: number[];
98
+ /**
99
+ * Called with every pane's size, in percent, whenever they change: on
100
+ * each step of a drag or a key, on a collapse and on a reset.
101
+ */
102
+ onSizesChange?: (sizes: number[]) => void;
103
+ /**
104
+ * How far an arrow key moves a handle, in percent. Shift moves ten times
105
+ * as far.
106
+ */
107
+ step?: number;
108
+ /** Text color helper. */
109
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
110
+ /** Background color helper. */
111
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
112
+ }
113
+ /**
114
+ * One pane of a Splitter, sized by the splitter around it.
115
+ *
116
+ * @function
117
+ * @param {SplitterPaneProps} props - Props for Splitter.Pane.
118
+ * @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the pane's `<div>`.
119
+ * @returns {JSX.Element} The rendered pane.
120
+ */
121
+ export declare const SplitterPane: React.ForwardRefExoticComponent<SplitterPaneProps & React.RefAttributes<HTMLDivElement>>;
122
+ export declare const Splitter: React.ForwardRefExoticComponent<SplitterProps & React.RefAttributes<HTMLDivElement>> & {
123
+ Pane: React.ForwardRefExoticComponent<SplitterPaneProps & React.RefAttributes<HTMLDivElement>>;
124
+ };
125
+ export default Splitter;