@charcoal-ui/react 4.0.0-beta.2 → 4.0.0-beta.3
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.d.ts +9 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.story.d.ts +4 -6
- package/dist/components/Button/index.story.d.ts.map +1 -1
- package/dist/components/Button/index.test.d.ts +2 -0
- package/dist/components/Button/index.test.d.ts.map +1 -0
- package/dist/components/DropdownSelector/index.d.ts +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/index.cjs.js +11 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +15 -8
- package/dist/index.esm.js.map +1 -1
- package/package.json +7 -7
- package/src/components/Button/__snapshots__/index.story.storyshot +11 -49
- package/src/components/Button/__snapshots__/index.test.tsx.snap +11 -0
- package/src/components/Button/index.story.tsx +13 -66
- package/src/components/Button/index.test.tsx +32 -0
- package/src/components/Button/index.tsx +11 -1
- 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
|
@@ -8,8 +8,16 @@ export type ButtonProps<T extends React.ElementType = 'button'> = {
|
|
|
8
8
|
size?: Size;
|
|
9
9
|
fullWidth?: boolean;
|
|
10
10
|
isActive?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The component used for root element.
|
|
13
|
+
* @type T extends React.ElementType = 'button'
|
|
14
|
+
*/
|
|
11
15
|
as?: T;
|
|
12
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The as property of the component specified by the Button component's as attribute.
|
|
18
|
+
*/
|
|
19
|
+
componentAs?: React.ComponentPropsWithRef<T>['as'];
|
|
20
|
+
} & Omit<React.ComponentPropsWithRef<T>, 'children' | 'as'>;
|
|
13
21
|
declare const Button: <T extends React.ElementType<any> = "button">(p: ButtonProps<T>) => JSX.Element;
|
|
14
22
|
export default Button;
|
|
15
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,EAAgB,SAAS,EAAuB,MAAM,OAAO,CAAA;AAI3E,KAAK,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAA;AAE1E,KAAK,IAAI,GAAG,GAAG,GAAG,GAAG,CAAA;AAErB,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,IAAI;IAChE,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,EAAE,CAAC,EAAE,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,EAAgB,SAAS,EAAuB,MAAM,OAAO,CAAA;AAI3E,KAAK,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAA;AAE1E,KAAK,IAAI,GAAG,GAAG,GAAG,GAAG,CAAA;AAErB,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,IAAI;IAChE,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,EAAE,CAAC,EAAE,CAAC,CAAA;IACN;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;CACnD,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC,CAAA;AAE3D,QAAA,MAAM,MAAM,sEA2ByD,WAAW,CAAA;AAChF,eAAe,MAAM,CAAA"}
|
|
@@ -7,7 +7,8 @@ declare const _default: import("@storybook/types").ComponentAnnotations<import("
|
|
|
7
7
|
fullWidth?: boolean | undefined;
|
|
8
8
|
isActive?: boolean | undefined;
|
|
9
9
|
as?: import("react").ElementType<any> | undefined;
|
|
10
|
-
|
|
10
|
+
componentAs?: any;
|
|
11
|
+
} & Omit<any, "children" | "as">>;
|
|
11
12
|
export default _default;
|
|
12
13
|
export declare const Default: StoryObj<typeof Button>;
|
|
13
14
|
export declare const Primary: StoryObj<typeof Button>;
|
|
@@ -15,10 +16,7 @@ export declare const Navigation: StoryObj<typeof Button>;
|
|
|
15
16
|
export declare const Overlay: StoryObj<typeof Button>;
|
|
16
17
|
export declare const Danger: StoryObj<typeof Button>;
|
|
17
18
|
export declare const Small: StoryObj<typeof Button>;
|
|
18
|
-
export declare const
|
|
19
|
+
export declare const FullWidth: StoryObj<typeof Button>;
|
|
19
20
|
export declare const Disabled: StoryObj<typeof Button>;
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const Link: StoryObj<typeof Button>;
|
|
22
|
-
export declare const Nihongo: StoryObj<typeof Button>;
|
|
23
|
-
export declare const Focus: StoryObj<typeof Button>;
|
|
21
|
+
export declare const IsActive: StoryObj<typeof Button>;
|
|
24
22
|
//# sourceMappingURL=index.story.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.story.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.story.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,GAAG,CAAA;AACtB,OAAO,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAA;;;;;;;;;;AAEjD,wBAGwB;AAExB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,OAAO,MAAM,CAE3C,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,OAAO,MAAM,CAE3C,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,OAAO,MAAM,CAE9C,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,OAAO,MAAM,CAE3C,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,OAAO,MAAM,CAE1C,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,OAAO,MAAM,CAEzC,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,OAAO,MAAM,CAE7C,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,OAAO,MAAM,CAE5C,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,OAAO,MAAM,CAE5C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.test.tsx"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAA"}
|
|
@@ -18,5 +18,5 @@ export type DropdownSelectorProps = {
|
|
|
18
18
|
children: MenuListChildren;
|
|
19
19
|
onChange: (value: string) => void;
|
|
20
20
|
};
|
|
21
|
-
export default function DropdownSelector(props: DropdownSelectorProps): JSX.Element;
|
|
21
|
+
export default function DropdownSelector({ onChange, ...props }: DropdownSelectorProps): JSX.Element;
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownSelector/index.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownSelector/index.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAA0C,MAAM,OAAO,CAAA;AAOhF,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,EACvC,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,qBAAqB,eA4FvB"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -128,11 +128,12 @@ var Button = (0, import_react3.forwardRef)(function Button2({
|
|
|
128
128
|
className,
|
|
129
129
|
as,
|
|
130
130
|
isActive,
|
|
131
|
+
componentAs,
|
|
131
132
|
...props
|
|
132
133
|
}, ref) {
|
|
133
134
|
const Component = (0, import_react3.useMemo)(() => as ?? "button", [as]);
|
|
134
135
|
const classNames = useClassNames("charcoal-button", className);
|
|
135
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, { ...props, className: classNames, "data-variant": variant, "data-size": size, "data-full-width": fullWidth, "data-active": isActive, ref });
|
|
136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, { ...props, as: componentAs, className: classNames, "data-variant": variant, "data-size": size, "data-full-width": fullWidth, "data-active": isActive, ref });
|
|
136
137
|
});
|
|
137
138
|
var Button_default = Button;
|
|
138
139
|
|
|
@@ -1284,7 +1285,10 @@ var import_styled7 = require("@charcoal-ui/styled");
|
|
|
1284
1285
|
var import_visually_hidden3 = require("@react-aria/visually-hidden");
|
|
1285
1286
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1286
1287
|
var defaultRequiredText = "*\u5FC5\u9808";
|
|
1287
|
-
function DropdownSelector(
|
|
1288
|
+
function DropdownSelector({
|
|
1289
|
+
onChange,
|
|
1290
|
+
...props
|
|
1291
|
+
}) {
|
|
1288
1292
|
const triggerRef = (0, import_react21.useRef)(null);
|
|
1289
1293
|
const [isOpen, setIsOpen] = (0, import_react21.useState)(false);
|
|
1290
1294
|
const preview = findPreviewRecursive(props.children, props.value);
|
|
@@ -1293,9 +1297,12 @@ function DropdownSelector(props) {
|
|
|
1293
1297
|
const {
|
|
1294
1298
|
visuallyHiddenProps
|
|
1295
1299
|
} = (0, import_visually_hidden3.useVisuallyHidden)();
|
|
1300
|
+
const handleChange = (0, import_react21.useCallback)((e) => {
|
|
1301
|
+
onChange(e.target.value);
|
|
1302
|
+
}, [onChange]);
|
|
1296
1303
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropdownSelectorRoot, { "aria-disabled": props.disabled, children: [
|
|
1297
1304
|
props.showLabel === true && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DropdownFieldLabel, { label: props.label, required: props.required, requiredText: props.requiredText ?? defaultRequiredText, subLabel: props.subLabel }),
|
|
1298
|
-
/* @__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) => {
|
|
1305
|
+
/* @__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, onChange: handleChange, tabIndex: -1, children: propsArray.map((itemProps) => {
|
|
1299
1306
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: itemProps.value, disabled: itemProps.disabled, children: itemProps.value }, itemProps.value);
|
|
1300
1307
|
}) }) }),
|
|
1301
1308
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropdownButton, { invalid: props.invalid, disabled: props.disabled, onClick: () => {
|
|
@@ -1307,7 +1314,7 @@ function DropdownSelector(props) {
|
|
|
1307
1314
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DropdownButtonIcon, { name: "16/Menu" })
|
|
1308
1315
|
] }),
|
|
1309
1316
|
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) => {
|
|
1310
|
-
|
|
1317
|
+
onChange(v);
|
|
1311
1318
|
setIsOpen(false);
|
|
1312
1319
|
}, children: props.children }) }),
|
|
1313
1320
|
props.assistiveText !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AssertiveText, { invalid: props.invalid, children: props.assistiveText })
|