@graphty/compact-mantine 0.9.26 → 0.9.28

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.
package/dist/index.d.cts CHANGED
@@ -1873,58 +1873,6 @@ export declare interface ControlSectionProps extends DisclosureProps {
1873
1873
  collapsible?: boolean;
1874
1874
  }
1875
1875
 
1876
- /**
1877
- * A collapsible sub-group of controls, lighter than a section.
1878
- *
1879
- * Prefer an `AdvancedButton` that opens a pop-out: that is how Figma keeps rare
1880
- * settings off the panel. Where a fold inside the section is still wanted, this
1881
- * draws it the Figma way: a 32px row whose chevron hangs in the 16px gutter to
1882
- * the left of the section's content edge, and a label in the secondary text
1883
- * color that comes up to the primary one under the pointer. The content opens
1884
- * in one frame, on the same grid as the rows around it.
1885
- *
1886
- * The header is one button carrying the open state, and the controls it reveals
1887
- * are a labeled region that the button points at. Nothing inside a closed
1888
- * sub-group can be reached by Tab.
1889
- *
1890
- * Drive it from your own state with `opened` and `onOpenChange`, or leave both
1891
- * out and let it remember its own with `defaultOpened`.
1892
- * @param props - Component props
1893
- * @param props.label - The sub-group's name, drawn beside its chevron
1894
- * @param props.opened - Whether the sub-group is open, when you drive it from your own state
1895
- * @param props.defaultOpened - Whether it starts open when it keeps its own state, defaulting to false
1896
- * @param props.onOpenChange - Called when it opens or closes, with the new state first and the event second
1897
- * @param props.children - The controls the sub-group holds
1898
- * @returns The sub-group, its header and its controls
1899
- * @example
1900
- * ```tsx
1901
- * <ControlSection label="Labels">
1902
- * <ToggleRow label="Labels" defaultChecked />
1903
- * <ControlSubGroup label="Text effects" defaultOpened={false}>
1904
- * <ToggleRow label="Outline" />
1905
- * <ToggleRow label="Shadow" />
1906
- * </ControlSubGroup>
1907
- * </ControlSection>
1908
- * ```
1909
- */
1910
- export declare function ControlSubGroup(props: ControlSubGroupProps): default_2.JSX.Element;
1911
-
1912
- /**
1913
- * Props for the ControlSubGroup component.
1914
- */
1915
- export declare interface ControlSubGroupProps extends DisclosureProps {
1916
- /**
1917
- * The sub-group's name, drawn beside its chevron.
1918
- *
1919
- * One to three words in sentence case. It is also the accessible name of
1920
- * the header button, prefixed with "Expand" or "Collapse", and the name of
1921
- * the region the header opens.
1922
- */
1923
- label: string;
1924
- /** The controls the sub-group holds, stacked in the order you write them. */
1925
- children: default_2.ReactNode;
1926
- }
1927
-
1928
1876
  /**
1929
1877
  * Creates a new ColorStop with a unique ID.
1930
1878
  * @param offset - The position of the stop (0-1)
@@ -4083,6 +4031,11 @@ export declare interface PanelFieldProps extends Omit<default_2.ComponentPropsWi
4083
4031
  max?: number;
4084
4032
  /** How much one press of an arrow key changes a number field. Shift moves ten. */
4085
4033
  step?: number;
4034
+ /**
4035
+ * How many digits after the decimal separator a number field keeps. A
4036
+ * committed value is rounded to it, so `0` makes an integer field.
4037
+ */
4038
+ decimalScale?: number;
4086
4039
  /**
4087
4040
  * What a number field says about its arrow keys, after its name and value,
4088
4041
  * as its `aria-description`. Pass an empty string to say nothing.
@@ -4126,6 +4079,16 @@ export declare interface PanelFieldProps extends Omit<default_2.ComponentPropsWi
4126
4079
  * announced as unavailable.
4127
4080
  */
4128
4081
  disabled?: boolean;
