@charcoal-ui/react 3.10.1-beta.0 → 3.10.1
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/components/Button/index.story.d.ts +4 -9
- package/dist/components/Button/index.story.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/index.cjs.js +9 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +13 -7
- package/dist/index.esm.js.map +1 -1
- package/package.json +7 -7
- package/src/components/Button/__snapshots__/index.story.storyshot +91 -939
- package/src/components/Button/index.story.tsx +14 -161
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +15 -0
- package/src/components/DropdownSelector/index.tsx +19 -4
- package/src/components/Modal/__snapshots__/index.story.storyshot +2 -0
package/dist/index.esm.js
CHANGED
|
@@ -1089,7 +1089,7 @@ var LoadingSpinnerIcon = forwardRef14(function LoadingSpinnerIcon2({
|
|
|
1089
1089
|
});
|
|
1090
1090
|
|
|
1091
1091
|
// src/components/DropdownSelector/index.tsx
|
|
1092
|
-
import { useState as useState3, useRef as useRef9, useMemo as useMemo3 } from "react";
|
|
1092
|
+
import { useState as useState3, useRef as useRef9, useMemo as useMemo3, useCallback as useCallback6 } from "react";
|
|
1093
1093
|
import styled16, { css as css9 } from "styled-components";
|
|
1094
1094
|
import { disabledSelector as disabledSelector2 } from "@charcoal-ui/utils";
|
|
1095
1095
|
|
|
@@ -1267,7 +1267,10 @@ import { focusVisibleFocusRingCss as focusVisibleFocusRingCss6 } from "@charcoal
|
|
|
1267
1267
|
import { useVisuallyHidden as useVisuallyHidden3 } from "@react-aria/visually-hidden";
|
|
1268
1268
|
import { jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1269
1269
|
var defaultRequiredText = "*\u5FC5\u9808";
|
|
1270
|
-
function DropdownSelector(
|
|
1270
|
+
function DropdownSelector({
|
|
1271
|
+
onChange,
|
|
1272
|
+
...props
|
|
1273
|
+
}) {
|
|
1271
1274
|
const triggerRef = useRef9(null);
|
|
1272
1275
|
const [isOpen, setIsOpen] = useState3(false);
|
|
1273
1276
|
const preview = findPreviewRecursive(props.children, props.value);
|
|
@@ -1276,9 +1279,12 @@ function DropdownSelector(props) {
|
|
|
1276
1279
|
const {
|
|
1277
1280
|
visuallyHiddenProps
|
|
1278
1281
|
} = useVisuallyHidden3();
|
|
1282
|
+
const handleChange = useCallback6((e) => {
|
|
1283
|
+
onChange(e.target.value);
|
|
1284
|
+
}, [onChange]);
|
|
1279
1285
|
return /* @__PURE__ */ jsxs10(DropdownSelectorRoot, { "aria-disabled": props.disabled, children: [
|
|
1280
1286
|
props.showLabel === true && /* @__PURE__ */ jsx20(DropdownFieldLabel, { label: props.label, required: props.required, requiredText: props.requiredText ?? defaultRequiredText, subLabel: props.subLabel }),
|
|
1281
|
-
/* @__PURE__ */ jsx20("div", { ...visuallyHiddenProps, "aria-hidden": "true", children: /* @__PURE__ */ jsx20("select", { name: props.name, value: props.value, tabIndex: -1, children: propsArray.map((itemProps) => {
|
|
1287
|
+
/* @__PURE__ */ jsx20("div", { ...visuallyHiddenProps, "aria-hidden": "true", children: /* @__PURE__ */ jsx20("select", { name: props.name, value: props.value, onChange: handleChange, tabIndex: -1, children: propsArray.map((itemProps) => {
|
|
1282
1288
|
return /* @__PURE__ */ jsx20("option", { value: itemProps.value, disabled: itemProps.disabled, children: itemProps.value }, itemProps.value);
|
|
1283
1289
|
}) }) }),
|
|
1284
1290
|
/* @__PURE__ */ jsxs10(DropdownButton, { invalid: props.invalid, disabled: props.disabled, onClick: () => {
|
|
@@ -1290,7 +1296,7 @@ function DropdownSelector(props) {
|
|
|
1290
1296
|
/* @__PURE__ */ jsx20(DropdownButtonIcon, { name: "16/Menu" })
|
|
1291
1297
|
] }),
|
|
1292
1298
|
isOpen && /* @__PURE__ */ jsx20(DropdownPopover, { isOpen, onClose: () => setIsOpen(false), triggerRef, value: props.value, children: /* @__PURE__ */ jsx20(MenuList, { value: props.value, onChange: (v) => {
|
|
1293
|
-
|
|
1299
|
+
onChange(v);
|
|
1294
1300
|
setIsOpen(false);
|
|
1295
1301
|
}, children: props.children }) }),
|
|
1296
1302
|
props.assistiveText !== void 0 && /* @__PURE__ */ jsx20(AssertiveText, { invalid: props.invalid, children: props.assistiveText })
|
|
@@ -1342,7 +1348,7 @@ var ItemDiv = styled17.div.withConfig({
|
|
|
1342
1348
|
})(["display:flex;align-items:center;min-height:40px;cursor:pointer;outline:none;padding-right:16px;padding-left:16px;transition:background-color 0.2s;&:disabled,&[aria-disabled]:not([aria-disabled='false']){opacity:0.32;cursor:default;}:hover,:focus,:focus-within{&:not(disabled):not([aria-disabled='true']){background-color:var(--charcoal-surface3);}}"]);
|
|
1343
1349
|
|
|
1344
1350
|
// src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx
|
|
1345
|
-
import { useCallback as
|
|
1351
|
+
import { useCallback as useCallback7, useContext as useContext7 } from "react";
|
|
1346
1352
|
|
|
1347
1353
|
// src/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.tsx
|
|
1348
1354
|
function handleFocusByKeyBoard(element, parent) {
|
|
@@ -1380,11 +1386,11 @@ function useMenuItemHandleKeyDown(value) {
|
|
|
1380
1386
|
root,
|
|
1381
1387
|
propsArray
|
|
1382
1388
|
} = useContext7(MenuListContext);
|
|
1383
|
-
const setContextValue =
|
|
1389
|
+
const setContextValue = useCallback7(() => {
|
|
1384
1390
|
if (value !== void 0)
|
|
1385
1391
|
setValue(value);
|
|
1386
1392
|
}, [value, setValue]);
|
|
1387
|
-
const handleKeyDown =
|
|
1393
|
+
const handleKeyDown = useCallback7((e) => {
|
|
1388
1394
|
if (e.key === "Enter") {
|
|
1389
1395
|
setContextValue();
|
|
1390
1396
|
} else if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|