@astryxdesign/lab 0.3.0-canary.fbc60c5 → 0.3.0-canary.fcbc342
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/ListInput/ListInput.d.ts +138 -0
- package/dist/ListInput/ListInput.d.ts.map +1 -0
- package/dist/ListInput/ListInput.js +1254 -0
- package/dist/ListInput/index.d.ts +11 -0
- package/dist/ListInput/index.d.ts.map +1 -0
- package/dist/ListInput/index.js +13 -0
- package/dist/RichTextEditor/RichTextEditorAutoLinkPlugin.d.ts +0 -1
- package/dist/RichTextEditor/RichTextEditorAutoLinkPlugin.d.ts.map +1 -1
- package/dist/RichTextEditor/RichTextEditorAutoLinkPlugin.js +0 -1
- package/dist/Schedule/useCurrentTime.d.ts.map +1 -1
- package/dist/Schedule/useCurrentTime.js +2 -0
- package/dist/Stepper/Step.d.ts.map +1 -1
- package/dist/Stepper/Step.js +87 -49
- package/dist/Stepper/Stepper.d.ts +15 -4
- package/dist/Stepper/Stepper.d.ts.map +1 -1
- package/dist/Stepper/Stepper.js +18 -8
- package/dist/Stepper/StepperContext.d.ts +5 -5
- package/dist/Stepper/StepperContext.d.ts.map +1 -1
- package/dist/Stepper/stepper.stylex.d.ts +15 -0
- package/dist/Stepper/stepper.stylex.d.ts.map +1 -0
- package/dist/Stepper/stepper.stylex.js +20 -0
- package/dist/TransferList/TransferList.d.ts +90 -0
- package/dist/TransferList/TransferList.d.ts.map +1 -0
- package/dist/TransferList/TransferList.js +895 -0
- package/dist/TransferList/TransferListSelector.d.ts +57 -0
- package/dist/TransferList/TransferListSelector.d.ts.map +1 -0
- package/dist/TransferList/TransferListSelector.js +211 -0
- package/dist/TransferList/index.d.ts +10 -0
- package/dist/TransferList/index.d.ts.map +1 -0
- package/dist/TransferList/index.js +12 -0
- package/dist/TransferList/tokens.stylex.d.ts +15 -0
- package/dist/TransferList/tokens.stylex.d.ts.map +1 -0
- package/dist/TransferList/tokens.stylex.js +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/lab.css +91 -3
- package/dist/reorderStyles.d.ts +69 -0
- package/dist/reorderStyles.d.ts.map +1 -0
- package/dist/reorderStyles.js +82 -0
- package/package.json +3 -3
- package/src/BottomSheet/BottomSheet.doc.mjs +2 -2
- package/src/ListInput/ListInput.doc.mjs +375 -0
- package/src/ListInput/ListInput.test.tsx +1110 -0
- package/src/ListInput/ListInput.tsx +1800 -0
- package/src/ListInput/index.ts +21 -0
- package/src/RichTextEditor/RichTextEditor.doc.mjs +2 -2
- package/src/RichTextEditor/RichTextEditorAutoLinkPlugin.tsx +0 -1
- package/src/Schedule/useCurrentTime.test.ts +49 -0
- package/src/Schedule/useCurrentTime.ts +2 -0
- package/src/Stepper/Step.tsx +114 -30
- package/src/Stepper/Stepper.doc.mjs +13 -3
- package/src/Stepper/Stepper.test.tsx +143 -9
- package/src/Stepper/Stepper.tsx +35 -8
- package/src/Stepper/StepperContext.ts +5 -5
- package/src/Stepper/stepper.stylex.ts +19 -0
- package/src/Tour/Tour.doc.mjs +8 -8
- package/src/TransferList/TransferList.composition.test.tsx +288 -0
- package/src/TransferList/TransferList.doc.mjs +749 -0
- package/src/TransferList/TransferList.test.tsx +888 -0
- package/src/TransferList/TransferList.tsx +1323 -0
- package/src/TransferList/TransferListSelector.test.tsx +562 -0
- package/src/TransferList/TransferListSelector.tsx +315 -0
- package/src/TransferList/index.ts +20 -0
- package/src/TransferList/tokens.stylex.ts +18 -0
- package/src/index.ts +14 -0
- package/src/reorderStyles.ts +76 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file ListInput.tsx
|
|
3
|
+
* @input React, StyleX, Astryx field/list/button/icon/layer/empty-state primitives, compact size context, browser scroll geometry, programmatic theme tokens, and shared Lab reorder styles
|
|
4
|
+
* @output Exports ListInput and its controlled data, column, renderer, and change types
|
|
5
|
+
* @position Lab experiment (RFC facebook/astryx#4531) for editing compact repeated records
|
|
6
|
+
*
|
|
7
|
+
* SYNC: When modified, update these files to stay in sync:
|
|
8
|
+
* - /packages/lab/src/ListInput/ListInput.doc.mjs
|
|
9
|
+
* - /packages/lab/src/ListInput/ListInput.test.tsx
|
|
10
|
+
* - /packages/lab/src/ListInput/index.ts
|
|
11
|
+
* - /apps/storybook/stories/ListInput.stories.tsx
|
|
12
|
+
*/
|
|
13
|
+
import { type Key, type ReactNode } from 'react';
|
|
14
|
+
import type { BaseProps } from '@astryxdesign/core';
|
|
15
|
+
import { type InputStatus } from '@astryxdesign/core/Field';
|
|
16
|
+
import type { ColumnWidth } from '@astryxdesign/core/Table';
|
|
17
|
+
export type ListInputChange<T> = {
|
|
18
|
+
type: 'add';
|
|
19
|
+
item: T;
|
|
20
|
+
index: number;
|
|
21
|
+
} | {
|
|
22
|
+
type: 'update';
|
|
23
|
+
item: T;
|
|
24
|
+
previousItem: T;
|
|
25
|
+
index: number;
|
|
26
|
+
columnKey?: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'remove';
|
|
29
|
+
item: T;
|
|
30
|
+
index: number;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'reorder';
|
|
33
|
+
item: T;
|
|
34
|
+
fromIndex: number;
|
|
35
|
+
toIndex: number;
|
|
36
|
+
};
|
|
37
|
+
export interface ListInputValueContext<T> {
|
|
38
|
+
/** Current record. */
|
|
39
|
+
item: T;
|
|
40
|
+
/** Current visual position. */
|
|
41
|
+
index: number;
|
|
42
|
+
/** Accessible cell label, including the record position. */
|
|
43
|
+
label: string;
|
|
44
|
+
/** True because ListInput owns the visible column label. */
|
|
45
|
+
isLabelHidden: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface ListInputRenderContext<T> extends ListInputValueContext<T> {
|
|
48
|
+
/** Complete validation status scoped to this field. */
|
|
49
|
+
status?: InputStatus;
|
|
50
|
+
/** Forward to the rendered Astryx control so status uses its native tooltip. */
|
|
51
|
+
statusVariant: 'tooltip';
|
|
52
|
+
/** Whether the rendered control should be disabled. */
|
|
53
|
+
isDisabled: boolean;
|
|
54
|
+
/** Whether an asynchronous list operation is in progress. */
|
|
55
|
+
isLoading: boolean;
|
|
56
|
+
/** Replace this record in the controlled list. */
|
|
57
|
+
updateItem: (nextItem: T, columnKey?: string) => void;
|
|
58
|
+
}
|
|
59
|
+
export interface ListInputColumn<T> {
|
|
60
|
+
/** Stable column identifier, also passed to getFieldStatus. */
|
|
61
|
+
key: string;
|
|
62
|
+
/** Field label shown on the first record and repeated when rows stack. */
|
|
63
|
+
header: string;
|
|
64
|
+
/**
|
|
65
|
+
* Column sizing. Use proportional() or pixel() from @astryxdesign/core/Table
|
|
66
|
+
* to tune the width ratio. Defaults to a proportional column with a 140px floor.
|
|
67
|
+
*/
|
|
68
|
+
width?: ColumnWidth;
|
|
69
|
+
/** Renders the editable control for one cell. */
|
|
70
|
+
renderInput: (context: ListInputRenderContext<T>) => ReactNode;
|
|
71
|
+
}
|
|
72
|
+
export interface ListInputProps<T> extends Omit<BaseProps<HTMLDivElement>, 'onChange'> {
|
|
73
|
+
/** Ref forwarded to the outer field element. */
|
|
74
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
75
|
+
/** Visible and accessible label for the list. */
|
|
76
|
+
label: string;
|
|
77
|
+
/** Optional supporting text. */
|
|
78
|
+
description?: string;
|
|
79
|
+
/** Controlled records. */
|
|
80
|
+
value: T[];
|
|
81
|
+
/** Called for every record mutation with the next value and mutation detail. */
|
|
82
|
+
onChange: (nextValue: T[], change: ListInputChange<T>) => void;
|
|
83
|
+
/** Returns a stable key for focus preservation and reordering. */
|
|
84
|
+
getItemKey: (item: T) => Key;
|
|
85
|
+
/** Creates a new record when the Add action is used. */
|
|
86
|
+
createItem: () => T;
|
|
87
|
+
/** Column definitions and cell renderers. */
|
|
88
|
+
columns: ListInputColumn<T>[];
|
|
89
|
+
/** Singular name used in action labels and announcements. @default 'item' */
|
|
90
|
+
itemName?: string;
|
|
91
|
+
/** Validation status for the whole list. */
|
|
92
|
+
status?: InputStatus;
|
|
93
|
+
/** Returns a validation status displayed across one record. */
|
|
94
|
+
getItemStatus?: (item: T, index: number) => InputStatus | undefined;
|
|
95
|
+
/** Returns a validation status passed to one field renderer. */
|
|
96
|
+
getFieldStatus?: (item: T, columnKey: string, index: number) => InputStatus | undefined;
|
|
97
|
+
/** Enables handle-only pointer and keyboard reordering. @default false */
|
|
98
|
+
isReorderable?: boolean;
|
|
99
|
+
/** Disables fields and mutation controls. @default false */
|
|
100
|
+
isDisabled?: boolean;
|
|
101
|
+
/** Marks the list busy and prevents mutations. @default false */
|
|
102
|
+
isLoading?: boolean;
|
|
103
|
+
/** Maximum record count. Reaching it disables, but does not remove, Add. */
|
|
104
|
+
maxItems?: number;
|
|
105
|
+
/** Visually hides the list label while preserving its accessible name. */
|
|
106
|
+
isLabelHidden?: boolean;
|
|
107
|
+
/** Marks the list optional. */
|
|
108
|
+
isOptional?: boolean;
|
|
109
|
+
/** Marks the list required. */
|
|
110
|
+
isRequired?: boolean;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A compact editor for short collections of consistent, simple records.
|
|
114
|
+
*
|
|
115
|
+
* ListInput owns list semantics, add/remove controls, handle-only reordering,
|
|
116
|
+
* live collection motion, focus restoration, announcements, and list/item/
|
|
117
|
+
* field validation placement. Consumers keep ownership of the controlled data
|
|
118
|
+
* and render each field with standard Astryx inputs.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```
|
|
122
|
+
* <ListInput
|
|
123
|
+
* label="Guests"
|
|
124
|
+
* value={guests}
|
|
125
|
+
* onChange={setGuests}
|
|
126
|
+
* getItemKey={guest => guest.id}
|
|
127
|
+
* createItem={() => ({id: crypto.randomUUID(), name: '', email: ''})}
|
|
128
|
+
* columns={columns}
|
|
129
|
+
* itemName="guest"
|
|
130
|
+
* isReorderable
|
|
131
|
+
* />
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function ListInput<T>({ label, description, value, onChange, getItemKey, createItem, columns, itemName, status, getItemStatus, getFieldStatus, isReorderable, isDisabled, isLoading, maxItems, isLabelHidden, isOptional, isRequired, ref, ...rest }: ListInputProps<T>): ReactNode;
|
|
135
|
+
export declare namespace ListInput {
|
|
136
|
+
var displayName: string;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=ListInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListInput.d.ts","sourceRoot":"","sources":["../../src/ListInput/ListInput.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,OAAO,EAOL,KAAK,GAAG,EACR,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAGlD,OAAO,EAAQ,KAAK,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAOjE,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAa1D,MAAM,MAAM,eAAe,CAAC,CAAC,IACzB;IAAC,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,GACrC;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;IACR,YAAY,EAAE,CAAC,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACD;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,GACxC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC;AAEnE,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,sBAAsB;IACtB,IAAI,E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