@charcoal-ui/react 3.9.1 → 3.10.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/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuList/MenuListContext.d.ts +2 -1
- package/dist/components/DropdownSelector/MenuList/MenuListContext.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuList/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.d.ts +2 -1
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts +4 -0
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.story.d.ts +12 -5
- package/dist/components/DropdownSelector/index.story.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/index.story.d.ts.map +1 -1
- package/dist/index.cjs.js +44 -23
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +54 -33
- package/dist/index.esm.js.map +1 -1
- package/package.json +9 -7
- package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +5 -3
- package/src/components/DropdownSelector/ListItem/index.tsx +5 -1
- package/src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx +29 -18
- package/src/components/DropdownSelector/MenuList/MenuListContext.ts +3 -2
- package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +15 -9
- package/src/components/DropdownSelector/MenuList/index.tsx +6 -4
- package/src/components/DropdownSelector/MenuList/internals/getValuesRecursive.tsx +11 -8
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +2666 -396
- package/src/components/DropdownSelector/index.story.tsx +264 -103
- package/src/components/DropdownSelector/index.tsx +35 -7
- package/src/components/LoadingSpinner/LoadingSpinnerIcon.story.tsx +1 -0
- package/src/components/LoadingSpinner/index.story.tsx +1 -0
- package/src/components/Modal/__snapshots__/index.story.storyshot +76 -0
package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMenuItemHandleKeyDown.d.ts","sourceRoot":"","sources":["../../../../../src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,CAAC,EAAE,MAAM,GACb,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,MAAM,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"useMenuItemHandleKeyDown.d.ts","sourceRoot":"","sources":["../../../../../src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,CAAC,EAAE,MAAM,GACb,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,MAAM,IAAI,CAAC,CAoDhE"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
+
import { DropdownMenuItemProps } from '../DropdownMenuItem';
|
|
2
3
|
type MenuListContextType = {
|
|
3
4
|
root?: RefObject<HTMLUListElement>;
|
|
4
5
|
value?: string;
|
|
5
|
-
|
|
6
|
+
propsArray?: DropdownMenuItemProps[];
|
|
6
7
|
setValue: (v: string) => void;
|
|
7
8
|
};
|
|
8
9
|
export declare const MenuListContext: import("react").Context<MenuListContextType>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuListContext.d.ts","sourceRoot":"","sources":["../../../../src/components/DropdownSelector/MenuList/MenuListContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"MenuListContext.d.ts","sourceRoot":"","sources":["../../../../src/components/DropdownSelector/MenuList/MenuListContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,OAAO,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,KAAK,mBAAmB,GAAG;IACzB,IAAI,CAAC,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAA;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,qBAAqB,EAAE,CAAA;IACpC,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,eAAe,8CAO1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/DropdownSelector/MenuList/index.tsx"],"names":[],"mappings":"AAIA,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAE5C,KAAK,aAAa,GAAG,KAAK,CAAC,YAAY,CACrC,OAAO,QAAQ,GAAG,OAAO,aAAa,GAAG,OAAO,OAAO,CACxD,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,aAAa,EAAE,CAAA;AAE9D,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/DropdownSelector/MenuList/index.tsx"],"names":[],"mappings":"AAIA,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAE5C,KAAK,aAAa,GAAG,KAAK,CAAC,YAAY,CACrC,OAAO,QAAQ,GAAG,OAAO,aAAa,GAAG,OAAO,OAAO,CACxD,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,aAAa,EAAE,CAAA;AAE9D,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,KAAK,EAAE,aAAa,eAuBpD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MenuListChildren } from '..';
|
|
2
|
+
import { DropdownMenuItemProps } from '../../DropdownMenuItem';
|
|
2
3
|
/**
|
|
3
4
|
* valueというpropsを持つ子要素の値を再起的に探索して配列にする
|
|
4
5
|
*
|
|
@@ -7,5 +8,5 @@ import { MenuListChildren } from '..';
|
|
|
7
8
|
* @param values
|
|
8
9
|
* @returns
|
|
9
10
|
*/
|
|
10
|
-
export declare function getValuesRecursive(children: MenuListChildren
|
|
11
|
+
export declare function getValuesRecursive(children: MenuListChildren): DropdownMenuItemProps[];
|
|
11
12
|
//# sourceMappingURL=getValuesRecursive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getValuesRecursive.d.ts","sourceRoot":"","sources":["../../../../../src/components/DropdownSelector/MenuList/internals/getValuesRecursive.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"getValuesRecursive.d.ts","sourceRoot":"","sources":["../../../../../src/components/DropdownSelector/MenuList/internals/getValuesRecursive.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAA;AAErC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAE9D;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,gBAAgB,2BAuB5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownSelector/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownSelector/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA6B,MAAM,OAAO,CAAA;AAO5D,OAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAKvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAClC,CAAA;AAID,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,eAgFpE"}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import DropdownSelector
|
|
1
|
+
import DropdownSelector from '.';
|
|
2
2
|
import { StoryObj } from '@storybook/react';
|
|
3
|
-
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, DropdownSelectorProps>;
|
|
3
|
+
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import(".").DropdownSelectorProps>;
|
|
4
4
|
export default _default;
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
5
|
+
export declare const Default: StoryObj<typeof DropdownSelector>;
|
|
6
|
+
export declare const Label: StoryObj<typeof DropdownSelector>;
|
|
7
|
+
export declare const Disabled: StoryObj<typeof DropdownSelector>;
|
|
8
|
+
export declare const DisabledItem: StoryObj<typeof DropdownSelector>;
|
|
9
|
+
export declare const Invalid: StoryObj<typeof DropdownSelector>;
|
|
10
|
+
export declare const AssistiveText: StoryObj<typeof DropdownSelector>;
|
|
11
|
+
export declare const InvalidAssistiveText: StoryObj<typeof DropdownSelector>;
|
|
12
|
+
export declare const RequiredText: StoryObj<typeof DropdownSelector>;
|
|
13
|
+
export declare const SubLabel: StoryObj<typeof DropdownSelector>;
|
|
7
14
|
export declare const LongNames: StoryObj<typeof DropdownSelector>;
|
|
8
15
|
export declare const InModal: StoryObj<typeof DropdownSelector>;
|
|
9
16
|
export declare const InFormTag: StoryObj<typeof DropdownSelector>;
|
|
10
17
|
export declare const CustomChildren: StoryObj<typeof DropdownSelector>;
|
|
11
|
-
export declare const
|
|
18
|
+
export declare const Section: StoryObj<typeof DropdownSelector>;
|
|
12
19
|
//# sourceMappingURL=index.story.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownSelector/index.story.tsx"],"names":[],"mappings":"AACA,OAAO,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownSelector/index.story.tsx"],"names":[],"mappings":"AACA,OAAO,gBAAgB,MAAM,GAAG,CAAA;AAMhC,OAAO,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAA;;AAKjD,wBAGkC;AAElC,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CAoBrD,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CAkBnD,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CAkBtD,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CAiB1D,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CAkBrD,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CAkB3D,CAAA;AAED,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CAmBlE,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CAqB1D,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CAoBtD,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CA+BvD,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CAkFrD,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CAwCvD,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CAoC5D,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,OAAO,gBAAgB,CA4BrD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadingSpinnerIcon.story.d.ts","sourceRoot":"","sources":["../../../src/components/LoadingSpinner/LoadingSpinnerIcon.story.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,GAAG,CAAA;;;;AAEtC,
|
|
1
|
+
{"version":3,"file":"LoadingSpinnerIcon.story.d.ts","sourceRoot":"","sources":["../../../src/components/LoadingSpinner/LoadingSpinnerIcon.story.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,GAAG,CAAA;;;;AAEtC,wBAOoC;AAEpC,eAAO,MAAM,IAAI,EAAE,QAAQ,CAAC,OAAO,kBAAkB,CAAM,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/components/LoadingSpinner/index.story.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,cAAc,MAAM,GAAG,CAAA;;AAE9B,
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/components/LoadingSpinner/index.story.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,cAAc,MAAM,GAAG,CAAA;;AAE9B,wBAUgC;AAEhC,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,OAAO,cAAc,CAAM,CAAA"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1276,40 +1276,43 @@ var import_react18 = require("react");
|
|
|
1276
1276
|
var MenuListContext = (0, import_react18.createContext)({
|
|
1277
1277
|
root: void 0,
|
|
1278
1278
|
value: "",
|
|
1279
|
-
|
|
1279
|
+
propsArray: [],
|
|
1280
1280
|
setValue: (_v) => {
|
|
1281
1281
|
}
|
|
1282
1282
|
});
|
|
1283
1283
|
|
|
1284
1284
|
// src/components/DropdownSelector/MenuList/internals/getValuesRecursive.tsx
|
|
1285
1285
|
var React12 = __toESM(require("react"));
|
|
1286
|
-
function getValuesRecursive(children
|
|
1286
|
+
function getValuesRecursive(children) {
|
|
1287
1287
|
const childArray = React12.Children.toArray(children);
|
|
1288
|
+
const propsArray = [];
|
|
1288
1289
|
for (let i = 0; i < childArray.length; i++) {
|
|
1289
1290
|
const child = childArray[i];
|
|
1290
1291
|
if (React12.isValidElement(child)) {
|
|
1291
1292
|
const props = child.props;
|
|
1292
1293
|
if ("value" in props && typeof props.value === "string") {
|
|
1293
|
-
|
|
1294
|
-
|
|
1294
|
+
propsArray.push({
|
|
1295
|
+
disabled: props.disabled,
|
|
1296
|
+
value: props.value
|
|
1297
|
+
});
|
|
1295
1298
|
}
|
|
1296
1299
|
if ("children" in props && props.children) {
|
|
1297
|
-
getValuesRecursive(props.children
|
|
1300
|
+
propsArray.push(...getValuesRecursive(props.children));
|
|
1298
1301
|
}
|
|
1299
1302
|
}
|
|
1300
1303
|
}
|
|
1304
|
+
return propsArray;
|
|
1301
1305
|
}
|
|
1302
1306
|
|
|
1303
1307
|
// src/components/DropdownSelector/MenuList/index.tsx
|
|
1304
1308
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1305
1309
|
function MenuList(props) {
|
|
1306
1310
|
const root = (0, import_react19.useRef)(null);
|
|
1307
|
-
const
|
|
1308
|
-
getValuesRecursive(props.children, values);
|
|
1311
|
+
const propsArray = (0, import_react19.useMemo)(() => getValuesRecursive(props.children), [props.children]);
|
|
1309
1312
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(StyledUl, { ref: root, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(MenuListContext.Provider, { value: {
|
|
1310
1313
|
value: props.value ?? "",
|
|
1311
1314
|
root,
|
|
1312
|
-
|
|
1315
|
+
propsArray,
|
|
1313
1316
|
setValue: (v) => {
|
|
1314
1317
|
props.onChange?.(v);
|
|
1315
1318
|
}
|
|
@@ -1321,20 +1324,29 @@ var StyledUl = import_styled_components16.default.ul.withConfig({
|
|
|
1321
1324
|
|
|
1322
1325
|
// src/components/DropdownSelector/index.tsx
|
|
1323
1326
|
var import_styled8 = require("@charcoal-ui/styled");
|
|
1327
|
+
var import_visually_hidden3 = require("@react-aria/visually-hidden");
|
|
1324
1328
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1325
1329
|
var defaultRequiredText = "*\u5FC5\u9808";
|
|
1326
1330
|
function DropdownSelector(props) {
|
|
1327
1331
|
const triggerRef = (0, import_react20.useRef)(null);
|
|
1328
1332
|
const [isOpen, setIsOpen] = (0, import_react20.useState)(false);
|
|
1329
1333
|
const preview = findPreviewRecursive(props.children, props.value);
|
|
1334
|
+
const isPlaceholder = (0, import_react20.useMemo)(() => props.placeholder !== void 0 && preview === void 0, [preview, props.placeholder]);
|
|
1335
|
+
const propsArray = getValuesRecursive(props.children);
|
|
1336
|
+
const {
|
|
1337
|
+
visuallyHiddenProps
|
|
1338
|
+
} = (0, import_visually_hidden3.useVisuallyHidden)();
|
|
1330
1339
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropdownSelectorRoot, { "aria-disabled": props.disabled, children: [
|
|
1331
1340
|
props.showLabel === true && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DropdownFieldLabel, { label: props.label, required: props.required, requiredText: props.requiredText ?? defaultRequiredText, subLabel: props.subLabel }),
|
|
1341
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { ...visuallyHiddenProps, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("select", { name: props.name, value: props.value, tabIndex: -1, children: propsArray.map((itemProps) => {
|
|
1342
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: itemProps.value, disabled: itemProps.disabled, children: itemProps.value }, itemProps.value);
|
|
1343
|
+
}) }) }),
|
|
1332
1344
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropdownButton, { invalid: props.invalid, disabled: props.disabled, onClick: () => {
|
|
1333
1345
|
if (props.disabled === true)
|
|
1334
1346
|
return;
|
|
1335
1347
|
setIsOpen(true);
|
|
1336
1348
|
}, ref: triggerRef, type: "button", $active: isOpen, children: [
|
|
1337
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DropdownButtonText, {
|
|
1349
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DropdownButtonText, { $isText3: isPlaceholder, children: isPlaceholder ? props.placeholder : preview }),
|
|
1338
1350
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DropdownButtonIcon, { name: "16/Menu" })
|
|
1339
1351
|
] }),
|
|
1340
1352
|
isOpen && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DropdownPopover, { isOpen, onClose: () => setIsOpen(false), triggerRef, value: props.value, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(MenuList, { value: props.value, onChange: (v) => {
|
|
@@ -1359,7 +1371,7 @@ var DropdownButton = import_styled_components17.default.button.withConfig({
|
|
|
1359
1371
|
}) => invalid === true && (0, import_styled_components17.css)(["&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{box-shadow:0 0 0 4px rgba(255,43,0,0.32);}"]));
|
|
1360
1372
|
var DropdownButtonText = import_styled_components17.default.span.withConfig({
|
|
1361
1373
|
componentId: "ccl__sc-1vnxmc8-3"
|
|
1362
|
-
})(["text-align:left;font-size:14px;line-height:22px;display:flow-root;color:var(--charcoal-
|
|
1374
|
+
})(["text-align:left;font-size:14px;line-height:22px;display:flow-root;color:var(--charcoal-", ");overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"], (p) => p.$isText3 ? "text3" : "text2");
|
|
1363
1375
|
var DropdownButtonIcon = (0, import_styled_components17.default)(Icon_default).withConfig({
|
|
1364
1376
|
componentId: "ccl__sc-1vnxmc8-4"
|
|
1365
1377
|
})(["color:var(--charcoal-text2);"]);
|
|
@@ -1387,7 +1399,7 @@ var StyledLi = import_styled_components18.default.li.withConfig({
|
|
|
1387
1399
|
})(["list-style:none;"]);
|
|
1388
1400
|
var ItemDiv = import_styled_components18.default.div.withConfig({
|
|
1389
1401
|
componentId: "ccl__sc-p1vs75-1"
|
|
1390
|
-
})(["display:flex;align-items:center;min-height:40px;cursor:pointer;outline:none;padding-right:16px;padding-left:16px;&:disabled,&[aria-disabled]:not([aria-disabled='false']){opacity:0.32;cursor:default;}:hover,:focus,:focus-within{background-color:var(--charcoal-surface3);}"]);
|
|
1402
|
+
})(["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);}}"]);
|
|
1391
1403
|
|
|
1392
1404
|
// src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx
|
|
1393
1405
|
var import_react21 = require("react");
|
|
@@ -1426,7 +1438,7 @@ function useMenuItemHandleKeyDown(value) {
|
|
|
1426
1438
|
const {
|
|
1427
1439
|
setValue,
|
|
1428
1440
|
root,
|
|
1429
|
-
|
|
1441
|
+
propsArray
|
|
1430
1442
|
} = (0, import_react21.useContext)(MenuListContext);
|
|
1431
1443
|
const setContextValue = (0, import_react21.useCallback)(() => {
|
|
1432
1444
|
if (value !== void 0)
|
|
@@ -1436,24 +1448,33 @@ function useMenuItemHandleKeyDown(value) {
|
|
|
1436
1448
|
if (e.key === "Enter") {
|
|
1437
1449
|
setContextValue();
|
|
1438
1450
|
} else if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
1451
|
+
const isForward = e.key === "ArrowDown";
|
|
1439
1452
|
e.preventDefault();
|
|
1440
|
-
if (!
|
|
1453
|
+
if (!propsArray || value === void 0)
|
|
1441
1454
|
return;
|
|
1442
|
-
const
|
|
1455
|
+
const values = propsArray.map((props) => props.value).filter((v) => v);
|
|
1456
|
+
let index = values.indexOf(value);
|
|
1443
1457
|
if (index === -1)
|
|
1444
1458
|
return;
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
next
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1459
|
+
for (let n = 0; n < values.length; n++) {
|
|
1460
|
+
const focusValue = isForward ? index + 1 >= values.length ? values[0] : values[index + 1] : index - 1 < 0 ? values[values.length - 1] : values[index - 1];
|
|
1461
|
+
const next = root?.current?.querySelector(`[data-key='${focusValue}']`);
|
|
1462
|
+
if (next instanceof HTMLElement) {
|
|
1463
|
+
if (next.ariaDisabled === "true") {
|
|
1464
|
+
index += isForward ? 1 : -1;
|
|
1465
|
+
continue;
|
|
1466
|
+
}
|
|
1467
|
+
next.focus({
|
|
1468
|
+
preventScroll: true
|
|
1469
|
+
});
|
|
1470
|
+
if (root?.current?.parentElement) {
|
|
1471
|
+
handleFocusByKeyBoard(next, root.current.parentElement);
|
|
1472
|
+
}
|
|
1473
|
+
break;
|
|
1453
1474
|
}
|
|
1454
1475
|
}
|
|
1455
1476
|
}
|
|
1456
|
-
}, [setContextValue, value, root
|
|
1477
|
+
}, [setContextValue, propsArray, value, root]);
|
|
1457
1478
|
return [handleKeyDown, setContextValue];
|
|
1458
1479
|
}
|
|
1459
1480
|
|