@wordpress/ui 0.4.0 → 0.5.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/CHANGELOG.md +20 -0
- package/LICENSE.md +1 -1
- package/README.md +18 -0
- package/build/badge/badge.cjs +95 -0
- package/build/badge/badge.cjs.map +7 -0
- package/build/{lock-unlock.js → badge/index.cjs} +8 -14
- package/build/badge/index.cjs.map +7 -0
- package/build/badge/types.cjs +19 -0
- package/build/badge/types.cjs.map +7 -0
- package/build/box/{box.js → box.cjs} +7 -6
- package/build/box/box.cjs.map +7 -0
- package/build/box/{index.js → index.cjs} +2 -2
- package/build/box/{types.js → types.cjs} +1 -1
- package/build/box/types.cjs.map +7 -0
- package/build/button/button.cjs +401 -0
- package/build/button/button.cjs.map +7 -0
- package/build/{utils/element.js → button/icon.cjs} +22 -20
- package/build/button/icon.cjs.map +7 -0
- package/build/button/index.cjs +39 -0
- package/build/button/index.cjs.map +7 -0
- package/build/button/types.cjs +19 -0
- package/build/button/types.cjs.map +7 -0
- package/build/form/primitives/field/control.cjs +38 -0
- package/build/form/primitives/field/control.cjs.map +7 -0
- package/build/form/primitives/field/description.cjs +92 -0
- package/build/form/primitives/field/description.cjs.map +7 -0
- package/build/form/primitives/field/details.cjs +99 -0
- package/build/form/primitives/field/details.cjs.map +7 -0
- package/build/form/primitives/field/index.cjs +46 -0
- package/build/form/primitives/field/index.cjs.map +7 -0
- package/build/form/primitives/field/item.cjs +36 -0
- package/build/form/primitives/field/item.cjs.map +7 -0
- package/build/form/primitives/field/label.cjs +98 -0
- package/build/form/primitives/field/label.cjs.map +7 -0
- package/build/form/primitives/field/root.cjs +79 -0
- package/build/form/primitives/field/root.cjs.map +7 -0
- package/build/form/primitives/field/types.cjs +19 -0
- package/build/form/primitives/field/types.cjs.map +7 -0
- package/build/form/primitives/fieldset/context.cjs +40 -0
- package/build/form/primitives/fieldset/context.cjs.map +7 -0
- package/build/form/primitives/fieldset/description.cjs +101 -0
- package/build/form/primitives/fieldset/description.cjs.map +7 -0
- package/build/form/primitives/fieldset/details.cjs +103 -0
- package/build/form/primitives/fieldset/details.cjs.map +7 -0
- package/build/form/primitives/fieldset/index.cjs +40 -0
- package/build/form/primitives/fieldset/index.cjs.map +7 -0
- package/build/form/primitives/fieldset/legend.cjs +94 -0
- package/build/form/primitives/fieldset/legend.cjs.map +7 -0
- package/build/form/primitives/fieldset/root.cjs +86 -0
- package/build/form/primitives/fieldset/root.cjs.map +7 -0
- package/build/form/primitives/fieldset/types.cjs +19 -0
- package/build/form/primitives/fieldset/types.cjs.map +7 -0
- package/build/form/primitives/index.cjs +50 -0
- package/build/form/primitives/index.cjs.map +7 -0
- package/build/form/primitives/input/index.cjs +31 -0
- package/build/form/primitives/input/index.cjs.map +7 -0
- package/build/form/primitives/input/input.cjs +148 -0
- package/build/form/primitives/input/input.cjs.map +7 -0
- package/build/form/primitives/input/types.cjs +19 -0
- package/build/form/primitives/input/types.cjs.map +7 -0
- package/build/form/primitives/input-layout/context.cjs +49 -0
- package/build/form/primitives/input-layout/context.cjs.map +7 -0
- package/build/form/primitives/input-layout/index.cjs +35 -0
- package/build/form/primitives/input-layout/index.cjs.map +7 -0
- package/build/form/primitives/input-layout/input-layout.cjs +196 -0
- package/build/form/primitives/input-layout/input-layout.cjs.map +7 -0
- package/build/form/primitives/input-layout/slot.cjs +165 -0
- package/build/form/primitives/input-layout/slot.cjs.map +7 -0
- package/build/form/primitives/input-layout/types.cjs +19 -0
- package/build/form/primitives/input-layout/types.cjs.map +7 -0
- package/build/icon/icon.cjs +46 -0
- package/build/icon/icon.cjs.map +7 -0
- package/build/{index.js → icon/index.cjs} +13 -7
- package/build/icon/index.cjs.map +7 -0
- package/build/icon/types.cjs +19 -0
- package/build/icon/types.cjs.map +7 -0
- package/build/index.cjs +37 -0
- package/build/index.cjs.map +7 -0
- package/build/stack/{index.js → index.cjs} +2 -2
- package/build/stack/index.cjs.map +7 -0
- package/build/stack/{stack.js → stack.cjs} +6 -18
- package/build/stack/stack.cjs.map +7 -0
- package/build/stack/{types.js → types.cjs} +1 -1
- package/build/stack/types.cjs.map +7 -0
- package/build/types/css-modules.d.cjs +2 -0
- package/build/types/css-modules.d.cjs.map +7 -0
- package/build/types/{react.d.js → react.d.cjs} +1 -1
- package/build/utils/{types.js → types.cjs} +1 -1
- package/build/visually-hidden/index.cjs +31 -0
- package/build/visually-hidden/index.cjs.map +7 -0
- package/build/visually-hidden/types.cjs +19 -0
- package/build/visually-hidden/types.cjs.map +7 -0
- package/build/visually-hidden/visually-hidden.cjs +69 -0
- package/build/visually-hidden/visually-hidden.cjs.map +7 -0
- package/build-module/badge/badge.mjs +70 -0
- package/build-module/badge/badge.mjs.map +7 -0
- package/build-module/badge/index.mjs +6 -0
- package/build-module/badge/index.mjs.map +7 -0
- package/build-module/badge/types.mjs +1 -0
- package/build-module/box/{box.js → box.mjs} +7 -6
- package/build-module/box/box.mjs.map +7 -0
- package/build-module/box/index.mjs +6 -0
- package/build-module/box/types.mjs +1 -0
- package/build-module/button/button.mjs +366 -0
- package/build-module/button/button.mjs.map +7 -0
- package/build-module/button/icon.mjs +22 -0
- package/build-module/button/icon.mjs.map +7 -0
- package/build-module/button/index.mjs +14 -0
- package/build-module/button/index.mjs.map +7 -0
- package/build-module/button/types.mjs +1 -0
- package/build-module/form/primitives/field/control.mjs +13 -0
- package/build-module/form/primitives/field/control.mjs.map +7 -0
- package/build-module/form/primitives/field/description.mjs +57 -0
- package/build-module/form/primitives/field/description.mjs.map +7 -0
- package/build-module/form/primitives/field/details.mjs +64 -0
- package/build-module/form/primitives/field/details.mjs.map +7 -0
- package/build-module/form/primitives/field/index.mjs +16 -0
- package/build-module/form/primitives/field/index.mjs.map +7 -0
- package/build-module/form/primitives/field/item.mjs +11 -0
- package/build-module/form/primitives/field/item.mjs.map +7 -0
- package/build-module/form/primitives/field/label.mjs +63 -0
- package/build-module/form/primitives/field/label.mjs.map +7 -0
- package/build-module/form/primitives/field/root.mjs +44 -0
- package/build-module/form/primitives/field/root.mjs.map +7 -0
- package/build-module/form/primitives/field/types.mjs +1 -0
- package/build-module/form/primitives/fieldset/context.mjs +14 -0
- package/build-module/form/primitives/fieldset/context.mjs.map +7 -0
- package/build-module/form/primitives/fieldset/description.mjs +66 -0
- package/build-module/form/primitives/fieldset/description.mjs.map +7 -0
- package/build-module/form/primitives/fieldset/details.mjs +68 -0
- package/build-module/form/primitives/fieldset/details.mjs.map +7 -0
- package/build-module/form/primitives/fieldset/index.mjs +12 -0
- package/build-module/form/primitives/fieldset/index.mjs.map +7 -0
- package/build-module/form/primitives/fieldset/legend.mjs +59 -0
- package/build-module/form/primitives/fieldset/legend.mjs.map +7 -0
- package/build-module/form/primitives/fieldset/root.mjs +51 -0
- package/build-module/form/primitives/fieldset/root.mjs.map +7 -0
- package/build-module/form/primitives/fieldset/types.mjs +1 -0
- package/build-module/form/primitives/index.mjs +12 -0
- package/build-module/form/primitives/index.mjs.map +7 -0
- package/build-module/form/primitives/input/index.mjs +6 -0
- package/build-module/form/primitives/input/index.mjs.map +7 -0
- package/build-module/form/primitives/input/input.mjs +113 -0
- package/build-module/form/primitives/input/input.mjs.map +7 -0
- package/build-module/form/primitives/input/types.mjs +1 -0
- package/build-module/form/primitives/input/types.mjs.map +7 -0
- package/build-module/form/primitives/input-layout/context.mjs +22 -0
- package/build-module/form/primitives/input-layout/context.mjs.map +7 -0
- package/build-module/form/primitives/input-layout/index.mjs +10 -0
- package/build-module/form/primitives/input-layout/index.mjs.map +7 -0
- package/build-module/form/primitives/input-layout/input-layout.mjs +161 -0
- package/build-module/form/primitives/input-layout/input-layout.mjs.map +7 -0
- package/build-module/form/primitives/input-layout/slot.mjs +130 -0
- package/build-module/form/primitives/input-layout/slot.mjs.map +7 -0
- package/build-module/form/primitives/input-layout/types.mjs +1 -0
- package/build-module/form/primitives/input-layout/types.mjs.map +7 -0
- package/build-module/icon/icon.mjs +21 -0
- package/build-module/icon/icon.mjs.map +7 -0
- package/build-module/icon/index.mjs +6 -0
- package/build-module/icon/index.mjs.map +7 -0
- package/build-module/icon/types.mjs +1 -0
- package/build-module/icon/types.mjs.map +7 -0
- package/build-module/index.mjs +9 -0
- package/build-module/index.mjs.map +7 -0
- package/build-module/stack/index.mjs +6 -0
- package/build-module/stack/index.mjs.map +7 -0
- package/build-module/stack/{stack.js → stack.mjs} +6 -8
- package/build-module/stack/stack.mjs.map +7 -0
- package/build-module/stack/types.mjs +1 -0
- package/build-module/stack/types.mjs.map +7 -0
- package/build-module/types/css-modules.d.mjs +1 -0
- package/build-module/types/css-modules.d.mjs.map +7 -0
- package/build-module/types/{react.d.js → react.d.mjs} +1 -1
- package/build-module/utils/types.mjs +1 -0
- package/build-module/utils/types.mjs.map +7 -0
- package/build-module/visually-hidden/index.mjs +6 -0
- package/build-module/visually-hidden/index.mjs.map +7 -0
- package/build-module/visually-hidden/types.mjs +1 -0
- package/build-module/visually-hidden/types.mjs.map +7 -0
- package/build-module/visually-hidden/visually-hidden.mjs +44 -0
- package/build-module/visually-hidden/visually-hidden.mjs.map +7 -0
- package/build-types/badge/badge.d.ts +7 -0
- package/build-types/badge/badge.d.ts.map +1 -0
- package/build-types/badge/index.d.ts +2 -0
- package/build-types/badge/index.d.ts.map +1 -0
- package/build-types/badge/stories/index.story.d.ts +15 -0
- package/build-types/badge/stories/index.story.d.ts.map +1 -0
- package/build-types/badge/types.d.ts +14 -0
- package/build-types/badge/types.d.ts.map +1 -0
- package/build-types/box/box.d.ts +0 -3
- package/build-types/box/box.d.ts.map +1 -1
- package/build-types/box/stories/index.story.d.ts +1 -11
- package/build-types/box/stories/index.story.d.ts.map +1 -1
- package/build-types/box/types.d.ts +8 -15
- package/build-types/box/types.d.ts.map +1 -1
- package/build-types/button/button.d.ts +3 -0
- package/build-types/button/button.d.ts.map +1 -0
- package/build-types/button/icon.d.ts +10 -0
- package/build-types/button/icon.d.ts.map +1 -0
- package/build-types/button/index.d.ts +10 -0
- package/build-types/button/index.d.ts.map +1 -0
- package/build-types/button/stories/index.story.d.ts +23 -0
- package/build-types/button/stories/index.story.d.ts.map +1 -0
- package/build-types/button/test/button.test.d.ts +2 -0
- package/build-types/button/test/button.test.d.ts.map +1 -0
- package/build-types/button/test/icon.test.d.ts +2 -0
- package/build-types/button/test/icon.test.d.ts.map +1 -0
- package/build-types/button/types.d.ts +63 -0
- package/build-types/button/types.d.ts.map +1 -0
- package/build-types/form/primitives/field/control.d.ts +6 -0
- package/build-types/form/primitives/field/control.d.ts.map +1 -0
- package/build-types/form/primitives/field/description.d.ts +9 -0
- package/build-types/form/primitives/field/description.d.ts.map +1 -0
- package/build-types/form/primitives/field/details.d.ts +21 -0
- package/build-types/form/primitives/field/details.d.ts.map +1 -0
- package/build-types/form/primitives/field/index.d.ts +8 -0
- package/build-types/form/primitives/field/index.d.ts.map +1 -0
- package/build-types/form/primitives/field/item.d.ts +3 -0
- package/build-types/form/primitives/field/item.d.ts.map +1 -0
- package/build-types/form/primitives/field/label.d.ts +11 -0
- package/build-types/form/primitives/field/label.d.ts.map +1 -0
- package/build-types/form/primitives/field/root.d.ts +15 -0
- package/build-types/form/primitives/field/root.d.ts.map +1 -0
- package/build-types/form/primitives/field/stories/index.story.d.ts +39 -0
- package/build-types/form/primitives/field/stories/index.story.d.ts.map +1 -0
- package/build-types/form/primitives/field/test/index.test.d.ts +2 -0
- package/build-types/form/primitives/field/test/index.test.d.ts.map +1 -0
- package/build-types/form/primitives/field/types.d.ts +62 -0
- package/build-types/form/primitives/field/types.d.ts.map +1 -0
- package/build-types/form/primitives/fieldset/context.d.ts +8 -0
- package/build-types/form/primitives/fieldset/context.d.ts.map +1 -0
- package/build-types/form/primitives/fieldset/description.d.ts +9 -0
- package/build-types/form/primitives/fieldset/description.d.ts.map +1 -0
- package/build-types/form/primitives/fieldset/details.d.ts +21 -0
- package/build-types/form/primitives/fieldset/details.d.ts.map +1 -0
- package/build-types/form/primitives/fieldset/index.d.ts +6 -0
- package/build-types/form/primitives/fieldset/index.d.ts.map +1 -0
- package/build-types/form/primitives/fieldset/legend.d.ts +9 -0
- package/build-types/form/primitives/fieldset/legend.d.ts.map +1 -0
- package/build-types/form/primitives/fieldset/root.d.ts +15 -0
- package/build-types/form/primitives/fieldset/root.d.ts.map +1 -0
- package/build-types/form/primitives/fieldset/stories/index.story.d.ts +18 -0
- package/build-types/form/primitives/fieldset/stories/index.story.d.ts.map +1 -0
- package/build-types/form/primitives/fieldset/test/index.test.d.ts +2 -0
- package/build-types/form/primitives/fieldset/test/index.test.d.ts.map +1 -0
- package/build-types/form/primitives/fieldset/types.d.ts +32 -0
- package/build-types/form/primitives/fieldset/types.d.ts.map +1 -0
- package/build-types/form/primitives/index.d.ts +5 -0
- package/build-types/form/primitives/index.d.ts.map +1 -0
- package/build-types/form/primitives/input/index.d.ts +2 -0
- package/build-types/form/primitives/input/index.d.ts.map +1 -0
- package/build-types/form/primitives/input/input.d.ts +10 -0
- package/build-types/form/primitives/input/input.d.ts.map +1 -0
- package/build-types/form/primitives/input/stories/index.story.d.ts +13 -0
- package/build-types/form/primitives/input/stories/index.story.d.ts.map +1 -0
- package/build-types/form/primitives/input/test/index.test.d.ts +2 -0
- package/build-types/form/primitives/input/test/index.test.d.ts.map +1 -0
- package/build-types/form/primitives/input/types.d.ts +27 -0
- package/build-types/form/primitives/input/types.d.ts.map +1 -0
- package/build-types/form/primitives/input-layout/context.d.ts +17 -0
- package/build-types/form/primitives/input-layout/context.d.ts.map +1 -0
- package/build-types/form/primitives/input-layout/index.d.ts +4 -0
- package/build-types/form/primitives/input-layout/index.d.ts.map +1 -0
- package/build-types/form/primitives/input-layout/input-layout.d.ts +7 -0
- package/build-types/form/primitives/input-layout/input-layout.d.ts.map +1 -0
- package/build-types/form/primitives/input-layout/slot.d.ts +6 -0
- package/build-types/form/primitives/input-layout/slot.d.ts.map +1 -0
- package/build-types/form/primitives/input-layout/stories/index.story.d.ts +24 -0
- package/build-types/form/primitives/input-layout/stories/index.story.d.ts.map +1 -0
- package/build-types/form/primitives/input-layout/test/index.test.d.ts +2 -0
- package/build-types/form/primitives/input-layout/test/index.test.d.ts.map +1 -0
- package/build-types/form/primitives/input-layout/types.d.ts +41 -0
- package/build-types/form/primitives/input-layout/types.d.ts.map +1 -0
- package/build-types/icon/icon.d.ts +14 -0
- package/build-types/icon/icon.d.ts.map +1 -0
- package/build-types/icon/index.d.ts +2 -0
- package/build-types/icon/index.d.ts.map +1 -0
- package/build-types/icon/stories/index.story.d.ts +11 -0
- package/build-types/icon/stories/index.story.d.ts.map +1 -0
- package/build-types/icon/test/icon.test.d.ts +2 -0
- package/build-types/icon/test/icon.test.d.ts.map +1 -0
- package/build-types/icon/types.d.ts +15 -0
- package/build-types/icon/types.d.ts.map +1 -0
- package/build-types/index.d.ts +6 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/stack/index.d.ts +0 -3
- package/build-types/stack/index.d.ts.map +1 -1
- package/build-types/stack/stack.d.ts.map +1 -1
- package/build-types/stack/stories/index.story.d.ts +1 -11
- package/build-types/stack/stories/index.story.d.ts.map +1 -1
- package/build-types/stack/types.d.ts +2 -5
- package/build-types/stack/types.d.ts.map +1 -1
- package/build-types/test/index.test.d.ts +2 -0
- package/build-types/test/index.test.d.ts.map +1 -0
- package/build-types/visually-hidden/index.d.ts +2 -0
- package/build-types/visually-hidden/index.d.ts.map +1 -0
- package/build-types/visually-hidden/stories/index.story.d.ts +7 -0
- package/build-types/visually-hidden/stories/index.story.d.ts.map +1 -0
- package/build-types/visually-hidden/test/visually-hidden.test.d.ts +2 -0
- package/build-types/visually-hidden/test/visually-hidden.test.d.ts.map +1 -0
- package/build-types/visually-hidden/types.d.ts +8 -0
- package/build-types/visually-hidden/types.d.ts.map +1 -0
- package/build-types/visually-hidden/visually-hidden.d.ts +7 -0
- package/build-types/visually-hidden/visually-hidden.d.ts.map +1 -0
- package/package.json +26 -9
- package/src/badge/badge.tsx +88 -0
- package/src/badge/index.ts +1 -0
- package/src/badge/stories/choosing-intent.mdx +112 -0
- package/src/badge/stories/index.story.tsx +120 -0
- package/src/badge/types.ts +22 -0
- package/src/box/box.tsx +11 -23
- package/src/box/stories/index.story.tsx +3 -15
- package/src/box/types.ts +16 -59
- package/src/button/button.tsx +57 -0
- package/src/button/icon.tsx +24 -0
- package/src/button/index.ts +16 -0
- package/src/button/stories/index.story.tsx +192 -0
- package/src/button/style.module.css +232 -0
- package/src/button/test/button.test.tsx +89 -0
- package/src/button/test/icon.test.tsx +13 -0
- package/src/button/types.ts +72 -0
- package/src/form/primitives/field/control.tsx +9 -0
- package/src/form/primitives/field/description.tsx +18 -0
- package/src/form/primitives/field/details.tsx +36 -0
- package/src/form/primitives/field/index.ts +8 -0
- package/src/form/primitives/field/item.tsx +9 -0
- package/src/form/primitives/field/label.tsx +21 -0
- package/src/form/primitives/field/root.tsx +33 -0
- package/src/form/primitives/field/stories/index.story.tsx +132 -0
- package/src/form/primitives/field/test/index.test.tsx +36 -0
- package/src/form/primitives/field/types.ts +82 -0
- package/src/form/primitives/fieldset/context.tsx +13 -0
- package/src/form/primitives/fieldset/description.tsx +36 -0
- package/src/form/primitives/fieldset/details.tsx +46 -0
- package/src/form/primitives/fieldset/index.ts +6 -0
- package/src/form/primitives/fieldset/legend.tsx +17 -0
- package/src/form/primitives/fieldset/root.tsx +42 -0
- package/src/form/primitives/fieldset/stories/index.story.tsx +67 -0
- package/src/form/primitives/fieldset/style.module.css +12 -0
- package/src/form/primitives/fieldset/test/index.test.tsx +135 -0
- package/src/form/primitives/fieldset/types.ts +35 -0
- package/src/form/primitives/index.ts +4 -0
- package/src/form/primitives/input/index.ts +1 -0
- package/src/form/primitives/input/input.tsx +28 -0
- package/src/form/primitives/input/stories/index.story.tsx +40 -0
- package/src/form/primitives/input/style.module.css +34 -0
- package/src/form/primitives/input/test/index.test.tsx +13 -0
- package/src/form/primitives/input/types.ts +31 -0
- package/src/form/primitives/input-layout/context.tsx +36 -0
- package/src/form/primitives/input-layout/index.ts +6 -0
- package/src/form/primitives/input-layout/input-layout.tsx +49 -0
- package/src/form/primitives/input-layout/slot.tsx +39 -0
- package/src/form/primitives/input-layout/stories/index.story.tsx +67 -0
- package/src/form/primitives/input-layout/style.module.css +82 -0
- package/src/form/primitives/input-layout/test/index.test.tsx +23 -0
- package/src/form/primitives/input-layout/types.ts +44 -0
- package/src/icon/icon.tsx +30 -0
- package/src/icon/index.ts +1 -0
- package/src/icon/stories/index.story.tsx +47 -0
- package/src/icon/test/icon.test.tsx +13 -0
- package/src/icon/types.ts +14 -0
- package/src/index.ts +6 -0
- package/src/stack/index.ts +0 -3
- package/src/stack/stack.tsx +5 -18
- package/src/stack/stories/index.story.tsx +1 -14
- package/src/stack/test/stack.test.tsx +22 -12
- package/src/stack/types.ts +2 -6
- package/src/stories/introduction.mdx +6 -0
- package/src/test/index.test.ts +22 -0
- package/src/utils/css/field.module.css +27 -0
- package/src/utils/css/focus.module.css +31 -0
- package/src/utils/css/resets.module.css +13 -0
- package/src/visually-hidden/index.ts +1 -0
- package/src/visually-hidden/stories/index.story.tsx +22 -0
- package/src/visually-hidden/style.module.css +15 -0
- package/src/visually-hidden/test/visually-hidden.test.tsx +59 -0
- package/src/visually-hidden/types.ts +8 -0
- package/src/visually-hidden/visually-hidden.tsx +23 -0
- package/build/box/box.js.map +0 -7
- package/build/box/types.js.map +0 -7
- package/build/index.js.map +0 -7
- package/build/lock-unlock.js.map +0 -7
- package/build/stack/index.js.map +0 -7
- package/build/stack/stack.js.map +0 -7
- package/build/stack/types.js.map +0 -7
- package/build/types/css-modules.d.js +0 -2
- package/build/utils/element.js.map +0 -7
- package/build-module/box/box.js.map +0 -7
- package/build-module/box/index.js +0 -6
- package/build-module/box/types.js +0 -1
- package/build-module/index.js +0 -3
- package/build-module/index.js.map +0 -7
- package/build-module/lock-unlock.js +0 -11
- package/build-module/lock-unlock.js.map +0 -7
- package/build-module/stack/index.js +0 -6
- package/build-module/stack/index.js.map +0 -7
- package/build-module/stack/stack.js.map +0 -7
- package/build-module/stack/types.js +0 -1
- package/build-module/types/css-modules.d.js +0 -1
- package/build-module/utils/element.js +0 -20
- package/build-module/utils/element.js.map +0 -7
- package/build-module/utils/types.js +0 -1
- package/build-types/lock-unlock.d.ts +0 -2
- package/build-types/lock-unlock.d.ts.map +0 -1
- package/build-types/utils/element.d.ts +0 -25
- package/build-types/utils/element.d.ts.map +0 -1
- package/src/lock-unlock.ts +0 -10
- package/src/utils/element.ts +0 -51
- package/tsconfig.json +0 -13
- package/tsconfig.tsbuildinfo +0 -1
- /package/build/box/{index.js.map → index.cjs.map} +0 -0
- /package/build/types/{react.d.js.map → react.d.cjs.map} +0 -0
- /package/build/utils/{types.js.map → types.cjs.map} +0 -0
- /package/build-module/{box/types.js.map → badge/types.mjs.map} +0 -0
- /package/build-module/box/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/{stack/types.js.map → box/types.mjs.map} +0 -0
- /package/build-module/{types/css-modules.d.js.map → button/types.mjs.map} +0 -0
- /package/build-module/{utils/types.js.map → form/primitives/field/types.mjs.map} +0 -0
- /package/{build/types/css-modules.d.js.map → build-module/form/primitives/fieldset/types.mjs.map} +0 -0
- /package/build-module/types/{react.d.js.map → react.d.mjs.map} +0 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { Fragment, useState } from '@wordpress/element';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
+
import { cog } from '@wordpress/icons';
|
|
4
|
+
import { Button } from '../index';
|
|
5
|
+
|
|
6
|
+
const meta: Meta< typeof Button > = {
|
|
7
|
+
title: 'Design System/Components/Button',
|
|
8
|
+
component: Button,
|
|
9
|
+
argTypes: {
|
|
10
|
+
'aria-pressed': {
|
|
11
|
+
control: { type: 'boolean' },
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
type Story = StoryObj< typeof Button >;
|
|
18
|
+
|
|
19
|
+
export const Default: Story = {
|
|
20
|
+
args: {
|
|
21
|
+
children: 'Button',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Outline: Story = {
|
|
26
|
+
...Default,
|
|
27
|
+
args: {
|
|
28
|
+
...Default.args,
|
|
29
|
+
variant: 'outline',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const Minimal: Story = {
|
|
34
|
+
...Default,
|
|
35
|
+
args: {
|
|
36
|
+
...Default.args,
|
|
37
|
+
variant: 'minimal',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Compact: Story = {
|
|
42
|
+
...Default,
|
|
43
|
+
args: {
|
|
44
|
+
...Default.args,
|
|
45
|
+
size: 'compact',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const Small: Story = {
|
|
50
|
+
...Default,
|
|
51
|
+
args: {
|
|
52
|
+
...Default.args,
|
|
53
|
+
size: 'small',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const Neutral: Story = {
|
|
58
|
+
...Default,
|
|
59
|
+
args: {
|
|
60
|
+
...Default.args,
|
|
61
|
+
tone: 'neutral',
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const NeutralOutline: Story = {
|
|
66
|
+
...Default,
|
|
67
|
+
args: {
|
|
68
|
+
...Default.args,
|
|
69
|
+
tone: 'neutral',
|
|
70
|
+
variant: 'outline',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const Unstyled: Story = {
|
|
75
|
+
...Default,
|
|
76
|
+
args: {
|
|
77
|
+
...Default.args,
|
|
78
|
+
variant: 'unstyled',
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const AllTonesAndVariants: Story = {
|
|
83
|
+
...Default,
|
|
84
|
+
render: ( args ) => (
|
|
85
|
+
<div
|
|
86
|
+
style={ {
|
|
87
|
+
display: 'grid',
|
|
88
|
+
gridTemplateColumns: 'max-content repeat(2, min-content)',
|
|
89
|
+
color: 'var(--wpds-color-fg-content-neutral)',
|
|
90
|
+
} }
|
|
91
|
+
>
|
|
92
|
+
<div></div>
|
|
93
|
+
<div style={ { textAlign: 'center' } }>Resting</div>
|
|
94
|
+
<div style={ { textAlign: 'center' } }>Disabled</div>
|
|
95
|
+
{ ( [ 'brand', 'neutral' ] as const ).map( ( tone ) => (
|
|
96
|
+
<Fragment key={ tone }>
|
|
97
|
+
{ (
|
|
98
|
+
[ 'solid', 'outline', 'minimal', 'unstyled' ] as const
|
|
99
|
+
).map( ( variant ) => (
|
|
100
|
+
<Fragment key={ variant }>
|
|
101
|
+
<div
|
|
102
|
+
style={ {
|
|
103
|
+
paddingInlineEnd: '1rem',
|
|
104
|
+
display: 'flex',
|
|
105
|
+
alignItems: 'center',
|
|
106
|
+
} }
|
|
107
|
+
>
|
|
108
|
+
{ variant }, { tone }
|
|
109
|
+
</div>
|
|
110
|
+
<div
|
|
111
|
+
style={ {
|
|
112
|
+
padding: '0.5rem 1rem',
|
|
113
|
+
display: 'flex',
|
|
114
|
+
alignItems: 'center',
|
|
115
|
+
} }
|
|
116
|
+
>
|
|
117
|
+
<Button
|
|
118
|
+
{ ...args }
|
|
119
|
+
tone={ tone }
|
|
120
|
+
variant={ variant }
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
<div
|
|
124
|
+
style={ {
|
|
125
|
+
padding: '0.5rem 1rem',
|
|
126
|
+
display: 'flex',
|
|
127
|
+
alignItems: 'center',
|
|
128
|
+
} }
|
|
129
|
+
>
|
|
130
|
+
<Button
|
|
131
|
+
{ ...args }
|
|
132
|
+
tone={ tone }
|
|
133
|
+
variant={ variant }
|
|
134
|
+
disabled
|
|
135
|
+
/>
|
|
136
|
+
</div>
|
|
137
|
+
</Fragment>
|
|
138
|
+
) ) }
|
|
139
|
+
</Fragment>
|
|
140
|
+
) ) }
|
|
141
|
+
</div>
|
|
142
|
+
),
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export const WithIcon: Story = {
|
|
146
|
+
...Default,
|
|
147
|
+
args: {
|
|
148
|
+
...Default.args,
|
|
149
|
+
children: (
|
|
150
|
+
<>
|
|
151
|
+
<Button.Icon icon={ cog } />
|
|
152
|
+
Button
|
|
153
|
+
</>
|
|
154
|
+
),
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const Loading: Story = {
|
|
159
|
+
...Default,
|
|
160
|
+
args: {
|
|
161
|
+
...Default.args,
|
|
162
|
+
loading: true,
|
|
163
|
+
loadingAnnouncement: 'Saving data',
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The pressed state is only available for buttons with `tone="neutral"` and
|
|
169
|
+
* `variant="minimal"`. This represents a toggle button that is currently in an
|
|
170
|
+
* active/pressed state.
|
|
171
|
+
*/
|
|
172
|
+
export const Pressed: Story = {
|
|
173
|
+
...Default,
|
|
174
|
+
args: {
|
|
175
|
+
...Default.args,
|
|
176
|
+
tone: 'neutral',
|
|
177
|
+
variant: 'minimal',
|
|
178
|
+
},
|
|
179
|
+
render: ( args ) => {
|
|
180
|
+
const [ isPressed, setIsPressed ] = useState( true );
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<Button
|
|
184
|
+
{ ...args }
|
|
185
|
+
aria-pressed={ isPressed }
|
|
186
|
+
onClick={ () => setIsPressed( ! isPressed ) }
|
|
187
|
+
>
|
|
188
|
+
Button
|
|
189
|
+
</Button>
|
|
190
|
+
);
|
|
191
|
+
},
|
|
192
|
+
};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;
|
|
2
|
+
|
|
3
|
+
@layer wp-ui-components {
|
|
4
|
+
.button,
|
|
5
|
+
.is-unstyled {
|
|
6
|
+
appearance: none;
|
|
7
|
+
padding: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.button {
|
|
11
|
+
/* Internal variables */
|
|
12
|
+
--wp-ui-button-font-weight: 499;
|
|
13
|
+
|
|
14
|
+
--wp-ui-button-background-color: var(--wpds-color-bg-interactive-brand-strong);
|
|
15
|
+
--wp-ui-button-background-color-active: var(--wpds-color-bg-interactive-brand-strong-active);
|
|
16
|
+
--wp-ui-button-background-color-disabled: var(--wpds-color-bg-interactive-neutral-strong-disabled);
|
|
17
|
+
--wp-ui-button-foreground-color: var(--wpds-color-fg-interactive-brand-strong);
|
|
18
|
+
--wp-ui-button-foreground-color-active: var(--wpds-color-fg-interactive-brand-strong-active);
|
|
19
|
+
--wp-ui-button-foreground-color-disabled: var(--wpds-color-fg-interactive-neutral-strong-disabled);
|
|
20
|
+
--wp-ui-button-padding-inline: calc(3 * var(--wpds-dimension-base)); /* TODO: Create new interactive padding tokens */
|
|
21
|
+
--wp-ui-button-height: 40px;
|
|
22
|
+
--wp-ui-button-aspect-ratio: auto; /* Useful for overrides such as icon buttons */
|
|
23
|
+
--wp-ui-button-font-size: var(--wpds-font-size-md);
|
|
24
|
+
|
|
25
|
+
/* by default, borders have the same color as the background */
|
|
26
|
+
--wp-ui-button-border-color: var(--wp-ui-button-background-color);
|
|
27
|
+
--wp-ui-button-border-color-active: var(--wp-ui-button-background-color-active);
|
|
28
|
+
--wp-ui-button-border-color-disabled: var(--wp-ui-button-background-color-disabled);
|
|
29
|
+
|
|
30
|
+
/* Styles */
|
|
31
|
+
position: relative;
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
align-items: center;
|
|
35
|
+
gap: calc(2 * var(--wpds-dimension-base)); /* TODO: Consider new interactive/control gap tokens */
|
|
36
|
+
aspect-ratio: var(--wp-ui-button-aspect-ratio);
|
|
37
|
+
height: var(--wp-ui-button-height);
|
|
38
|
+
padding-inline: var(--wp-ui-button-padding-inline);
|
|
39
|
+
border-style: solid;
|
|
40
|
+
border-width: 1px;
|
|
41
|
+
border-color: var(--wp-ui-button-border-color);
|
|
42
|
+
border-radius: var(--wpds-border-radius-surface-sm);
|
|
43
|
+
background-color: var(--wp-ui-button-background-color);
|
|
44
|
+
background-clip: padding-box;
|
|
45
|
+
font-family: var(--wpds-font-family-body);
|
|
46
|
+
font-size: var(--wp-ui-button-font-size);
|
|
47
|
+
font-weight: var(--wp-ui-button-font-weight);
|
|
48
|
+
line-height: var(--wpds-font-line-height-sm);
|
|
49
|
+
text-decoration: none;
|
|
50
|
+
color: var(--wp-ui-button-foreground-color);
|
|
51
|
+
|
|
52
|
+
@media not ( prefers-reduced-motion ) {
|
|
53
|
+
transition: color 0.1s ease-out;
|
|
54
|
+
|
|
55
|
+
* {
|
|
56
|
+
transition: opacity 0.1s ease-out;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Use pointer cursor for buttons that are links */
|
|
61
|
+
&[href] {
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Make sure that links rendered as children of `Button` use button styles */
|
|
66
|
+
*[href] {
|
|
67
|
+
color: inherit;
|
|
68
|
+
text-decoration: inherit;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* States */
|
|
72
|
+
&:not([aria-disabled="true"]):is(:hover, :active, :focus) {
|
|
73
|
+
/* hover/active/focus states apply when the button is not disabled. A non
|
|
74
|
+
disabled, loading button will have hover/active/focus styles */
|
|
75
|
+
--wp-ui-button-background-color: var(--wp-ui-button-background-color-active);
|
|
76
|
+
--wp-ui-button-foreground-color: var(--wp-ui-button-foreground-color-active);
|
|
77
|
+
--wp-ui-button-border-color: var(--wp-ui-button-border-color-active);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&[aria-disabled="true"]:not(.is-loading) {
|
|
81
|
+
/* A loading button, even when disabled, won't "look" disabled */
|
|
82
|
+
--wp-ui-button-background-color: var(--wp-ui-button-background-color-disabled);
|
|
83
|
+
--wp-ui-button-foreground-color: var(--wp-ui-button-foreground-color-disabled);
|
|
84
|
+
--wp-ui-button-border-color: var(--wp-ui-button-border-color-disabled);
|
|
85
|
+
|
|
86
|
+
@media ( forced-colors: active ) {
|
|
87
|
+
border-color: GrayText;
|
|
88
|
+
color: GrayText;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Loading spinner — not animated and hidden unless in loading state */
|
|
93
|
+
&::before {
|
|
94
|
+
content: "";
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: 50%;
|
|
97
|
+
inset-inline-start: 50%;
|
|
98
|
+
transform: translate(-50%, -50%);
|
|
99
|
+
|
|
100
|
+
display: block;
|
|
101
|
+
box-sizing: border-box;
|
|
102
|
+
height: var(--wp-ui-button-font-size);
|
|
103
|
+
aspect-ratio: 1;
|
|
104
|
+
|
|
105
|
+
border: var(--wpds-border-width-interactive-focus) solid;
|
|
106
|
+
border-block-start-color: var(--wp-ui-button-foreground-color);
|
|
107
|
+
border-inline-end-color: var(--wp-ui-button-foreground-color);
|
|
108
|
+
border-block-end-color: transparent;
|
|
109
|
+
border-inline-start-color: transparent;
|
|
110
|
+
border-radius: 50%;
|
|
111
|
+
|
|
112
|
+
pointer-events: none;
|
|
113
|
+
opacity: 0;
|
|
114
|
+
|
|
115
|
+
@media not ( prefers-reduced-motion ) {
|
|
116
|
+
transition: opacity 0.1s ease-out;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.is-small {
|
|
122
|
+
--wp-ui-button-padding-inline: calc(2 * var(--wpds-dimension-base)); /* TODO: Create new interactive padding tokens */
|
|
123
|
+
--wp-ui-button-height: 24px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Variants (`tone` + `variant`) overrides compared to default styles */
|
|
127
|
+
|
|
128
|
+
/* All outline buttons have a border */
|
|
129
|
+
.is-brand {
|
|
130
|
+
/* no need to redefine variables for .is-brand.is-solid as it's the default variant */
|
|
131
|
+
|
|
132
|
+
/* Outline and minimal buttons use the same foreground color */
|
|
133
|
+
&.is-outline,
|
|
134
|
+
&.is-minimal {
|
|
135
|
+
--wp-ui-button-foreground-color: var(--wpds-color-fg-interactive-brand);
|
|
136
|
+
--wp-ui-button-foreground-color-active: var(--wpds-color-fg-interactive-brand-active);
|
|
137
|
+
--wp-ui-button-foreground-color-disabled: var(--wpds-color-fg-interactive-neutral-disabled);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
&.is-outline {
|
|
141
|
+
--wp-ui-button-background-color: var(--wpds-color-bg-interactive-brand-weak);
|
|
142
|
+
--wp-ui-button-background-color-active: var(--wpds-color-bg-interactive-brand-weak-active);
|
|
143
|
+
--wp-ui-button-background-color-disabled: var(--wpds-color-bg-interactive-neutral-weak-disabled);
|
|
144
|
+
--wp-ui-button-border-color: var(--wpds-color-stroke-interactive-brand);
|
|
145
|
+
--wp-ui-button-border-color-active: var(--wpds-color-stroke-interactive-brand-active);
|
|
146
|
+
--wp-ui-button-border-color-disabled: var(--wpds-color-stroke-interactive-neutral-disabled);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
&.is-minimal {
|
|
150
|
+
--wp-ui-button-background-color: var(--wpds-color-bg-interactive-brand-weak);
|
|
151
|
+
--wp-ui-button-background-color-active: var(--wpds-color-bg-interactive-brand-weak-active);
|
|
152
|
+
--wp-ui-button-background-color-disabled: var(--wpds-color-bg-interactive-neutral-weak-disabled);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.is-neutral {
|
|
157
|
+
&.is-solid {
|
|
158
|
+
--wp-ui-button-background-color: var(--wpds-color-bg-interactive-neutral-strong);
|
|
159
|
+
--wp-ui-button-background-color-active: var(--wpds-color-bg-interactive-neutral-strong-active);
|
|
160
|
+
--wp-ui-button-background-color-disabled: var(--wpds-color-bg-interactive-neutral-strong-disabled);
|
|
161
|
+
--wp-ui-button-foreground-color: var(--wpds-color-fg-interactive-neutral-strong);
|
|
162
|
+
--wp-ui-button-foreground-color-active: var(--wpds-color-fg-interactive-neutral-strong-active);
|
|
163
|
+
--wp-ui-button-foreground-color-disabled: var(--wpds-color-fg-interactive-neutral-strong-disabled);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* Outline and minimal buttons use the same foreground color */
|
|
167
|
+
&.is-outline,
|
|
168
|
+
&.is-minimal {
|
|
169
|
+
--wp-ui-button-foreground-color: var(--wpds-color-fg-interactive-neutral);
|
|
170
|
+
--wp-ui-button-foreground-color-active: var(--wpds-color-fg-interactive-neutral-active);
|
|
171
|
+
--wp-ui-button-foreground-color-disabled: var(--wpds-color-fg-interactive-neutral-disabled);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
&.is-outline {
|
|
175
|
+
--wp-ui-button-background-color: var(--wpds-color-bg-interactive-neutral-weak);
|
|
176
|
+
--wp-ui-button-background-color-active: var(--wpds-color-bg-interactive-neutral-weak-active);
|
|
177
|
+
--wp-ui-button-background-color-disabled: var(--wpds-color-bg-interactive-neutral-weak-disabled);
|
|
178
|
+
--wp-ui-button-border-color: var(--wpds-color-stroke-interactive-neutral);
|
|
179
|
+
--wp-ui-button-border-color-active: var(--wpds-color-stroke-interactive-neutral-active);
|
|
180
|
+
--wp-ui-button-border-color-disabled: var(--wpds-color-stroke-interactive-neutral-disabled);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
&.is-minimal {
|
|
184
|
+
--wp-ui-button-background-color: var(--wpds-color-bg-interactive-neutral-weak);
|
|
185
|
+
--wp-ui-button-background-color-active: var(--wpds-color-bg-interactive-neutral-weak-active);
|
|
186
|
+
--wp-ui-button-background-color-disabled: var(--wpds-color-bg-interactive-neutral-weak-disabled);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.is-unstyled {
|
|
191
|
+
border: none;
|
|
192
|
+
background: none;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.is-compact {
|
|
196
|
+
--wp-ui-button-height: 32px;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.is-loading {
|
|
200
|
+
color: transparent;
|
|
201
|
+
|
|
202
|
+
* {
|
|
203
|
+
opacity: 0;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&::before {
|
|
207
|
+
transition-delay: 0.05s;
|
|
208
|
+
opacity: 1;
|
|
209
|
+
|
|
210
|
+
@media not ( prefers-reduced-motion ) {
|
|
211
|
+
animation: loading-animation 1s linear infinite;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
[aria-pressed="true"].is-minimal.is-neutral {
|
|
217
|
+
--wp-ui-button-background-color: var(--wpds-color-bg-interactive-neutral-strong);
|
|
218
|
+
--wp-ui-button-background-color-active: var(--wpds-color-bg-interactive-neutral-strong);
|
|
219
|
+
--wp-ui-button-foreground-color: var(--wpds-color-fg-interactive-neutral-strong);
|
|
220
|
+
--wp-ui-button-foreground-color-active: var(--wpds-color-fg-interactive-neutral-strong);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@keyframes loading-animation {
|
|
225
|
+
0% {
|
|
226
|
+
transform: translate(-50%, -50%) rotate(0deg);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
100% {
|
|
230
|
+
transform: translate(-50%, -50%) rotate(360deg);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createRef } from '@wordpress/element';
|
|
2
|
+
import { screen, render } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { Button } from '../index';
|
|
5
|
+
|
|
6
|
+
describe( 'Button', () => {
|
|
7
|
+
it( 'renders a button element by default', () => {
|
|
8
|
+
render( <Button>Click me</Button> );
|
|
9
|
+
|
|
10
|
+
expect(
|
|
11
|
+
screen.getByRole( 'button', { name: 'Click me' } )
|
|
12
|
+
).toBeVisible();
|
|
13
|
+
} );
|
|
14
|
+
|
|
15
|
+
it( 'forwards ref', () => {
|
|
16
|
+
const ref = createRef< HTMLButtonElement >();
|
|
17
|
+
|
|
18
|
+
render( <Button ref={ ref }>Click me</Button> );
|
|
19
|
+
|
|
20
|
+
expect( ref.current ).toBeInstanceOf( HTMLButtonElement );
|
|
21
|
+
} );
|
|
22
|
+
|
|
23
|
+
it( 'is accessible when disabled by default', async () => {
|
|
24
|
+
const user = userEvent.setup();
|
|
25
|
+
|
|
26
|
+
const onClickMock = jest.fn();
|
|
27
|
+
render(
|
|
28
|
+
<Button disabled onClick={ onClickMock }>
|
|
29
|
+
Click me
|
|
30
|
+
</Button>
|
|
31
|
+
);
|
|
32
|
+
const button = screen.getByRole( 'button', { name: 'Click me' } );
|
|
33
|
+
|
|
34
|
+
expect( button ).toBeEnabled();
|
|
35
|
+
expect( button ).toHaveAttribute( 'aria-disabled', 'true' );
|
|
36
|
+
|
|
37
|
+
await user.keyboard( '{Tab}' );
|
|
38
|
+
expect( button ).toHaveFocus();
|
|
39
|
+
|
|
40
|
+
await user.keyboard( '{Enter}' );
|
|
41
|
+
expect( onClickMock ).not.toHaveBeenCalled();
|
|
42
|
+
} );
|
|
43
|
+
|
|
44
|
+
it( 'is disabled when loading', () => {
|
|
45
|
+
render( <Button loading>Click me</Button> );
|
|
46
|
+
|
|
47
|
+
const button = screen.getByRole( 'button', { name: 'Click me' } );
|
|
48
|
+
|
|
49
|
+
expect( button ).toBeEnabled();
|
|
50
|
+
expect( button ).toHaveAttribute( 'aria-disabled', 'true' );
|
|
51
|
+
} );
|
|
52
|
+
|
|
53
|
+
it( 'can be enabled explicitly when loading', () => {
|
|
54
|
+
render(
|
|
55
|
+
<Button loading disabled={ false }>
|
|
56
|
+
Click me
|
|
57
|
+
</Button>
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const button = screen.getByRole( 'button', { name: 'Click me' } );
|
|
61
|
+
|
|
62
|
+
expect( button ).toBeEnabled();
|
|
63
|
+
expect( button ).not.toHaveAttribute( 'aria-disabled', 'true' );
|
|
64
|
+
} );
|
|
65
|
+
|
|
66
|
+
it( 'supports custom render prop while retaining the default focusable when disabled behavior', () => {
|
|
67
|
+
render(
|
|
68
|
+
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
69
|
+
<Button render={ <a href="/" /> } nativeButton={ false } disabled>
|
|
70
|
+
Click me
|
|
71
|
+
</Button>
|
|
72
|
+
);
|
|
73
|
+
const button = screen.getByRole( 'button', { name: 'Click me' } );
|
|
74
|
+
|
|
75
|
+
expect( button ).toHaveAttribute( 'aria-disabled', 'true' );
|
|
76
|
+
} );
|
|
77
|
+
|
|
78
|
+
it( 'merges custom className with built-in classes', () => {
|
|
79
|
+
const customClass = 'my-button';
|
|
80
|
+
render(
|
|
81
|
+
<Button render={ <button /> } className={ customClass }>
|
|
82
|
+
Click me
|
|
83
|
+
</Button>
|
|
84
|
+
);
|
|
85
|
+
expect(
|
|
86
|
+
screen.getByRole( 'button', { name: 'Click me' } )
|
|
87
|
+
).toHaveClass( customClass );
|
|
88
|
+
} );
|
|
89
|
+
} );
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRef } from '@wordpress/element';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { ButtonIcon } from '../icon';
|
|
4
|
+
|
|
5
|
+
describe( 'Button.Icon', () => {
|
|
6
|
+
it( 'forwards ref', () => {
|
|
7
|
+
const ref = createRef< SVGSVGElement >();
|
|
8
|
+
|
|
9
|
+
render( <ButtonIcon ref={ ref } icon={ <svg /> } /> );
|
|
10
|
+
|
|
11
|
+
expect( ref.current ).toBeInstanceOf( SVGSVGElement );
|
|
12
|
+
} );
|
|
13
|
+
} );
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type ReactNode, type HTMLAttributes } from 'react';
|
|
2
|
+
import type { Button as _Button } from '@base-ui/react/button';
|
|
3
|
+
import type { ComponentProps } from '../utils/types';
|
|
4
|
+
|
|
5
|
+
type _ButtonProps = ComponentProps< typeof _Button >;
|
|
6
|
+
|
|
7
|
+
export interface ButtonProps
|
|
8
|
+
extends Omit< _ButtonProps, 'disabled' | 'aria-pressed' > {
|
|
9
|
+
/**
|
|
10
|
+
* The variant of the button. Variants describe the visual style treatment
|
|
11
|
+
* of the button.
|
|
12
|
+
*
|
|
13
|
+
* @default "solid"
|
|
14
|
+
*/
|
|
15
|
+
variant?: 'solid' | 'outline' | 'minimal' | 'unstyled';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The tone of the button, describing a semantic color intent:
|
|
19
|
+
*
|
|
20
|
+
* - `'brand': for the most prominent actions, using the brand colors.
|
|
21
|
+
* - `'neutral'` for less prominent actions.
|
|
22
|
+
*
|
|
23
|
+
* @default "brand"
|
|
24
|
+
*/
|
|
25
|
+
tone?: 'brand' | 'neutral';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The size of the button.
|
|
29
|
+
*
|
|
30
|
+
* - `'default'`: For normal text-label buttons, unless it is a toggle button.
|
|
31
|
+
* - `'compact'`: For toggle buttons, icon buttons, and buttons when used in context of either.
|
|
32
|
+
* - `'small'`: For icon buttons associated with more advanced or auxiliary features.
|
|
33
|
+
*
|
|
34
|
+
* @default "default"
|
|
35
|
+
*/
|
|
36
|
+
size?: 'default' | 'compact' | 'small';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Whether the button is disabled.
|
|
40
|
+
*/
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Whether the element should be focusable even when it is disabled.
|
|
45
|
+
*
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
focusableWhenDisabled?: _ButtonProps[ 'focusableWhenDisabled' ];
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Indicates the current "pressed" state of toggle buttons. This should only
|
|
52
|
+
* be used with neutral minimal buttons.
|
|
53
|
+
*/
|
|
54
|
+
'aria-pressed'?: HTMLAttributes< HTMLButtonElement >[ 'aria-pressed' ];
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The content of the button.
|
|
58
|
+
*/
|
|
59
|
+
children?: ReactNode;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Whether the button is in a loading state, such as when an action is being
|
|
63
|
+
* performed.
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
loading?: boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The text used for assistive technology to indicate the loading state.
|
|
70
|
+
*/
|
|
71
|
+
loadingAnnouncement?: string;
|
|
72
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Field as _Field } from '@base-ui/react/field';
|
|
2
|
+
import { forwardRef } from '@wordpress/element';
|
|
3
|
+
import type { FieldControlProps } from './types';
|
|
4
|
+
|
|
5
|
+
export const Control = forwardRef< HTMLInputElement, FieldControlProps >(
|
|
6
|
+
function Control( props, ref ) {
|
|
7
|
+
return <_Field.Control ref={ ref } { ...props } />;
|
|
8
|
+
}
|
|
9
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { Field as _Field } from '@base-ui/react/field';
|
|
3
|
+
import { forwardRef } from '@wordpress/element';
|
|
4
|
+
import fieldStyles from '../../../utils/css/field.module.css';
|
|
5
|
+
import type { FieldDescriptionProps } from './types';
|
|
6
|
+
|
|
7
|
+
export const Description = forwardRef<
|
|
8
|
+
HTMLParagraphElement,
|
|
9
|
+
FieldDescriptionProps
|
|
10
|
+
>( function Description( { className, ...restProps }, ref ) {
|
|
11
|
+
return (
|
|
12
|
+
<_Field.Description
|
|
13
|
+
ref={ ref }
|
|
14
|
+
className={ clsx( fieldStyles.description, className ) }
|
|
15
|
+
{ ...restProps }
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
} );
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { Field as _Field } from '@base-ui/react/field';
|
|
3
|
+
import { forwardRef } from '@wordpress/element';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import fieldStyles from '../../../utils/css/field.module.css';
|
|
6
|
+
import type { FieldDetailsProps } from './types';
|
|
7
|
+
import { VisuallyHidden } from '../../../visually-hidden';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A component for showing additional information about the field,
|
|
11
|
+
* styled similarly to a normal `Field.Description`.
|
|
12
|
+
* Unlike a normal description, it can include links and other semantic elements.
|
|
13
|
+
*
|
|
14
|
+
* Although this content is not associated with the field using direct semantics,
|
|
15
|
+
* it is made discoverable to screen reader users via a visually hidden description,
|
|
16
|
+
* alerting them to the presence of additional information below.
|
|
17
|
+
*
|
|
18
|
+
* If the content only includes plain text, use `Field.Description` instead,
|
|
19
|
+
* so the readout is not unnecessarily verbose for screen reader users.
|
|
20
|
+
*/
|
|
21
|
+
export const Details = forwardRef< HTMLDivElement, FieldDetailsProps >(
|
|
22
|
+
function Details( { className, ...restProps }, ref ) {
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<_Field.Description render={ <VisuallyHidden /> }>
|
|
26
|
+
{ __( 'More details follow the field.' ) }
|
|
27
|
+
</_Field.Description>
|
|
28
|
+
<div
|
|
29
|
+
ref={ ref }
|
|
30
|
+
className={ clsx( fieldStyles.description, className ) }
|
|
31
|
+
{ ...restProps }
|
|
32
|
+
></div>
|
|
33
|
+
</>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Root } from './root';
|
|
2
|
+
import { Item } from './item';
|
|
3
|
+
import { Label } from './label';
|
|
4
|
+
import { Description } from './description';
|
|
5
|
+
import { Details } from './details';
|
|
6
|
+
import { Control } from './control';
|
|
7
|
+
|
|
8
|
+
export { Root, Item, Label, Description, Details, Control };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Field as _Field } from '@base-ui/react/field';
|
|
2
|
+
import { forwardRef } from '@wordpress/element';
|
|
3
|
+
import type { FieldItemProps } from './types';
|
|
4
|
+
|
|
5
|
+
export const Item: React.ForwardRefExoticComponent<
|
|
6
|
+
FieldItemProps & React.RefAttributes< HTMLDivElement >
|
|
7
|
+
> = forwardRef( function Item( props, ref ) {
|
|
8
|
+
return <_Field.Item ref={ ref } { ...props } />;
|
|
9
|
+
} );
|