@photonix/basic 3.0.0 → 3.1.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.
- package/dist/index.css +270 -14
- package/dist/index.d.mts +259 -2
- package/dist/index.d.ts +259 -2
- package/dist/index.js +1877 -349
- package/dist/index.mjs +1880 -363
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
export * from '@photonix/icons';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Layout component type definitions
|
|
@@ -565,6 +566,8 @@ interface CheckboxProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElemen
|
|
|
565
566
|
* Whether the checkbox is checked (controlled)
|
|
566
567
|
*/
|
|
567
568
|
checked?: boolean;
|
|
569
|
+
/** Participate in native form validation. */
|
|
570
|
+
required?: boolean;
|
|
568
571
|
/**
|
|
569
572
|
* Initial checked state when uncontrolled
|
|
570
573
|
*/
|
|
@@ -603,6 +606,8 @@ interface RadioProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
|
603
606
|
* Whether the radio is selected (controlled)
|
|
604
607
|
*/
|
|
605
608
|
checked?: boolean;
|
|
609
|
+
/** Participate in native form validation. */
|
|
610
|
+
required?: boolean;
|
|
606
611
|
/**
|
|
607
612
|
* Initial selected state when uncontrolled
|
|
608
613
|
*/
|
|
@@ -622,11 +627,42 @@ interface RadioProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
|
622
627
|
}
|
|
623
628
|
declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLButtonElement>>;
|
|
624
629
|
|
|
630
|
+
/** Props shared by RadioGroup and CheckboxGroup so the two groups read the same way. */
|
|
631
|
+
interface SelectionGroupBaseProps extends Omit<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, 'onChange' | 'defaultValue' | 'value' | 'form' | 'name'> {
|
|
632
|
+
/** Visible group label (legend). Omit only when `aria-label` names the group. */
|
|
633
|
+
label?: React.ReactNode;
|
|
634
|
+
/** Supporting text below the label. */
|
|
635
|
+
description?: React.ReactNode;
|
|
636
|
+
/** Error message; also marks the group invalid. */
|
|
637
|
+
error?: React.ReactNode;
|
|
638
|
+
/** Form field name applied to every option. */
|
|
639
|
+
name?: string;
|
|
640
|
+
/** Associates the options with a form outside the group. */
|
|
641
|
+
form?: string;
|
|
642
|
+
disabled?: boolean;
|
|
643
|
+
required?: boolean;
|
|
644
|
+
/** Layout of the options. @default 'vertical' */
|
|
645
|
+
orientation?: 'horizontal' | 'vertical';
|
|
646
|
+
children: React.ReactNode;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
interface RadioGroupProps extends SelectionGroupBaseProps {
|
|
650
|
+
/** Selected option value (controlled). */
|
|
651
|
+
value?: string;
|
|
652
|
+
/** Initially selected option value (uncontrolled). */
|
|
653
|
+
defaultValue?: string;
|
|
654
|
+
onChange?: (value: string) => void;
|
|
655
|
+
}
|
|
656
|
+
/** Single-choice group of `Radio` children with roving focus and native form support. */
|
|
657
|
+
declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLFieldSetElement>>;
|
|
658
|
+
|
|
625
659
|
interface SwitchProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {
|
|
626
660
|
/**
|
|
627
661
|
* Whether the switch is on (controlled)
|
|
628
662
|
*/
|
|
629
663
|
checked?: boolean;
|
|
664
|
+
/** Participate in native form validation. */
|
|
665
|
+
required?: boolean;
|
|
630
666
|
/**
|
|
631
667
|
* Initial state when uncontrolled
|
|
632
668
|
*/
|
|
@@ -662,6 +698,8 @@ interface TextFieldDropdownOption {
|
|
|
662
698
|
disabled?: boolean;
|
|
663
699
|
}
|
|
664
700
|
interface TextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'size'> {
|
|
701
|
+
/** Style the native input without changing the field wrapper layout. */
|
|
702
|
+
inputStyle?: React.CSSProperties;
|
|
665
703
|
/** Label text. */
|
|
666
704
|
label?: string;
|
|
667
705
|
/** Whether the label is placed inside or outside the input box. Default is 'outside'. */
|
|
@@ -1002,7 +1040,12 @@ interface ChipProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
1002
1040
|
/**
|
|
1003
1041
|
* Size of the chip
|
|
1004
1042
|
*/
|
|
1005
|
-
size?: 'medium' | 'large';
|
|
1043
|
+
size?: 'small' | 'medium' | 'large';
|
|
1044
|
+
/**
|
|
1045
|
+
* Corner shape: 'pill' is fully rounded, 'rounded' uses the Button corner
|
|
1046
|
+
* radius (e.g. tags inside an input).
|
|
1047
|
+
*/
|
|
1048
|
+
shape?: 'pill' | 'rounded';
|
|
1006
1049
|
/**
|
|
1007
1050
|
* Whether the chip is disabled
|
|
1008
1051
|
*/
|
|
@@ -1017,6 +1060,16 @@ interface ChipProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
1017
1060
|
* Callback when clear button is clicked (only for filled + hasDropdown)
|
|
1018
1061
|
*/
|
|
1019
1062
|
onClear?: (e: React.MouseEvent) => void;
|
|
1063
|
+
/**
|
|
1064
|
+
* Shows the chip's delete button (CancelFilled) on any variant, e.g. for
|
|
1065
|
+
* removable tags. Takes precedence over `actionIcon`.
|
|
1066
|
+
*/
|
|
1067
|
+
onRemove?: (e: React.MouseEvent) => void;
|
|
1068
|
+
/**
|
|
1069
|
+
* Accessible label for the close button
|
|
1070
|
+
* @default `Remove ${label}`
|
|
1071
|
+
*/
|
|
1072
|
+
removeLabel?: string;
|
|
1020
1073
|
/**
|
|
1021
1074
|
* Optional action icon shown after the dropdown affordance
|
|
1022
1075
|
*/
|
|
@@ -1106,4 +1159,208 @@ declare const LayoutProvider: React.FC<LayoutProviderProps>;
|
|
|
1106
1159
|
*/
|
|
1107
1160
|
declare const useLayout: () => LayoutContextValue | null;
|
|
1108
1161
|
|
|
1109
|
-
|
|
1162
|
+
/** Native fieldset with a legend, supporting text and an error message for grouped controls. */
|
|
1163
|
+
interface FieldsetProps extends React.FieldsetHTMLAttributes<HTMLFieldSetElement> {
|
|
1164
|
+
/** Visible group label. Omit only when the group is named with aria-label. */
|
|
1165
|
+
legend?: React.ReactNode;
|
|
1166
|
+
description?: React.ReactNode;
|
|
1167
|
+
error?: React.ReactNode;
|
|
1168
|
+
}
|
|
1169
|
+
declare const Fieldset: React.ForwardRefExoticComponent<FieldsetProps & React.RefAttributes<HTMLFieldSetElement>>;
|
|
1170
|
+
|
|
1171
|
+
interface CheckboxGroupProps extends SelectionGroupBaseProps {
|
|
1172
|
+
/** Checked option values (controlled). */
|
|
1173
|
+
value?: string[];
|
|
1174
|
+
/** Initially checked option values (uncontrolled). */
|
|
1175
|
+
defaultValue?: string[];
|
|
1176
|
+
onChange?: (value: string[]) => void;
|
|
1177
|
+
/** Message shown by native validation when `required` and nothing is checked. */
|
|
1178
|
+
requiredMessage?: string;
|
|
1179
|
+
}
|
|
1180
|
+
declare const CheckboxGroupContext: React.Context<{
|
|
1181
|
+
value: string[];
|
|
1182
|
+
name?: string;
|
|
1183
|
+
form?: string;
|
|
1184
|
+
disabled?: boolean;
|
|
1185
|
+
toggle: (value: string, checked: boolean) => void;
|
|
1186
|
+
} | null>;
|
|
1187
|
+
/** Multi-choice group of `Checkbox` children; same API shape as `RadioGroup`. */
|
|
1188
|
+
declare const CheckboxGroup: React.ForwardRefExoticComponent<CheckboxGroupProps & React.RefAttributes<HTMLFieldSetElement>>;
|
|
1189
|
+
|
|
1190
|
+
interface NumberFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "type" | "min" | "max" | "step" | "size"> {
|
|
1191
|
+
label: string;
|
|
1192
|
+
size?: "small" | "medium" | "large";
|
|
1193
|
+
inputWidth?: number | string;
|
|
1194
|
+
value?: number | null;
|
|
1195
|
+
defaultValue?: number | null;
|
|
1196
|
+
onChange?: (value: number | null) => void;
|
|
1197
|
+
min?: number;
|
|
1198
|
+
max?: number;
|
|
1199
|
+
step?: number;
|
|
1200
|
+
error?: string;
|
|
1201
|
+
description?: string;
|
|
1202
|
+
/** Accessible name of the decrement button. @default `Decrease ${label}` */
|
|
1203
|
+
decreaseLabel?: string;
|
|
1204
|
+
/** Accessible name of the increment button. @default `Increase ${label}` */
|
|
1205
|
+
increaseLabel?: string;
|
|
1206
|
+
}
|
|
1207
|
+
declare function NumberField({ label, size, inputWidth, value, defaultValue, onChange, min, max, step, error, description, disabled, readOnly, name, decreaseLabel, increaseLabel, ...props }: NumberFieldProps): react_jsx_runtime.JSX.Element;
|
|
1208
|
+
|
|
1209
|
+
interface RatingProps {
|
|
1210
|
+
label: string;
|
|
1211
|
+
value?: number;
|
|
1212
|
+
defaultValue?: number;
|
|
1213
|
+
max?: number;
|
|
1214
|
+
onChange?: (value: number) => void;
|
|
1215
|
+
disabled?: boolean;
|
|
1216
|
+
readOnly?: boolean;
|
|
1217
|
+
name?: string;
|
|
1218
|
+
form?: string;
|
|
1219
|
+
/** Show a button that resets the rating to 0. @default false */
|
|
1220
|
+
clearable?: boolean;
|
|
1221
|
+
/** Visible text of the clear button. */
|
|
1222
|
+
clearText?: string;
|
|
1223
|
+
/** Accessible name of the clear button. */
|
|
1224
|
+
clearLabel?: string;
|
|
1225
|
+
/** Accessible name of each star. */
|
|
1226
|
+
getStarLabel?: (value: number, max: number) => string;
|
|
1227
|
+
}
|
|
1228
|
+
declare function Rating({ label, value, defaultValue, max, onChange, disabled, readOnly, name, form, clearable, clearText, clearLabel, getStarLabel, }: RatingProps): react_jsx_runtime.JSX.Element;
|
|
1229
|
+
|
|
1230
|
+
interface OTPProps {
|
|
1231
|
+
label: string;
|
|
1232
|
+
length?: number;
|
|
1233
|
+
/** Insert a visual dash between groups of digits. */
|
|
1234
|
+
groupSize?: number;
|
|
1235
|
+
/** Conceal each entered digit with a dot. Used by PIN. */
|
|
1236
|
+
masked?: boolean;
|
|
1237
|
+
/** Use the label only as an accessible name, without displaying it. */
|
|
1238
|
+
hideLabel?: boolean;
|
|
1239
|
+
/** Render circular PIN indicators instead of rectangular input fields. */
|
|
1240
|
+
dotFields?: boolean;
|
|
1241
|
+
size?: "small" | "medium" | "large";
|
|
1242
|
+
value?: string;
|
|
1243
|
+
defaultValue?: string;
|
|
1244
|
+
onChange?: (value: string) => void;
|
|
1245
|
+
/** Called automatically when every cell is filled. Verify the code here and pass failures via error. */
|
|
1246
|
+
onComplete?: (value: string) => void;
|
|
1247
|
+
disabled?: boolean;
|
|
1248
|
+
/** Display an existing code without edits. Copying a cell copies the full code. */
|
|
1249
|
+
readOnly?: boolean;
|
|
1250
|
+
required?: boolean;
|
|
1251
|
+
name?: string;
|
|
1252
|
+
form?: string;
|
|
1253
|
+
/** Supporting text below the inputs; an error takes precedence. */
|
|
1254
|
+
helperText?: string;
|
|
1255
|
+
error?: string;
|
|
1256
|
+
/** Accessible name of each cell. */
|
|
1257
|
+
getCellLabel?: (label: string, position: number, length: number) => string;
|
|
1258
|
+
/**
|
|
1259
|
+
* Sequential entry, used by PIN: every tap, focus or key lands on the first empty
|
|
1260
|
+
* cell — digits fill left to right, Backspace clears from the right and no cell
|
|
1261
|
+
* can be picked by hand.
|
|
1262
|
+
*/
|
|
1263
|
+
sequential?: boolean;
|
|
1264
|
+
/** Focus the field when it mounts (on the next cell when `sequential`). */
|
|
1265
|
+
autoFocus?: boolean;
|
|
1266
|
+
}
|
|
1267
|
+
/** Segmented numeric entry with independent input cells, paste/autofill and native form support. */
|
|
1268
|
+
declare function OTP({ label, length, groupSize, masked, hideLabel, dotFields, size, value, defaultValue, onChange, onComplete, disabled, readOnly, required, name, form, helperText, error, getCellLabel, sequential, autoFocus, }: OTPProps): react_jsx_runtime.JSX.Element;
|
|
1269
|
+
|
|
1270
|
+
interface PINProps extends Omit<OTPProps, "label" | "masked" | "hideLabel" | "dotFields" | "groupSize" | "readOnly" | "size"> {
|
|
1271
|
+
/** Number of digits in the PIN. @default 4 */
|
|
1272
|
+
length?: number;
|
|
1273
|
+
/** Accessible name for the PIN inputs; no visible label is rendered. */
|
|
1274
|
+
"aria-label"?: string;
|
|
1275
|
+
/** Focus the first empty dot on mount. Only one field on a page can; pass `false` for the rest. @default true */
|
|
1276
|
+
autoFocus?: boolean;
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Numeric PIN entry with empty circular indicators that fill as digits are entered.
|
|
1280
|
+
* Entry is sequential: digits fill left to right, Backspace clears from the right and
|
|
1281
|
+
* no dot can be picked by hand.
|
|
1282
|
+
*/
|
|
1283
|
+
declare function PIN({ length, "aria-label": accessibleLabel, autoFocus, ...props }: PINProps): react_jsx_runtime.JSX.Element;
|
|
1284
|
+
|
|
1285
|
+
interface EmptyProps {
|
|
1286
|
+
title?: string;
|
|
1287
|
+
description?: React.ReactNode;
|
|
1288
|
+
icon?: React.ReactNode;
|
|
1289
|
+
action?: React.ReactNode;
|
|
1290
|
+
}
|
|
1291
|
+
declare function Empty({ title, description, icon, action, }: EmptyProps): react_jsx_runtime.JSX.Element;
|
|
1292
|
+
|
|
1293
|
+
interface ResultProps {
|
|
1294
|
+
status: "success" | "error" | "warning" | "info";
|
|
1295
|
+
title: string;
|
|
1296
|
+
description?: React.ReactNode;
|
|
1297
|
+
action?: React.ReactNode;
|
|
1298
|
+
}
|
|
1299
|
+
declare function Result({ status, title, description, action }: ResultProps): react_jsx_runtime.JSX.Element;
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* How each label/value pair is laid out (Figma "Detail Field"):
|
|
1303
|
+
* - `stack`: label above the value (Detail Field Stack).
|
|
1304
|
+
* - `inline`: label on the left, value right-aligned on the same row (Detail Field Inline).
|
|
1305
|
+
* - `column`: label and value in a 2 : 3 column grid, value left-aligned (Detail Field Column).
|
|
1306
|
+
*/
|
|
1307
|
+
type DataListLayout = "stack" | "inline" | "column";
|
|
1308
|
+
/**
|
|
1309
|
+
* Per-item variant (Figma Detail Field `variant`).
|
|
1310
|
+
* - `normal`: default row.
|
|
1311
|
+
* - `emphasize`: value in medium weight.
|
|
1312
|
+
* - `total`: summary row — emphasized label and value.
|
|
1313
|
+
* - `flexible` (inline/column): the label hugs its text and the value takes the remaining width.
|
|
1314
|
+
* - `hero` (stack): the value as a large headline figure, e.g. a balance; supports `masked`.
|
|
1315
|
+
* - `complex` (stack): a rich value (avatar, title, meta) that fills the row, with the action at the end.
|
|
1316
|
+
*/
|
|
1317
|
+
type DataListItemVariant = "normal" | "emphasize" | "total" | "flexible" | "hero" | "complex";
|
|
1318
|
+
interface DataListItem {
|
|
1319
|
+
id: string;
|
|
1320
|
+
label: React.ReactNode;
|
|
1321
|
+
value: React.ReactNode;
|
|
1322
|
+
/** @default "normal" */
|
|
1323
|
+
variant?: DataListItemVariant;
|
|
1324
|
+
/**
|
|
1325
|
+
* Medium-weight label (Figma Label `emphasized`): primary text. With `labelLead` the label
|
|
1326
|
+
* stays secondary and only takes the weight (`subEmphasized`). Implied by `variant="total"`.
|
|
1327
|
+
*/
|
|
1328
|
+
labelEmphasized?: boolean;
|
|
1329
|
+
/** Lead-in before the label in primary text, e.g. "Send to" (Figma Label `subNormal`/`subEmphasized`). */
|
|
1330
|
+
labelLead?: React.ReactNode;
|
|
1331
|
+
/** Icon before the label, 20px (Figma Label `hasPrefix`). */
|
|
1332
|
+
labelIcon?: React.ReactNode;
|
|
1333
|
+
/** Secondary text at the end of the label row, e.g. "20/500" (Figma Label `hasTrailing`). */
|
|
1334
|
+
labelTrailing?: React.ReactNode;
|
|
1335
|
+
/** 20px icon before the value (Figma Body `leadingIcon`). */
|
|
1336
|
+
icon?: React.ReactNode;
|
|
1337
|
+
/** Muted text before the value, e.g. a currency symbol. */
|
|
1338
|
+
valuePrefix?: React.ReactNode;
|
|
1339
|
+
/** `hero` only: replace the figure with six dots (Figma Balance `hidden`). */
|
|
1340
|
+
masked?: boolean;
|
|
1341
|
+
/** Secondary text on a second line under the value (Figma Body `2 line`). */
|
|
1342
|
+
description?: React.ReactNode;
|
|
1343
|
+
/** Status badge (Figma Body `text w badge`), e.g. `<Badge shape="rounded" color="onLight" />`. */
|
|
1344
|
+
badge?: React.ReactNode;
|
|
1345
|
+
/** `inline`: right after the value, 8px apart. `below`: on its own line under the value. @default "inline" */
|
|
1346
|
+
badgePlacement?: "inline" | "below";
|
|
1347
|
+
/**
|
|
1348
|
+
* Control after the value, e.g. a copy IconButton (Figma Body `trailingIcon`, 20px). It sits in a
|
|
1349
|
+
* 20px slot and never grows the row; use `size="medium"` so the button's icon is 20px.
|
|
1350
|
+
*/
|
|
1351
|
+
action?: React.ReactNode;
|
|
1352
|
+
}
|
|
1353
|
+
interface DataListProps {
|
|
1354
|
+
items: DataListItem[];
|
|
1355
|
+
/** Accessible name of the list. @default "Details" */
|
|
1356
|
+
label?: string;
|
|
1357
|
+
/** @default "stack" for `orientation="vertical"`, otherwise "inline" */
|
|
1358
|
+
layout?: DataListLayout;
|
|
1359
|
+
/** Label size (Figma Label `size`): `sm` = title-sm, `lg` = title-md. @default "sm" in stack, "lg" otherwise */
|
|
1360
|
+
labelSize?: "sm" | "lg";
|
|
1361
|
+
/** @deprecated Use `layout`: "horizontal" maps to `inline`, "vertical" to `stack`. */
|
|
1362
|
+
orientation?: "horizontal" | "vertical";
|
|
1363
|
+
}
|
|
1364
|
+
declare function DataList({ items, label, layout, labelSize, orientation, }: DataListProps): react_jsx_runtime.JSX.Element;
|
|
1365
|
+
|
|
1366
|
+
export { AVATAR_IMAGES, AspectRatio$1 as AspectRatio, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize, AvatarTemplate, type AvatarTemplateProps, type BackgroundToken, Badge, Box, Button, type ButtonProps, Center, Checkbox, CheckboxGroup, CheckboxGroupContext, type CheckboxGroupProps, Chip, ChipBar, type ChipProps, Cluster, Container, CustomScrollbar, DataList, type DataListItem, type DataListItemVariant, type DataListLayout, type DataListProps, Divider, Empty, type EmptyProps, Fieldset, type FieldsetProps, Flex, Grid, GridItem, HStack, Heading, IconButton, Image, LayoutContext, LayoutProvider, NumberField, type NumberFieldProps, OTP, type OTPProps, PIN, type PINProps, Portal, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type RadiusToken, Rating, type RatingProps, Result, type ResultProps, type ShadowToken, SimpleGrid, Skeleton, SlotPlaceholder, type SlotPlaceholderProps, Spacer, type SpacingToken, Spinner, Stack, Switch, type SwitchProps, Text, TextArea, type TextAreaProps, TextField, type TextFieldDropdownOption, type TextFieldProps, VStack, VisuallyHidden, useLayout };
|