4082
+ /**
4083
+ * One sentence saying why the field is off, used only while `disabled` is
4084
+ * true.
4085
+ *
4086
+ * It is appended to the field's name after a full stop in the tooltip --
4087
+ * "Size. Load data first" -- and joins the field's accessible description,
4088
+ * so a screen reader reads the reason instead of announcing an unexplained
4089
+ * unavailable field.
4090
+ */
4091
+ disabledReason?: string;
4129
4092
  /**
4130
4093
  * Whether the value can be read but not changed.
4131
4094
  *
@@ -5407,6 +5370,50 @@ export declare function renameTreeItem<T extends TreeLike<T> & {
5407
5370
  name: string;
5408
5371
  }>(items: readonly T[], id: string, name: string): T[];
5409
5372
 
5373
+ /**
5374
+ * A small button that gives a row's value back to its default.
5375
+ *
5376
+ * Put it in the row's trailing slot, and draw it only once the reader has set a
5377
+ * value of their own, so a panel of untouched rows stays quiet and a row with a
5378
+ * reset reads as "changed here" (design/figma-spec.md 6.1: the reset sits in the
5379
+ * trailing slot, never inside the field).
5380
+ * @param props - Component props
5381
+ * @param props.label - The name of the control the button resets
5382
+ * @param props.onClick - Called when the button is activated
5383
+ * @param props.disabled - Whether the button cannot be used
5384
+ * @returns The reset button
5385
+ * @example
5386
+ * ```tsx
5387
+ * const [size, setSize] = useState<number | undefined>(undefined);
5388
+ *
5389
+ * <FieldRow trailing={size !== undefined && <ResetButton label="Size" onClick={() => { setSize(undefined); }} />}>
5390
+ * <PanelField label="Size" kind="number" value={size ?? 10} onChange={(next) => { setSize(Number(next)); }} />
5391
+ * </FieldRow>
5392
+ * ```
5393
+ */
5394
+ export declare const ResetButton: default_2.ForwardRefExoticComponent<ResetButtonProps & default_2.RefAttributes<HTMLButtonElement>>;
5395
+
5396
+ /**
5397
+ * Props for the reset button.
5398
+ */
5399
+ export declare interface ResetButtonProps extends Omit<default_2.ButtonHTMLAttributes<HTMLButtonElement>, "color" | "onClick" | "type"> {
5400
+ /**
5401
+ * The name of the control the button resets, such as `"Size"`.
5402
+ *
5403
+ * The button's accessible name and tooltip are built from it -- "Reset
5404
+ * Size to default" in English, and whatever `LabelsProvider` was given
5405
+ * otherwise.
5406
+ */
5407
+ label: string;
5408
+ /** Called when the button is activated, by a click or from the keyboard, with that event. */
5409
+ onClick?: ActivationHandler;
5410
+ /**
5411
+ * Whether the button cannot be used.
5412
+ * @default false
5413
+ */
5414
+ disabled?: boolean;
5415
+ }
5416
+
5410
5417
  /**
5411
5418
  * A handle that resizes a panel by dragging, by the arrow keys, or back to its default size by
5412
5419
  * a double-click.
@@ -5869,249 +5876,6 @@ export declare interface SplitButtonProps extends BoxProps, ElementProps<"div",
5869
5876
  menuProps?: Omit<MenuProps, "children">;
5870
5877
  }
5871
5878
 
5872
- /**
5873
- * A number box that says whether the reader typed its value or inherited it.
5874
- *
5875
- * It is a Mantine `NumberInput` with one idea added: `undefined` means "nothing
5876
- * has been entered here", so the control shows `defaultValue` and offers no
5877
- * reset. As soon as the reader commits a number of their own a reset button
5878
- * appears beside it, and pressing that reset
5879
- * reports `undefined` again. A panel built from these reads at a glance as a
5880
- * list of what has been customized and what has not.
5881
- *
5882
- * The number is committed on Enter, Tab or blur, not on every keystroke, so
5883
- * what the reader is part-way through typing is never sent anywhere and the
5884
- * control never takes the caret away mid-word. What is typed may be arithmetic
5885
- * (`40*2` commits 80); text that is not a number reverts. On commit the number
5886
- * is pulled into `min`..`max` and the box is redrawn showing what was actually
5887
- * kept. ArrowUp and ArrowDown step it at once (Shift: ten steps), Escape
5888
- * abandons what was typed.
5889
- *
5890
- * What the reader types is read in their own locale, so `3,14` is 3.14 wherever
5891
- * the comma is the decimal separator, and the locale's own digits are numbers
5892
- * rather than nonsense. The locale comes from `LabelsProvider`, then from the
5893
- * document, then from the browser.
5894
- *
5895
- * Reach for Mantine's own `NumberInput` for an ordinary form. Reach for this
5896
- * one where a value has a sensible default that the reader is overriding rather
5897
- * than filling in.
5898
- * @param props - Component props
5899
- * @param props.label - The control's name, drawn above it
5900
- * @param props.value - The number, when you drive the control from your own state
5901
- * @param props.defaultValue - What is shown while the reader has entered nothing of their own
5902
- * @param props.onChange - Called with the committed number, or with `undefined` when the control is reset
5903
- * @param props.min - The smallest number accepted
5904
- * @param props.max - The largest number accepted
5905
- * @param props.step - How far the arrow keys move the number
5906
- * @param props.decimalScale - How many digits after the decimal separator to keep
5907
- * @param props.suffix - A unit written after the number
5908
- * @param props.disabled - Whether the control cannot be used at all
5909
- * @param props.disabledReason - One sentence saying why the control is off, drawn only while it is off
5910
- * @param props.onFocus - Called when the control takes focus
5911
- * @param props.onBlur - Called when the control loses focus, after the number has been committed
5912
- * @returns The number box, and its reset button when a number has been entered
5913
- * @example
5914
- * ```tsx
5915
- * const [size, setSize] = useState<number | undefined>(undefined);
5916
- *
5917
- * <StyleNumberInput
5918
- * label="Size"
5919
- * value={size}
5920
- * defaultValue={10}
5921
- * min={1}
5922
- * max={100}
5923
- * suffix="px"
5924
- * onChange={setSize}
5925
- * />
5926
- * ```
5927
- */
5928
- export declare function StyleNumberInput({ label, value, defaultValue, onChange, min, max, step, decimalScale, suffix, disabled, disabledReason, onFocus, onBlur, }: StyleNumberInputProps): default_2.JSX.Element;
5929
-
5930
- /**
5931
- * Props for the StyleNumberInput component.
5932
- */
5933
- export declare interface StyleNumberInputProps {
5934
- /** The control's name, drawn above it and read out as its accessible name. */
5935
- label: string;
5936
- /**
5937
- * The number, when you drive the control from your own state.
5938
- *
5939
- * `undefined` does not mean "empty" here: it means the reader has typed
5940
- * nothing and the control is showing `defaultValue`.
5941
- */
5942
- value?: number | undefined;
5943
- /** What is shown while the reader has entered nothing of their own. */
5944
- defaultValue: number;
5945
- /**
5946
- * Called when the reader commits a number, and with `undefined` when they
5947
- * reset the control to its default.
5948
- *
5949
- * A number is committed when the control loses focus rather than on every
5950
- * keystroke, so a half-typed "1" on the way to "12" is never reported. The
5951
- * event that caused the change is passed second.
5952
- */
5953
- onChange?: ChangeHandler<number | undefined>;
5954
- /** The smallest number accepted. Anything lower is pulled up to it on commit. */
5955
- min?: number;
5956
- /** The largest number accepted. Anything higher is pulled down to it on commit. */
5957
- max?: number;
5958
- /** How far the arrow keys move the number each time. Shift moves ten. */
5959
- step?: number;
5960
- /** How many digits after the decimal separator to keep. */
5961
- decimalScale?: number;
5962
- /** A unit written after the number, such as `"%"` or `"px"`. */
5963
- suffix?: string;
5964
- /**
5965
- * Kept so existing callers still compile; it no longer changes anything.
5966
- *
5967
- * Figma's number fields never draw up and down steppers, so neither does
5968
- * this one; the arrow keys step the number instead.
5969
- * @deprecated The steppers are gone at either value.
5970
- */
5971
- hideControls?: boolean;
5972
- /**
5973
- * Whether the control cannot be used at all.
5974
- *
5975
- * A disabled control is drawn in the same dimmed ink as every other
5976
- * disabled control in the library, is skipped by the Tab key, and is
5977
- * announced as unavailable. Its reset button is disabled with it, so the
5978
- * value cannot be changed by any route.
5979
- * @default false
5980
- */
5981
- disabled?: boolean;
5982
- /**
5983
- * One sentence saying why the control is off, shown only while `disabled`
5984
- * is true.
5985
- *
5986
- * It is appended to the control's own name after a full stop and drawn as
5987
- * the tooltip -- "Width. Load data first" -- and it also joins the
5988
- * control's accessible description, so a screen reader reads the reason out
5989
- * instead of announcing an unexplained unavailable control.
5990
- *
5991
- * Write it as a whole sentence naming what would make the control usable
5992
- * again.
5993
- */
5994
- disabledReason?: string;
5995
- /** Called when the control takes focus. Forwarded unchanged. */
5996
- onFocus?: default_2.FocusEventHandler<HTMLInputElement>;
5997
- /**
5998
- * Called when the control loses focus.
5999
- *
6000
- * Forwarded after the number has been committed, so reading the state you
6001
- * keep for this control inside the handler sees the new value.
6002
- */
6003
- onBlur?: default_2.FocusEventHandler<HTMLInputElement>;
6004
- }
6005
-
6006
- /**
6007
- * A dropdown that says whether the reader chose its value or inherited it.
6008
- *
6009
- * It is drawn as Figma's outlined select trigger (the theme's Select), and its
6010
- * list is the dark listbox, opening over the trigger with the current choice
6011
- * on top of it (design/figma-spec.md 6.4, 6.5).
6012
- *
6013
- * It is a Mantine `Select` with one idea added: `undefined` means "nothing has
6014
- * been chosen here", so the control shows `defaultValue` and offers no reset.
6015
- * As soon as the reader picks something a reset button appears beside it, and pressing that reset reports `undefined`
6016
- * again. A panel built from these reads at a glance as a list of what has been
6017
- * customized and what has not.
6018
- *
6019
- * Reach for Mantine's own `Select` for an ordinary form. Reach for this one
6020
- * where a value has a sensible default that the reader is overriding rather
6021
- * than filling in.
6022
- * @param props - Component props
6023
- * @param props.label - The control's name, drawn above it
6024
- * @param props.value - The chosen value, when you drive the control from your own state
6025
- * @param props.defaultValue - What is shown while the reader has chosen nothing of their own
6026
- * @param props.options - The choices offered
6027
- * @param props.onChange - Called with the new choice, or with `undefined` when the control is reset
6028
- * @param props.disabled - Whether the control cannot be used at all
6029
- * @param props.disabledReason - One sentence saying why the control is off, drawn only while it is off
6030
- * @param props.onFocus - Called when the control takes focus
6031
- * @param props.onBlur - Called when the control loses focus
6032
- * @returns The dropdown, and its reset button when a choice has been made
6033
- * @example
6034
- * ```tsx
6035
- * const [shape, setShape] = useState<string | undefined>(undefined);
6036
- *
6037
- * <StyleSelect
6038
- * label="Shape"
6039
- * value={shape}
6040
- * defaultValue="circle"
6041
- * options={[
6042
- * {value: "circle", label: "Circle"},
6043
- * {value: "square", label: "Square"},
6044
- * ]}
6045
- * onChange={setShape}
6046
- * />
6047
- * ```
6048
- */
6049
- export declare function StyleSelect({ label, value, defaultValue, options, onChange, disabled, disabledReason, onFocus, onBlur, }: StyleSelectProps): default_2.JSX.Element;
6050
-
6051
- /**
6052
- * One choice in a {@link StyleSelect}.
6053
- */
6054
- export declare interface StyleSelectOption {
6055
- /** What is stored when this choice is picked. */
6056
- value: string;
6057
- /** The words drawn for this choice, in the reader's own language. */
6058
- label: string;
6059
- }
6060
-
6061
- /**
6062
- * Props for the StyleSelect component.
6063
- */
6064
- export declare interface StyleSelectProps {
6065
- /** The control's name, drawn above it and read out as its accessible name. */
6066
- label: string;
6067
- /**
6068
- * The chosen value, when you drive the control from your own state.
6069
- *
6070
- * `undefined` does not mean "empty" here: it means the reader has not
6071
- * chosen anything and the control is showing `defaultValue`.
6072
- */
6073
- value?: string | undefined;
6074
- /** What is shown while the reader has chosen nothing of their own. */
6075
- defaultValue: string;
6076
- /** The choices offered, in the order they should be listed. */
6077
- options: StyleSelectOption[];
6078
- /**
6079
- * Called when the reader picks a choice, and with `undefined` when they
6080
- * reset the control to its default.
6081
- *
6082
- * The value comes first; Mantine's own dropdown reports no event for a
6083
- * choice, so the second argument is present only for the reset.
6084
- */
6085
- onChange?: ChangeHandler<string | undefined>;
6086
- /**
6087
- * Whether the control cannot be used at all.
6088
- *
6089
- * A disabled control is drawn in the same dimmed ink as every other
6090
- * disabled control in the library, is skipped by the Tab key, and is
6091
- * announced as unavailable. Its reset button is disabled with it, so the
6092
- * value cannot be changed by any route.
6093
- * @default false
6094
- */
6095
- disabled?: boolean;
6096
- /**
6097
- * One sentence saying why the control is off, shown only while `disabled`
6098
- * is true.
6099
- *
6100
- * It is appended to the control's own name after a full stop and drawn as
6101
- * the tooltip -- "Fill. Load data first" -- and it also joins the control's
6102
- * accessible description, so a screen reader reads the reason out instead
6103
- * of announcing an unexplained unavailable control.
6104
- *
6105
- * Write it as a whole sentence naming what would make the control usable
6106
- * again, not as a restatement that it is off.
6107
- */
6108
- disabledReason?: string;
6109
- /** Called when the control takes focus. Forwarded unchanged. */
6110
- onFocus?: default_2.FocusEventHandler<HTMLInputElement>;
6111
- /** Called when the control loses focus. Forwarded unchanged. */
6112
- onBlur?: default_2.FocusEventHandler<HTMLInputElement>;
6113
- }
6114
-
6115
5879
  /**
6116
5880
  * Swatches with alpha channel for HEXA color pickers.
6117
5881
  * Includes both fully opaque (FF) and semi-transparent (80) variants.
@@ -6534,7 +6298,7 @@ export declare interface ToggleRowProps {
6534
6298
  * ```tsx
6535
6299
  * <ToggleWithContent label="Glow" defaultChecked>
6536
6300
  * <CompactColorInput label="Color" defaultColor="#5b8ff9" />
6537
- * <StyleNumberInput label="Radius" defaultValue={4} min={0} max={20} />
6301
+ * <PanelField label="Radius" kind="number" defaultValue={4} min={0} max={20} />
6538
6302
  * </ToggleWithContent>
6539
6303
  * ```
6540
6304
  */
@@ -6567,7 +6331,7 @@ export declare interface ToggleWithContentProps {
6567
6331
  * @example
6568
6332
  * ```tsx
6569
6333
  * <ToggleWithContent label="Glow" onChange={(next) => { setGlow(next); }}>
6570
- * <StyleNumberInput label="Radius" defaultValue={4} />
6334
+ * <PanelField label="Radius" kind="number" defaultValue={4} />
6571
6335
  * </ToggleWithContent>
6572
6336
  * ```
6573
6337
  */