@aws-amplify/ui-react 6.5.5 → 6.7.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/{Field-CIQvkMkM.js → Field-DbA9eYRa.js} +108 -0
- package/dist/{ThemeStyle-CgfvQJ7V.js → ThemeStyle-DA2-Clfz.js} +0 -8
- package/dist/esm/PrimitiveCatalog.mjs +328 -0
- package/dist/esm/components/AccountSettings/ChangePassword/ChangePassword.mjs +2 -0
- package/dist/esm/components/AccountSettings/ChangePassword/defaults.mjs +1 -0
- package/dist/esm/components/AccountSettings/DeleteUser/DeleteUser.mjs +2 -0
- package/dist/esm/components/AccountSettings/DeleteUser/defaults.mjs +1 -0
- package/dist/esm/components/AccountSettings/shared/Defaults.mjs +1 -0
- package/dist/esm/components/FileSelect/FileSelect.mjs +70 -0
- package/dist/esm/components/ThemeProvider/ComponentStyle.mjs +0 -4
- package/dist/esm/components/ThemeProvider/GlobalStyle.mjs +0 -4
- package/dist/esm/components/ThemeProvider/Style.mjs +0 -4
- package/dist/esm/components/ThemeProvider/ThemeStyle.mjs +0 -4
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/internal.mjs +2 -0
- package/dist/esm/primitives/Icon/context/StorageBrowserIcons.mjs +68 -0
- package/dist/esm/primitives/TextArea/useAutoresizeTextarea.mjs +1 -1
- package/dist/esm/primitives/index.mjs +1 -0
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +26 -64
- package/dist/internal.js +399 -1
- package/dist/server.js +1 -9
- package/dist/styles/AIConversation.css +11 -0
- package/dist/styles/AIConversation.layer.css +11 -0
- package/dist/styles/StorageBrowser.css +150 -0
- package/dist/styles/StorageBrowser.layer.css +152 -0
- package/dist/styles/base.css +1 -0
- package/dist/styles/base.layer.css +1 -0
- package/dist/styles.css +163 -0
- package/dist/styles.layer.css +163 -0
- package/dist/types/components/FileSelect/FileSelect.d.ts +59 -0
- package/dist/types/components/FileSelect/index.d.ts +1 -0
- package/dist/types/components/ThemeProvider/ComponentStyle.d.ts +0 -4
- package/dist/types/components/ThemeProvider/GlobalStyle.d.ts +0 -4
- package/dist/types/components/ThemeProvider/Style.d.ts +0 -4
- package/dist/types/components/ThemeProvider/ThemeStyle.d.ts +0 -4
- package/dist/types/internal.d.ts +2 -0
- package/dist/types/primitives/Icon/context/IconsContext.d.ts +2 -0
- package/dist/types/primitives/Icon/context/StorageBrowserIcons.d.ts +35 -0
- package/dist/types/primitives/components.d.ts +1 -0
- package/dist/types/primitives/types/field.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
|
@@ -910,6 +910,111 @@ const AlertIcon = ({ variation, ariaHidden, ariaLabel, role, }) => {
|
|
|
910
910
|
};
|
|
911
911
|
AlertIcon.displayName = 'AlertIcon';
|
|
912
912
|
|
|
913
|
+
// Source: https://github.com/radix-ui/primitives/blob/7ae63b6cce6ea53ea5d65b6d411894c004b38f47/packages/react/use-layout-effect/src/useLayoutEffect.tsx
|
|
914
|
+
/**
|
|
915
|
+
* On the server, React emits a warning when calling `useLayoutEffect`.
|
|
916
|
+
* This is because neither `useLayoutEffect` nor `useEffect` run on the server.
|
|
917
|
+
* We use this safe version which suppresses the warning by replacing it with a noop on the server.
|
|
918
|
+
*
|
|
919
|
+
* See: https://reactjs.org/docs/hooks-reference.html#uselayouteffect
|
|
920
|
+
*/
|
|
921
|
+
const useLayoutEffect = globalThis?.document ? React__namespace.useLayoutEffect : () => { };
|
|
922
|
+
|
|
923
|
+
// Adapted from https://github.com/radix-ui/primitives/blob/main/packages/react/id/src/id.tsx#L8
|
|
924
|
+
// Prefixed autogenerated id created by useStableId
|
|
925
|
+
const AUTO_GENERATED_ID_PREFIX = 'amplify-id';
|
|
926
|
+
// Create a local version of React.useId which will reference React.useId for React 18
|
|
927
|
+
// and fallback to noop for React 17 and below
|
|
928
|
+
// Note: We use `toString()` to prevent bundlers from trying to `import { useId } from 'react';`
|
|
929
|
+
// since it doesn't exist in React 17 and below (prevents https://github.com/aws-amplify/amplify-ui/issues/1154)
|
|
930
|
+
const useReactId =
|
|
931
|
+
// disable eslint below to allow usage of casting React to `any`, which ensures that TS
|
|
932
|
+
// does not get confused about the existence of `useId` in React 17 and below
|
|
933
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
934
|
+
React__namespace['useId'.toString()] || (() => undefined);
|
|
935
|
+
let count = 0;
|
|
936
|
+
/**
|
|
937
|
+
* Create a uuid to use with amplify fields unless
|
|
938
|
+
* an id is provided
|
|
939
|
+
* @param id user specified id
|
|
940
|
+
* @returns string
|
|
941
|
+
*/
|
|
942
|
+
const useStableId = (id) => {
|
|
943
|
+
const [stableId, setStableId] = React__namespace.useState(useReactId());
|
|
944
|
+
// React versions older than 18 will have client-side ids only
|
|
945
|
+
useLayoutEffect(() => {
|
|
946
|
+
if (!id) {
|
|
947
|
+
setStableId((reactId) => reactId ?? String(count++));
|
|
948
|
+
}
|
|
949
|
+
}, [id]);
|
|
950
|
+
return id ?? (stableId ? `${AUTO_GENERATED_ID_PREFIX}-${stableId}` : '');
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
// `FileSelect` input `type` must always be set to `file`
|
|
954
|
+
const INPUT_TYPE = 'file';
|
|
955
|
+
const TEST_ID = 'amplify-file-select';
|
|
956
|
+
const DEFAULT_PROPS = {
|
|
957
|
+
style: { display: 'none' },
|
|
958
|
+
type: 'file',
|
|
959
|
+
'data-testid': TEST_ID,
|
|
960
|
+
};
|
|
961
|
+
/**
|
|
962
|
+
* @internal @unstable
|
|
963
|
+
*/
|
|
964
|
+
const FileSelect = React__namespace["default"].forwardRef(function FileSelect({ multiple = true, type = 'FILE', testId = 'amplify-file-select', ...props }, ref) {
|
|
965
|
+
return (React__namespace["default"].createElement("input", { ...DEFAULT_PROPS, ...props, ...(type === 'FOLDER' ? { webkitdirectory: '' } : undefined), "data-testid": testId, multiple: multiple, ref: ref, type: INPUT_TYPE }));
|
|
966
|
+
});
|
|
967
|
+
/**
|
|
968
|
+
* @internal @unstable
|
|
969
|
+
*
|
|
970
|
+
* @usage
|
|
971
|
+
* ```tsx
|
|
972
|
+
* function MyUploadButton() {
|
|
973
|
+
* const [files, setFiles] = React.useState<File[]>([]);
|
|
974
|
+
* const [fileSelect, handleFileSelect] = useFileSelect(setFiles);
|
|
975
|
+
* return (
|
|
976
|
+
* <>
|
|
977
|
+
* {fileSelect}
|
|
978
|
+
* <Button
|
|
979
|
+
* onClick={() => {
|
|
980
|
+
* handleFileSelect('file');
|
|
981
|
+
* }}
|
|
982
|
+
* />
|
|
983
|
+
* </>
|
|
984
|
+
* );
|
|
985
|
+
* }
|
|
986
|
+
* ```
|
|
987
|
+
*/
|
|
988
|
+
const useFileSelect = (onSelect) => {
|
|
989
|
+
const [inputProps, setInputProps] = React__namespace["default"].useState(undefined);
|
|
990
|
+
const id = useStableId();
|
|
991
|
+
const ref = React__namespace["default"].useRef(null);
|
|
992
|
+
React__namespace["default"].useEffect(() => {
|
|
993
|
+
if (inputProps) {
|
|
994
|
+
ref.current?.click();
|
|
995
|
+
}
|
|
996
|
+
}, [id, inputProps]);
|
|
997
|
+
const handleFileSelect = React__namespace["default"].useCallback((type, options) => {
|
|
998
|
+
if (id !== ref.current?.id)
|
|
999
|
+
return;
|
|
1000
|
+
setInputProps({ type, ...options });
|
|
1001
|
+
}, [id]);
|
|
1002
|
+
const fileSelect = (React__namespace["default"].createElement(FileSelect, { ...inputProps, id: id, onChange: (event) => {
|
|
1003
|
+
if (ui.isFunction(inputProps?.onChange))
|
|
1004
|
+
inputProps?.onChange(event);
|
|
1005
|
+
if (ui.isFunction(onSelect) && !!event.target.files?.length) {
|
|
1006
|
+
onSelect?.([...event.target.files]);
|
|
1007
|
+
}
|
|
1008
|
+
// Reset the input value to allow re-selecting the same file
|
|
1009
|
+
if (ref.current) {
|
|
1010
|
+
ref.current.value = '';
|
|
1011
|
+
}
|
|
1012
|
+
// clean up
|
|
1013
|
+
setInputProps(undefined);
|
|
1014
|
+
}, ref: ref }));
|
|
1015
|
+
return [fileSelect, handleFileSelect];
|
|
1016
|
+
};
|
|
1017
|
+
|
|
913
1018
|
const FieldGroupIconPrimitive = ({ className, children, isVisible = true, excludeFromTabOrder = false, ...rest }, ref) => {
|
|
914
1019
|
return isVisible ? (React__namespace.createElement(View, { className: ui.classNames(ui.ComponentClassName.FieldGroupIcon, className), ref: ref, tabIndex: excludeFromTabOrder ? -1 : undefined, ...rest }, children)) : null;
|
|
915
1020
|
};
|
|
@@ -1075,6 +1180,7 @@ exports.FieldErrorMessage = FieldErrorMessage;
|
|
|
1075
1180
|
exports.FieldGroupIcon = FieldGroupIcon;
|
|
1076
1181
|
exports.FieldGroupIconButton = FieldGroupIconButton;
|
|
1077
1182
|
exports.FieldsetContext = FieldsetContext;
|
|
1183
|
+
exports.FileSelect = FileSelect;
|
|
1078
1184
|
exports.Flex = Flex;
|
|
1079
1185
|
exports.Icon = Icon;
|
|
1080
1186
|
exports.IconAdd = IconAdd;
|
|
@@ -1111,6 +1217,8 @@ exports.useBreakpoint = useBreakpoint;
|
|
|
1111
1217
|
exports.useColorMode = useColorMode;
|
|
1112
1218
|
exports.useDeprecationWarning = useDeprecationWarning;
|
|
1113
1219
|
exports.useFieldset = useFieldset;
|
|
1220
|
+
exports.useFileSelect = useFileSelect;
|
|
1114
1221
|
exports.useIcons = useIcons;
|
|
1222
|
+
exports.useStableId = useStableId;
|
|
1115
1223
|
exports.useStyles = useStyles;
|
|
1116
1224
|
exports.useTheme = useTheme;
|
|
@@ -22,10 +22,6 @@ function _interopNamespace(e) {
|
|
|
22
22
|
|
|
23
23
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* @experimental
|
|
27
|
-
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
28
|
-
*/
|
|
29
25
|
const Style = ({ cssText, ...rest }) => {
|
|
30
26
|
/*
|
|
31
27
|
Only inject theme CSS variables if given a theme.
|
|
@@ -81,10 +77,6 @@ const Style = ({ cssText, ...rest }) => {
|
|
|
81
77
|
};
|
|
82
78
|
Style.displayName = 'Style';
|
|
83
79
|
|
|
84
|
-
/**
|
|
85
|
-
* @experimental
|
|
86
|
-
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
87
|
-
*/
|
|
88
80
|
const ThemeStyle = ({ theme, ...rest }) => {
|
|
89
81
|
if (!theme)
|
|
90
82
|
return null;
|
|
@@ -2235,6 +2235,334 @@ const PrimitiveCatalog = {
|
|
|
2235
2235
|
}
|
|
2236
2236
|
}
|
|
2237
2237
|
},
|
|
2238
|
+
"Checkbox": {
|
|
2239
|
+
"properties": {
|
|
2240
|
+
"label": {
|
|
2241
|
+
"type": "string"
|
|
2242
|
+
},
|
|
2243
|
+
"labelHidden": {
|
|
2244
|
+
"type": "boolean"
|
|
2245
|
+
},
|
|
2246
|
+
"name": {
|
|
2247
|
+
"type": "string"
|
|
2248
|
+
},
|
|
2249
|
+
"value": {
|
|
2250
|
+
"type": "string"
|
|
2251
|
+
},
|
|
2252
|
+
"labelPosition": {
|
|
2253
|
+
"type": "string"
|
|
2254
|
+
},
|
|
2255
|
+
"isIndeterminate": {
|
|
2256
|
+
"type": "boolean"
|
|
2257
|
+
},
|
|
2258
|
+
"isDisabled": {
|
|
2259
|
+
"type": "boolean"
|
|
2260
|
+
},
|
|
2261
|
+
"id": {
|
|
2262
|
+
"type": "string"
|
|
2263
|
+
},
|
|
2264
|
+
"children": {
|
|
2265
|
+
"type": "string"
|
|
2266
|
+
},
|
|
2267
|
+
"className": {
|
|
2268
|
+
"type": "string"
|
|
2269
|
+
},
|
|
2270
|
+
"testId": {
|
|
2271
|
+
"type": "string"
|
|
2272
|
+
},
|
|
2273
|
+
"inert": {
|
|
2274
|
+
"type": "boolean"
|
|
2275
|
+
},
|
|
2276
|
+
"alignSelf": {
|
|
2277
|
+
"type": "string"
|
|
2278
|
+
},
|
|
2279
|
+
"backgroundColor": {
|
|
2280
|
+
"type": "string"
|
|
2281
|
+
},
|
|
2282
|
+
"backgroundImage": {
|
|
2283
|
+
"type": "string"
|
|
2284
|
+
},
|
|
2285
|
+
"border": {
|
|
2286
|
+
"type": "string"
|
|
2287
|
+
},
|
|
2288
|
+
"borderColor": {
|
|
2289
|
+
"type": "string"
|
|
2290
|
+
},
|
|
2291
|
+
"borderWidth": {
|
|
2292
|
+
"type": "string"
|
|
2293
|
+
},
|
|
2294
|
+
"borderStyle": {
|
|
2295
|
+
"type": "string"
|
|
2296
|
+
},
|
|
2297
|
+
"borderRadius": {
|
|
2298
|
+
"type": "string"
|
|
2299
|
+
},
|
|
2300
|
+
"bottom": {
|
|
2301
|
+
"type": "string"
|
|
2302
|
+
},
|
|
2303
|
+
"boxShadow": {
|
|
2304
|
+
"type": "string"
|
|
2305
|
+
},
|
|
2306
|
+
"color": {
|
|
2307
|
+
"type": "string"
|
|
2308
|
+
},
|
|
2309
|
+
"display": {
|
|
2310
|
+
"type": "string"
|
|
2311
|
+
},
|
|
2312
|
+
"fontFamily": {
|
|
2313
|
+
"type": "string"
|
|
2314
|
+
},
|
|
2315
|
+
"fontSize": {
|
|
2316
|
+
"type": "string"
|
|
2317
|
+
},
|
|
2318
|
+
"fontStyle": {
|
|
2319
|
+
"type": "string"
|
|
2320
|
+
},
|
|
2321
|
+
"fontWeight": {
|
|
2322
|
+
"type": "string"
|
|
2323
|
+
},
|
|
2324
|
+
"height": {
|
|
2325
|
+
"type": "string"
|
|
2326
|
+
},
|
|
2327
|
+
"left": {
|
|
2328
|
+
"type": "string"
|
|
2329
|
+
},
|
|
2330
|
+
"letterSpacing": {
|
|
2331
|
+
"type": "string"
|
|
2332
|
+
},
|
|
2333
|
+
"lineHeight": {
|
|
2334
|
+
"type": "string"
|
|
2335
|
+
},
|
|
2336
|
+
"margin": {
|
|
2337
|
+
"type": "string"
|
|
2338
|
+
},
|
|
2339
|
+
"marginBlock": {
|
|
2340
|
+
"type": "string"
|
|
2341
|
+
},
|
|
2342
|
+
"marginBlockEnd": {
|
|
2343
|
+
"type": "string"
|
|
2344
|
+
},
|
|
2345
|
+
"marginBlockStart": {
|
|
2346
|
+
"type": "string"
|
|
2347
|
+
},
|
|
2348
|
+
"marginBottom": {
|
|
2349
|
+
"type": "string"
|
|
2350
|
+
},
|
|
2351
|
+
"marginInline": {
|
|
2352
|
+
"type": "string"
|
|
2353
|
+
},
|
|
2354
|
+
"marginInlineEnd": {
|
|
2355
|
+
"type": "string"
|
|
2356
|
+
},
|
|
2357
|
+
"marginInlineStart": {
|
|
2358
|
+
"type": "string"
|
|
2359
|
+
},
|
|
2360
|
+
"marginLeft": {
|
|
2361
|
+
"type": "string"
|
|
2362
|
+
},
|
|
2363
|
+
"marginRight": {
|
|
2364
|
+
"type": "string"
|
|
2365
|
+
},
|
|
2366
|
+
"marginTop": {
|
|
2367
|
+
"type": "string"
|
|
2368
|
+
},
|
|
2369
|
+
"maxHeight": {
|
|
2370
|
+
"type": "string"
|
|
2371
|
+
},
|
|
2372
|
+
"maxWidth": {
|
|
2373
|
+
"type": "string"
|
|
2374
|
+
},
|
|
2375
|
+
"minHeight": {
|
|
2376
|
+
"type": "string"
|
|
2377
|
+
},
|
|
2378
|
+
"minWidth": {
|
|
2379
|
+
"type": "string"
|
|
2380
|
+
},
|
|
2381
|
+
"opacity": {
|
|
2382
|
+
"type": "string"
|
|
2383
|
+
},
|
|
2384
|
+
"overflow": {
|
|
2385
|
+
"type": "string"
|
|
2386
|
+
},
|
|
2387
|
+
"padding": {
|
|
2388
|
+
"type": "string"
|
|
2389
|
+
},
|
|
2390
|
+
"paddingBlock": {
|
|
2391
|
+
"type": "string"
|
|
2392
|
+
},
|
|
2393
|
+
"paddingBlockEnd": {
|
|
2394
|
+
"type": "string"
|
|
2395
|
+
},
|
|
2396
|
+
"paddingBlockStart": {
|
|
2397
|
+
"type": "string"
|
|
2398
|
+
},
|
|
2399
|
+
"paddingBottom": {
|
|
2400
|
+
"type": "string"
|
|
2401
|
+
},
|
|
2402
|
+
"paddingInline": {
|
|
2403
|
+
"type": "string"
|
|
2404
|
+
},
|
|
2405
|
+
"paddingInlineEnd": {
|
|
2406
|
+
"type": "string"
|
|
2407
|
+
},
|
|
2408
|
+
"paddingInlineStart": {
|
|
2409
|
+
"type": "string"
|
|
2410
|
+
},
|
|
2411
|
+
"paddingLeft": {
|
|
2412
|
+
"type": "string"
|
|
2413
|
+
},
|
|
2414
|
+
"paddingRight": {
|
|
2415
|
+
"type": "string"
|
|
2416
|
+
},
|
|
2417
|
+
"paddingTop": {
|
|
2418
|
+
"type": "string"
|
|
2419
|
+
},
|
|
2420
|
+
"position": {
|
|
2421
|
+
"type": "string"
|
|
2422
|
+
},
|
|
2423
|
+
"right": {
|
|
2424
|
+
"type": "string"
|
|
2425
|
+
},
|
|
2426
|
+
"textAlign": {
|
|
2427
|
+
"type": "string"
|
|
2428
|
+
},
|
|
2429
|
+
"textDecoration": {
|
|
2430
|
+
"type": "string"
|
|
2431
|
+
},
|
|
2432
|
+
"textTransform": {
|
|
2433
|
+
"type": "string"
|
|
2434
|
+
},
|
|
2435
|
+
"top": {
|
|
2436
|
+
"type": "string"
|
|
2437
|
+
},
|
|
2438
|
+
"transform": {
|
|
2439
|
+
"type": "string"
|
|
2440
|
+
},
|
|
2441
|
+
"transformOrigin": {
|
|
2442
|
+
"type": "string"
|
|
2443
|
+
},
|
|
2444
|
+
"width": {
|
|
2445
|
+
"type": "string"
|
|
2446
|
+
},
|
|
2447
|
+
"whiteSpace": {
|
|
2448
|
+
"type": "string"
|
|
2449
|
+
},
|
|
2450
|
+
"flex": {
|
|
2451
|
+
"type": "string"
|
|
2452
|
+
},
|
|
2453
|
+
"order": {
|
|
2454
|
+
"type": "string"
|
|
2455
|
+
},
|
|
2456
|
+
"grow": {
|
|
2457
|
+
"type": "string"
|
|
2458
|
+
},
|
|
2459
|
+
"shrink": {
|
|
2460
|
+
"type": "string"
|
|
2461
|
+
},
|
|
2462
|
+
"basis": {
|
|
2463
|
+
"type": "string"
|
|
2464
|
+
},
|
|
2465
|
+
"area": {
|
|
2466
|
+
"type": "string"
|
|
2467
|
+
},
|
|
2468
|
+
"column": {
|
|
2469
|
+
"type": "string"
|
|
2470
|
+
},
|
|
2471
|
+
"columnEnd": {
|
|
2472
|
+
"type": "string"
|
|
2473
|
+
},
|
|
2474
|
+
"columnSpan": {
|
|
2475
|
+
"type": "string"
|
|
2476
|
+
},
|
|
2477
|
+
"columnStart": {
|
|
2478
|
+
"type": "string"
|
|
2479
|
+
},
|
|
2480
|
+
"row": {
|
|
2481
|
+
"type": "string"
|
|
2482
|
+
},
|
|
2483
|
+
"rowEnd": {
|
|
2484
|
+
"type": "string"
|
|
2485
|
+
},
|
|
2486
|
+
"rowSpan": {
|
|
2487
|
+
"type": "string"
|
|
2488
|
+
},
|
|
2489
|
+
"rowStart": {
|
|
2490
|
+
"type": "string"
|
|
2491
|
+
},
|
|
2492
|
+
"ariaLabel": {
|
|
2493
|
+
"type": "string"
|
|
2494
|
+
},
|
|
2495
|
+
"ariaValuetext": {
|
|
2496
|
+
"type": "string"
|
|
2497
|
+
},
|
|
2498
|
+
"role": {
|
|
2499
|
+
"type": "string"
|
|
2500
|
+
},
|
|
2501
|
+
"direction": {
|
|
2502
|
+
"type": "string"
|
|
2503
|
+
},
|
|
2504
|
+
"wrap": {
|
|
2505
|
+
"type": "string"
|
|
2506
|
+
},
|
|
2507
|
+
"alignItems": {
|
|
2508
|
+
"type": "string"
|
|
2509
|
+
},
|
|
2510
|
+
"alignContent": {
|
|
2511
|
+
"type": "string"
|
|
2512
|
+
},
|
|
2513
|
+
"justifyContent": {
|
|
2514
|
+
"type": "string"
|
|
2515
|
+
},
|
|
2516
|
+
"gap": {
|
|
2517
|
+
"type": "string"
|
|
2518
|
+
},
|
|
2519
|
+
"columnGap": {
|
|
2520
|
+
"type": "string"
|
|
2521
|
+
},
|
|
2522
|
+
"rowGap": {
|
|
2523
|
+
"type": "string"
|
|
2524
|
+
},
|
|
2525
|
+
"autoComplete": {
|
|
2526
|
+
"type": "string"
|
|
2527
|
+
},
|
|
2528
|
+
"checked": {
|
|
2529
|
+
"type": "boolean"
|
|
2530
|
+
},
|
|
2531
|
+
"defaultChecked": {
|
|
2532
|
+
"type": "boolean"
|
|
2533
|
+
},
|
|
2534
|
+
"defaultValue": {
|
|
2535
|
+
"type": "string"
|
|
2536
|
+
},
|
|
2537
|
+
"hasError": {
|
|
2538
|
+
"type": "boolean"
|
|
2539
|
+
},
|
|
2540
|
+
"enterKeyHint": {
|
|
2541
|
+
"type": "string"
|
|
2542
|
+
},
|
|
2543
|
+
"inputMode": {
|
|
2544
|
+
"type": "string"
|
|
2545
|
+
},
|
|
2546
|
+
"isReadOnly": {
|
|
2547
|
+
"type": "boolean"
|
|
2548
|
+
},
|
|
2549
|
+
"isRequired": {
|
|
2550
|
+
"type": "boolean"
|
|
2551
|
+
},
|
|
2552
|
+
"placeholder": {
|
|
2553
|
+
"type": "string"
|
|
2554
|
+
},
|
|
2555
|
+
"size": {
|
|
2556
|
+
"type": "string"
|
|
2557
|
+
},
|
|
2558
|
+
"type": {
|
|
2559
|
+
"type": "string"
|
|
2560
|
+
},
|
|
2561
|
+
"variation": {
|
|
2562
|
+
"type": "string"
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
},
|
|
2238
2566
|
"CheckboxField": {
|
|
2239
2567
|
"properties": {
|
|
2240
2568
|
"label": {
|
|
@@ -8,6 +8,7 @@ import '../../ThemeProvider/ThemeContext.mjs';
|
|
|
8
8
|
import '../../../primitives/Alert/AlertIcon.mjs';
|
|
9
9
|
import { View } from '../../../primitives/View/View.mjs';
|
|
10
10
|
import '../../../primitives/Icon/context/IconsContext.mjs';
|
|
11
|
+
import '../../FileSelect/FileSelect.mjs';
|
|
11
12
|
import '../../../primitives/Field/FieldClearButton.mjs';
|
|
12
13
|
import '../../../primitives/Field/FieldDescription.mjs';
|
|
13
14
|
import '../../../primitives/Field/FieldErrorMessage.mjs';
|
|
@@ -20,6 +21,7 @@ import '../../../primitives/Breadcrumbs/Breadcrumbs.mjs';
|
|
|
20
21
|
import '../../../primitives/Button/Button.mjs';
|
|
21
22
|
import '../../../primitives/ButtonGroup/ButtonGroup.mjs';
|
|
22
23
|
import '../../../primitives/Card/Card.mjs';
|
|
24
|
+
import '../../../primitives/Checkbox/Checkbox.mjs';
|
|
23
25
|
import '../../../primitives/CheckboxField/CheckboxField.mjs';
|
|
24
26
|
import '../../../primitives/Collection/Collection.mjs';
|
|
25
27
|
import '../../../primitives/Divider/Divider.mjs';
|
|
@@ -7,6 +7,7 @@ import '../../../primitives/Breadcrumbs/Breadcrumbs.mjs';
|
|
|
7
7
|
import { Button } from '../../../primitives/Button/Button.mjs';
|
|
8
8
|
import '../../../primitives/ButtonGroup/ButtonGroup.mjs';
|
|
9
9
|
import '../../../primitives/Card/Card.mjs';
|
|
10
|
+
import '../../../primitives/Checkbox/Checkbox.mjs';
|
|
10
11
|
import '../../../primitives/CheckboxField/CheckboxField.mjs';
|
|
11
12
|
import '../../../primitives/Collection/Collection.mjs';
|
|
12
13
|
import '../../../primitives/Divider/Divider.mjs';
|
|
@@ -7,6 +7,7 @@ import '../../ThemeProvider/ThemeContext.mjs';
|
|
|
7
7
|
import '../../../primitives/Alert/AlertIcon.mjs';
|
|
8
8
|
import '../../../primitives/View/View.mjs';
|
|
9
9
|
import '../../../primitives/Icon/context/IconsContext.mjs';
|
|
10
|
+
import '../../FileSelect/FileSelect.mjs';
|
|
10
11
|
import '../../../primitives/Field/FieldClearButton.mjs';
|
|
11
12
|
import '../../../primitives/Field/FieldDescription.mjs';
|
|
12
13
|
import '../../../primitives/Field/FieldErrorMessage.mjs';
|
|
@@ -19,6 +20,7 @@ import '../../../primitives/Breadcrumbs/Breadcrumbs.mjs';
|
|
|
19
20
|
import '../../../primitives/Button/Button.mjs';
|
|
20
21
|
import '../../../primitives/ButtonGroup/ButtonGroup.mjs';
|
|
21
22
|
import '../../../primitives/Card/Card.mjs';
|
|
23
|
+
import '../../../primitives/Checkbox/Checkbox.mjs';
|
|
22
24
|
import '../../../primitives/CheckboxField/CheckboxField.mjs';
|
|
23
25
|
import '../../../primitives/Collection/Collection.mjs';
|
|
24
26
|
import '../../../primitives/Divider/Divider.mjs';
|
|
@@ -7,6 +7,7 @@ import '../../../primitives/Breadcrumbs/Breadcrumbs.mjs';
|
|
|
7
7
|
import { Button } from '../../../primitives/Button/Button.mjs';
|
|
8
8
|
import '../../../primitives/ButtonGroup/ButtonGroup.mjs';
|
|
9
9
|
import { Card } from '../../../primitives/Card/Card.mjs';
|
|
10
|
+
import '../../../primitives/Checkbox/Checkbox.mjs';
|
|
10
11
|
import '../../../primitives/CheckboxField/CheckboxField.mjs';
|
|
11
12
|
import '../../../primitives/Collection/Collection.mjs';
|
|
12
13
|
import '../../../primitives/Divider/Divider.mjs';
|
|
@@ -7,6 +7,7 @@ import '../../../primitives/Breadcrumbs/Breadcrumbs.mjs';
|
|
|
7
7
|
import '../../../primitives/Button/Button.mjs';
|
|
8
8
|
import '../../../primitives/ButtonGroup/ButtonGroup.mjs';
|
|
9
9
|
import '../../../primitives/Card/Card.mjs';
|
|
10
|
+
import '../../../primitives/Checkbox/Checkbox.mjs';
|
|
10
11
|
import '../../../primitives/CheckboxField/CheckboxField.mjs';
|
|
11
12
|
import '../../../primitives/Collection/Collection.mjs';
|
|
12
13
|
import '../../../primitives/Divider/Divider.mjs';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { isFunction } from '@aws-amplify/ui';
|
|
3
|
+
import { useStableId } from '../../primitives/utils/useStableId.mjs';
|
|
4
|
+
|
|
5
|
+
// `FileSelect` input `type` must always be set to `file`
|
|
6
|
+
const INPUT_TYPE = 'file';
|
|
7
|
+
const TEST_ID = 'amplify-file-select';
|
|
8
|
+
const DEFAULT_PROPS = {
|
|
9
|
+
style: { display: 'none' },
|
|
10
|
+
type: 'file',
|
|
11
|
+
'data-testid': TEST_ID,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @internal @unstable
|
|
15
|
+
*/
|
|
16
|
+
const FileSelect = React__default.forwardRef(function FileSelect({ multiple = true, type = 'FILE', testId = 'amplify-file-select', ...props }, ref) {
|
|
17
|
+
return (React__default.createElement("input", { ...DEFAULT_PROPS, ...props, ...(type === 'FOLDER' ? { webkitdirectory: '' } : undefined), "data-testid": testId, multiple: multiple, ref: ref, type: INPUT_TYPE }));
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* @internal @unstable
|
|
21
|
+
*
|
|
22
|
+
* @usage
|
|
23
|
+
* ```tsx
|
|
24
|
+
* function MyUploadButton() {
|
|
25
|
+
* const [files, setFiles] = React.useState<File[]>([]);
|
|
26
|
+
* const [fileSelect, handleFileSelect] = useFileSelect(setFiles);
|
|
27
|
+
* return (
|
|
28
|
+
* <>
|
|
29
|
+
* {fileSelect}
|
|
30
|
+
* <Button
|
|
31
|
+
* onClick={() => {
|
|
32
|
+
* handleFileSelect('file');
|
|
33
|
+
* }}
|
|
34
|
+
* />
|
|
35
|
+
* </>
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
const useFileSelect = (onSelect) => {
|
|
41
|
+
const [inputProps, setInputProps] = React__default.useState(undefined);
|
|
42
|
+
const id = useStableId();
|
|
43
|
+
const ref = React__default.useRef(null);
|
|
44
|
+
React__default.useEffect(() => {
|
|
45
|
+
if (inputProps) {
|
|
46
|
+
ref.current?.click();
|
|
47
|
+
}
|
|
48
|
+
}, [id, inputProps]);
|
|
49
|
+
const handleFileSelect = React__default.useCallback((type, options) => {
|
|
50
|
+
if (id !== ref.current?.id)
|
|
51
|
+
return;
|
|
52
|
+
setInputProps({ type, ...options });
|
|
53
|
+
}, [id]);
|
|
54
|
+
const fileSelect = (React__default.createElement(FileSelect, { ...inputProps, id: id, onChange: (event) => {
|
|
55
|
+
if (isFunction(inputProps?.onChange))
|
|
56
|
+
inputProps?.onChange(event);
|
|
57
|
+
if (isFunction(onSelect) && !!event.target.files?.length) {
|
|
58
|
+
onSelect?.([...event.target.files]);
|
|
59
|
+
}
|
|
60
|
+
// Reset the input value to allow re-selecting the same file
|
|
61
|
+
if (ref.current) {
|
|
62
|
+
ref.current.value = '';
|
|
63
|
+
}
|
|
64
|
+
// clean up
|
|
65
|
+
setInputProps(undefined);
|
|
66
|
+
}, ref: ref }));
|
|
67
|
+
return [fileSelect, handleFileSelect];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { DEFAULT_PROPS, FileSelect, useFileSelect };
|
|
@@ -2,10 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
import { createComponentCSS } from '@aws-amplify/ui';
|
|
3
3
|
import { Style } from './Style.mjs';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @experimental
|
|
7
|
-
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
8
|
-
*/
|
|
9
5
|
const ComponentStyle = ({ theme, componentThemes = [], ...rest }) => {
|
|
10
6
|
if (!theme || !componentThemes.length) {
|
|
11
7
|
return null;
|
|
@@ -2,10 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
import { createGlobalCSS } from '@aws-amplify/ui';
|
|
3
3
|
import { Style } from './Style.mjs';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @experimental
|
|
7
|
-
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
8
|
-
*/
|
|
9
5
|
const GlobalStyle = ({ styles, ...rest }) => {
|
|
10
6
|
if (!styles) {
|
|
11
7
|
return null;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -19,6 +19,7 @@ export { Breadcrumbs } from './primitives/Breadcrumbs/Breadcrumbs.mjs';
|
|
|
19
19
|
export { Button } from './primitives/Button/Button.mjs';
|
|
20
20
|
export { ButtonGroup } from './primitives/ButtonGroup/ButtonGroup.mjs';
|
|
21
21
|
export { Card } from './primitives/Card/Card.mjs';
|
|
22
|
+
export { Checkbox } from './primitives/Checkbox/Checkbox.mjs';
|
|
22
23
|
export { CheckboxField } from './primitives/CheckboxField/CheckboxField.mjs';
|
|
23
24
|
export { Collection } from './primitives/Collection/Collection.mjs';
|
|
24
25
|
export { Divider } from './primitives/Divider/Divider.mjs';
|