@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,35 @@
|
|
|
1
|
+
import type { Fieldset as _Fieldset } from '@base-ui/react';
|
|
2
|
+
import type { ComponentProps } from '../../../utils/types';
|
|
3
|
+
|
|
4
|
+
export type FieldsetRootProps = ComponentProps< typeof _Fieldset.Root > & {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type FieldsetLegendProps = ComponentProps< typeof _Fieldset.Legend > & {
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type FieldsetDescriptionProps = ComponentProps< 'p' > & {
|
|
13
|
+
/**
|
|
14
|
+
* The accessible description, associated using `aria-describedby`.
|
|
15
|
+
*
|
|
16
|
+
* For screen reader accessibility, this should only contain plain text,
|
|
17
|
+
* and no semantics such as links.
|
|
18
|
+
*/
|
|
19
|
+
children?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type FieldsetDetailsProps = ComponentProps< 'div' > & {
|
|
23
|
+
/**
|
|
24
|
+
* Additional information about the fieldset, which unlike a normal description,
|
|
25
|
+
* can include links and other semantic elements.
|
|
26
|
+
*
|
|
27
|
+
* Although this content is not associated with the fieldset using direct semantics,
|
|
28
|
+
* it is made discoverable to screen reader users via a visually hidden description,
|
|
29
|
+
* alerting them to the presence of additional information below.
|
|
30
|
+
*
|
|
31
|
+
* Do not use this component when the details content is only plain text,
|
|
32
|
+
* as it makes the readout unnecessarily verbose for screen reader users.
|
|
33
|
+
*/
|
|
34
|
+
children?: React.ReactNode;
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Input } from './input';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Input as _Input } from '@base-ui/react/input';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { forwardRef } from '@wordpress/element';
|
|
4
|
+
import focusStyles from '../../../utils/css/focus.module.css';
|
|
5
|
+
import styles from './style.module.css';
|
|
6
|
+
import type { InputProps } from './types';
|
|
7
|
+
import { InputLayout } from '../input-layout';
|
|
8
|
+
|
|
9
|
+
export const Input = forwardRef< HTMLInputElement, InputProps >( function Input(
|
|
10
|
+
{ className, size = 'default', prefix, suffix, style, ...restProps },
|
|
11
|
+
ref
|
|
12
|
+
) {
|
|
13
|
+
return (
|
|
14
|
+
<InputLayout
|
|
15
|
+
className={ clsx(
|
|
16
|
+
focusStyles[ 'outset-ring--focus-within' ],
|
|
17
|
+
className
|
|
18
|
+
) }
|
|
19
|
+
style={ style }
|
|
20
|
+
size={ size }
|
|
21
|
+
visuallyDisabled={ restProps.disabled }
|
|
22
|
+
prefix={ prefix }
|
|
23
|
+
suffix={ suffix }
|
|
24
|
+
>
|
|
25
|
+
<_Input ref={ ref } className={ styles.input } { ...restProps } />
|
|
26
|
+
</InputLayout>
|
|
27
|
+
);
|
|
28
|
+
} );
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Input, InputLayout } from '../../../..';
|
|
3
|
+
|
|
4
|
+
const meta: Meta< typeof Input > = {
|
|
5
|
+
title: 'Design System/Components/Form/Primitives/Input',
|
|
6
|
+
component: Input,
|
|
7
|
+
argTypes: {
|
|
8
|
+
defaultValue: { control: false },
|
|
9
|
+
onValueChange: { action: 'onValueChange' },
|
|
10
|
+
value: { control: false },
|
|
11
|
+
type: { control: 'text' },
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj< typeof Input >;
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
placeholder: 'Placeholder',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The `InputLayout.Slot` component can be used to add standard padding in
|
|
26
|
+
* the `prefix` or `suffix` slot.
|
|
27
|
+
*/
|
|
28
|
+
export const WithPrefix: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
placeholder: 'username',
|
|
31
|
+
prefix: <InputLayout.Slot>@</InputLayout.Slot>,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const Disabled: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
...Default.args,
|
|
38
|
+
disabled: true,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;
|
|
2
|
+
|
|
3
|
+
@layer wp-ui-components {
|
|
4
|
+
.input {
|
|
5
|
+
padding-block: var(--wp-ui-input-padding-block, 0);
|
|
6
|
+
padding-inline: var(--wp-ui-input-layout-padding-inline, 0);
|
|
7
|
+
width: 100%;
|
|
8
|
+
background: transparent;
|
|
9
|
+
border: none;
|
|
10
|
+
outline: none;
|
|
11
|
+
color: var(--wpds-color-fg-interactive-neutral);
|
|
12
|
+
font-family: inherit;
|
|
13
|
+
font-size: inherit;
|
|
14
|
+
line-height: inherit;
|
|
15
|
+
|
|
16
|
+
&::placeholder {
|
|
17
|
+
color: var(--wpds-color-fg-interactive-neutral-disabled);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&:disabled,
|
|
21
|
+
&[aria-disabled="true"] {
|
|
22
|
+
color: var(--wpds-color-fg-interactive-neutral-disabled);
|
|
23
|
+
|
|
24
|
+
@media ( forced-colors: active ) {
|
|
25
|
+
color: GrayText;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&[type="email"],
|
|
30
|
+
&[type="url"] {
|
|
31
|
+
direction: ltr; /* maintain LTR in RTL languages */
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import { createRef } from '@wordpress/element';
|
|
3
|
+
import { Input } from '../index';
|
|
4
|
+
|
|
5
|
+
describe( 'Input', () => {
|
|
6
|
+
it( 'forwards ref', () => {
|
|
7
|
+
const ref = createRef< HTMLInputElement >();
|
|
8
|
+
|
|
9
|
+
render( <Input ref={ ref } /> );
|
|
10
|
+
|
|
11
|
+
expect( ref.current ).toBeInstanceOf( HTMLInputElement );
|
|
12
|
+
} );
|
|
13
|
+
} );
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Input } from '@base-ui/react/input';
|
|
2
|
+
import type { InputLayoutProps } from '../input-layout/types';
|
|
3
|
+
import type { ComponentProps } from '../../../utils/types';
|
|
4
|
+
|
|
5
|
+
export type InputProps = Omit<
|
|
6
|
+
ComponentProps< typeof Input >,
|
|
7
|
+
'value' | 'defaultValue' | 'type' | 'disabled' | 'prefix' | 'size'
|
|
8
|
+
> &
|
|
9
|
+
Pick< InputLayoutProps, 'prefix' | 'suffix' > & {
|
|
10
|
+
/**
|
|
11
|
+
* Whether the field is disabled.
|
|
12
|
+
*/
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
} & {
|
|
15
|
+
/**
|
|
16
|
+
* The type of the input element.
|
|
17
|
+
*/
|
|
18
|
+
type?: Input.Props[ 'type' ];
|
|
19
|
+
/**
|
|
20
|
+
* The default value to use in uncontrolled mode.
|
|
21
|
+
*/
|
|
22
|
+
defaultValue?: Input.Props[ 'defaultValue' ];
|
|
23
|
+
/**
|
|
24
|
+
* The value to use in controlled mode.
|
|
25
|
+
*/
|
|
26
|
+
value?: Input.Props[ 'value' ];
|
|
27
|
+
/**
|
|
28
|
+
* The size of the field.
|
|
29
|
+
*/
|
|
30
|
+
size?: Exclude< InputLayoutProps[ 'size' ], 'small' >;
|
|
31
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Children, createContext, useContext } from '@wordpress/element';
|
|
2
|
+
import type { InputLayoutSlotType } from './types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Context for providing slot type information to child components.
|
|
6
|
+
*/
|
|
7
|
+
export const InputLayoutSlotTypeContext =
|
|
8
|
+
createContext< InputLayoutSlotType | null >( null );
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook to access the current slot context.
|
|
12
|
+
*/
|
|
13
|
+
export function useInputLayoutSlotContext() {
|
|
14
|
+
return useContext( InputLayoutSlotTypeContext );
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Wrapper component that provides slot type context for prefix and suffix slots.
|
|
19
|
+
*/
|
|
20
|
+
export function SlotContextProvider( {
|
|
21
|
+
type,
|
|
22
|
+
children,
|
|
23
|
+
}: {
|
|
24
|
+
type: InputLayoutSlotType;
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
} ) {
|
|
27
|
+
if ( Children.count( children ) === 0 ) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<InputLayoutSlotTypeContext.Provider value={ type }>
|
|
33
|
+
{ children }
|
|
34
|
+
</InputLayoutSlotTypeContext.Provider>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { forwardRef } from '@wordpress/element';
|
|
3
|
+
import resetStyles from '../../../utils/css/resets.module.css';
|
|
4
|
+
import styles from './style.module.css';
|
|
5
|
+
import type { InputLayoutProps } from './types';
|
|
6
|
+
import { SlotContextProvider } from './context';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A low-level component that handles the visual layout of an input-like field,
|
|
10
|
+
* including disabled states and standard prefix/suffix slots.
|
|
11
|
+
*/
|
|
12
|
+
export const InputLayout = forwardRef< HTMLDivElement, InputLayoutProps >(
|
|
13
|
+
function InputLayout(
|
|
14
|
+
{
|
|
15
|
+
className,
|
|
16
|
+
children,
|
|
17
|
+
visuallyDisabled,
|
|
18
|
+
size = 'default',
|
|
19
|
+
isBorderless,
|
|
20
|
+
prefix,
|
|
21
|
+
suffix,
|
|
22
|
+
...restProps
|
|
23
|
+
},
|
|
24
|
+
ref
|
|
25
|
+
) {
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
ref={ ref }
|
|
29
|
+
className={ clsx(
|
|
30
|
+
resetStyles[ 'box-sizing' ],
|
|
31
|
+
styles[ 'input-layout' ],
|
|
32
|
+
styles[ `is-size-${ size }` ],
|
|
33
|
+
visuallyDisabled && styles[ 'is-disabled' ],
|
|
34
|
+
isBorderless && styles[ 'is-borderless' ],
|
|
35
|
+
className
|
|
36
|
+
) }
|
|
37
|
+
{ ...restProps }
|
|
38
|
+
>
|
|
39
|
+
<SlotContextProvider type="prefix">
|
|
40
|
+
{ prefix }
|
|
41
|
+
</SlotContextProvider>
|
|
42
|
+
{ children }
|
|
43
|
+
<SlotContextProvider type="suffix">
|
|
44
|
+
{ suffix }
|
|
45
|
+
</SlotContextProvider>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { forwardRef } from '@wordpress/element';
|
|
3
|
+
import styles from './style.module.css';
|
|
4
|
+
import type { InputLayoutSlotProps } from './types';
|
|
5
|
+
import { useInputLayoutSlotContext } from './context';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A layout helper to add paddings in a prefix or suffix.
|
|
9
|
+
*/
|
|
10
|
+
export const InputLayoutSlot = forwardRef<
|
|
11
|
+
HTMLDivElement,
|
|
12
|
+
InputLayoutSlotProps
|
|
13
|
+
>( function InputLayoutSlot(
|
|
14
|
+
{ type: typeProp, padding = 'default', ...restProps },
|
|
15
|
+
ref
|
|
16
|
+
) {
|
|
17
|
+
const typeContext = useInputLayoutSlotContext();
|
|
18
|
+
const type = typeProp ?? typeContext;
|
|
19
|
+
|
|
20
|
+
if ( ! type ) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
'InputLayoutSlot requires a `type` prop or must be used within an InputLayout prefix/suffix slot.'
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
ref={ ref }
|
|
29
|
+
className={ clsx(
|
|
30
|
+
styles[ 'input-layout-slot' ],
|
|
31
|
+
styles[ `is-${ type }` ],
|
|
32
|
+
styles[ `is-padding-${ padding }` ]
|
|
33
|
+
) }
|
|
34
|
+
{ ...restProps }
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
} );
|
|
38
|
+
|
|
39
|
+
InputLayoutSlot.displayName = 'InputLayout.Slot';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { InputLayout } from '../../../..';
|
|
3
|
+
|
|
4
|
+
const meta: Meta< typeof InputLayout > = {
|
|
5
|
+
title: 'Design System/Components/Form/Primitives/InputLayout',
|
|
6
|
+
component: InputLayout,
|
|
7
|
+
subcomponents: {
|
|
8
|
+
Slot: InputLayout.Slot,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj< typeof InputLayout >;
|
|
14
|
+
|
|
15
|
+
export const Default: Story = {
|
|
16
|
+
args: {},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* By default, the `prefix` and `suffix` slots are rendered with no padding.
|
|
21
|
+
*/
|
|
22
|
+
export const WithPrefix: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
prefix: (
|
|
25
|
+
<div
|
|
26
|
+
style={ {
|
|
27
|
+
display: 'flex',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
justifyContent: 'center',
|
|
30
|
+
height: '100%',
|
|
31
|
+
aspectRatio: '1 / 1',
|
|
32
|
+
background: '#eee',
|
|
33
|
+
} }
|
|
34
|
+
>
|
|
35
|
+
$
|
|
36
|
+
</div>
|
|
37
|
+
),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The `InputLayout.Slot` component can be used to add standard padding in
|
|
43
|
+
* the `prefix` or `suffix` slot.
|
|
44
|
+
*
|
|
45
|
+
* The `padding="minimal"` setting will work best when the slot content is a button or icon.
|
|
46
|
+
*/
|
|
47
|
+
export const WithPaddedPrefix: Story = {
|
|
48
|
+
args: {
|
|
49
|
+
prefix: <InputLayout.Slot>https://</InputLayout.Slot>,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const Compact: Story = {
|
|
54
|
+
args: {
|
|
55
|
+
size: 'compact',
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The `small` size is intended only for rare cases like the trigger
|
|
61
|
+
* button of a low-profile `select` element.
|
|
62
|
+
*/
|
|
63
|
+
export const Small: Story = {
|
|
64
|
+
args: {
|
|
65
|
+
size: 'small',
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;
|
|
2
|
+
|
|
3
|
+
@layer wp-ui-components {
|
|
4
|
+
.input-layout {
|
|
5
|
+
/* TODO: Use padding tokens */
|
|
6
|
+
--wp-ui-input-layout-padding-inline: calc(var(--wpds-dimension-base) * 3);
|
|
7
|
+
|
|
8
|
+
display: flex;
|
|
9
|
+
height: 40px;
|
|
10
|
+
background-color: var(--wpds-color-bg-interactive-neutral-weak);
|
|
11
|
+
border-width: var(--wpds-border-width-surface-xs);
|
|
12
|
+
border-style: solid;
|
|
13
|
+
border-color: var(--wpds-color-stroke-interactive-neutral);
|
|
14
|
+
border-radius: var(--wpds-border-radius-surface-sm);
|
|
15
|
+
font-family: var(--wpds-font-family-body);
|
|
16
|
+
font-size: max(var(--wpds-font-size-md), 16px); /* avoid mobile zoom */
|
|
17
|
+
line-height: 1;
|
|
18
|
+
color: var(--wpds-color-fg-interactive-neutral);
|
|
19
|
+
|
|
20
|
+
@media (min-width: 600px) {
|
|
21
|
+
font-size: var(--wpds-font-size-md);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.is-size-compact {
|
|
25
|
+
/* TODO: Use padding tokens */
|
|
26
|
+
--wp-ui-input-layout-padding-inline: calc(var(--wpds-dimension-base) * 2);
|
|
27
|
+
height: 32px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.is-size-small {
|
|
31
|
+
/* TODO: Use padding tokens */
|
|
32
|
+
--wp-ui-input-layout-padding-inline: calc(var(--wpds-dimension-base) * 2);
|
|
33
|
+
height: 24px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&.is-disabled {
|
|
37
|
+
background-color: var(--wpds-color-bg-interactive-neutral-weak-disabled);
|
|
38
|
+
border-color: var(--wpds-color-stroke-interactive-neutral-disabled);
|
|
39
|
+
color: var(--wpds-color-fg-interactive-neutral-disabled);
|
|
40
|
+
|
|
41
|
+
@media (forced-colors: active) {
|
|
42
|
+
border-color: GrayText;
|
|
43
|
+
color: GrayText;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.is-borderless {
|
|
48
|
+
border-color: transparent;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Don't show focus ring when the focus is in the prefix or suffix slots */
|
|
52
|
+
&:has(.input-layout-slot:focus-within) {
|
|
53
|
+
outline: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&:hover:not(.is-disabled, .is-borderless) {
|
|
57
|
+
border-color: var(--wpds-color-stroke-interactive-neutral-active);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.input-layout-slot {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
|
|
65
|
+
&.is-padding-minimal {
|
|
66
|
+
--wp-ui-input-layout-prefix-padding-start:
|
|
67
|
+
calc(var(--wp-ui-input-layout-padding-inline) -
|
|
68
|
+
var(--wpds-dimension-base));
|
|
69
|
+
--wp-ui-input-layout-suffix-padding-end:
|
|
70
|
+
calc(var(--wp-ui-input-layout-padding-inline) -
|
|
71
|
+
var(--wpds-dimension-base));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&.is-prefix {
|
|
75
|
+
padding-inline-start: var(--wp-ui-input-layout-prefix-padding-start, var(--wp-ui-input-layout-padding-inline));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&.is-suffix {
|
|
79
|
+
padding-inline-end: var(--wp-ui-input-layout-suffix-padding-end, var(--wp-ui-input-layout-padding-inline));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import { createRef } from '@wordpress/element';
|
|
3
|
+
import { InputLayout } from '../index';
|
|
4
|
+
import { InputLayoutSlot } from '../slot';
|
|
5
|
+
|
|
6
|
+
describe( 'InputLayout', () => {
|
|
7
|
+
it( 'forwards ref', () => {
|
|
8
|
+
const layoutRef = createRef< HTMLDivElement >();
|
|
9
|
+
const slotRef = createRef< HTMLDivElement >();
|
|
10
|
+
|
|
11
|
+
render(
|
|
12
|
+
<InputLayout
|
|
13
|
+
ref={ layoutRef }
|
|
14
|
+
prefix={
|
|
15
|
+
<InputLayoutSlot ref={ slotRef }>Prefix</InputLayoutSlot>
|
|
16
|
+
}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
expect( layoutRef.current ).toBeInstanceOf( HTMLDivElement );
|
|
21
|
+
expect( slotRef.current ).toBeInstanceOf( HTMLDivElement );
|
|
22
|
+
} );
|
|
23
|
+
} );
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface InputLayoutProps
|
|
2
|
+
extends Omit< React.HTMLAttributes< HTMLDivElement >, 'prefix' > {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the field should be visually styled as disabled.
|
|
5
|
+
*/
|
|
6
|
+
visuallyDisabled?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The size of the field.
|
|
9
|
+
*
|
|
10
|
+
* @default 'default'
|
|
11
|
+
*/
|
|
12
|
+
size?: 'default' | 'compact' | 'small';
|
|
13
|
+
/**
|
|
14
|
+
* Whether the field should hide the border.
|
|
15
|
+
*/
|
|
16
|
+
isBorderless?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Element to render before the input.
|
|
19
|
+
*/
|
|
20
|
+
prefix?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Element to render after the input.
|
|
23
|
+
*/
|
|
24
|
+
suffix?: React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type InputLayoutSlotType = 'prefix' | 'suffix';
|
|
28
|
+
|
|
29
|
+
export interface InputLayoutSlotProps
|
|
30
|
+
extends Omit< React.HTMLAttributes< HTMLDivElement >, 'type' > {
|
|
31
|
+
/**
|
|
32
|
+
* The type of the slot.
|
|
33
|
+
*
|
|
34
|
+
* When not provided, the type will be automatically inferred from the
|
|
35
|
+
* `InputLayout` context if the slot is used within a `prefix` or `suffix`.
|
|
36
|
+
*/
|
|
37
|
+
type?: InputLayoutSlotType;
|
|
38
|
+
/**
|
|
39
|
+
* The padding of the slot.
|
|
40
|
+
*
|
|
41
|
+
* `minimal` will work best when the slot content is a button or icon.
|
|
42
|
+
*/
|
|
43
|
+
padding?: 'default' | 'minimal';
|
|
44
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { forwardRef } from '@wordpress/element';
|
|
2
|
+
import { SVG } from '@wordpress/primitives';
|
|
3
|
+
import type { IconProps } from './types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Renders an SVG icon with a 24px default size.
|
|
7
|
+
*
|
|
8
|
+
* If no `fill` colors are explicitly set on the icon itself, it will be rendered with a `currentColor` fill.
|
|
9
|
+
*
|
|
10
|
+
* ```jsx
|
|
11
|
+
* import { wordpress } from '@wordpress/icons';
|
|
12
|
+
*
|
|
13
|
+
* <Icon icon={ wordpress } />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export const Icon = forwardRef< SVGSVGElement, IconProps >( function Icon(
|
|
17
|
+
{ icon, size = 24, ...restProps },
|
|
18
|
+
ref
|
|
19
|
+
) {
|
|
20
|
+
return (
|
|
21
|
+
<SVG
|
|
22
|
+
ref={ ref }
|
|
23
|
+
fill="currentColor"
|
|
24
|
+
{ ...icon.props }
|
|
25
|
+
{ ...restProps }
|
|
26
|
+
width={ size }
|
|
27
|
+
height={ size }
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
} );
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Icon } from './icon';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { wordpress } from '@wordpress/icons';
|
|
3
|
+
import { Icon } from '../index';
|
|
4
|
+
|
|
5
|
+
const meta: Meta< typeof Icon > = {
|
|
6
|
+
title: 'Design System/Components/Icon',
|
|
7
|
+
component: Icon,
|
|
8
|
+
decorators: [
|
|
9
|
+
( Story ) => {
|
|
10
|
+
return (
|
|
11
|
+
<div
|
|
12
|
+
style={ {
|
|
13
|
+
color: 'var( --wpds-color-fg-content-neutral )',
|
|
14
|
+
} }
|
|
15
|
+
>
|
|
16
|
+
<Story />
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
export default meta;
|
|
23
|
+
|
|
24
|
+
type Story = StoryObj< typeof Icon >;
|
|
25
|
+
|
|
26
|
+
export const Default: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
icon: wordpress,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Explicit `fill` colors in the icon will be preserved.
|
|
34
|
+
*/
|
|
35
|
+
export const WithIntrinsicFillColor: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
icon: (
|
|
38
|
+
<svg
|
|
39
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
40
|
+
viewBox="0 0 24 24"
|
|
41
|
+
fill="blue"
|
|
42
|
+
>
|
|
43
|
+
<rect x="0" y="0" width="24" height="24" />
|
|
44
|
+
</svg>
|
|
45
|
+
),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import { createRef } from '@wordpress/element';
|
|
3
|
+
import { Icon } from '../index';
|
|
4
|
+
|
|
5
|
+
describe( 'Icon', () => {
|
|
6
|
+
it( 'forwards ref', () => {
|
|
7
|
+
const ref = createRef< SVGSVGElement >();
|
|
8
|
+
|
|
9
|
+
render( <Icon ref={ ref } icon={ <svg /> } /> );
|
|
10
|
+
|
|
11
|
+
expect( ref.current ).toBeInstanceOf( SVGSVGElement );
|
|
12
|
+
} );
|
|
13
|
+
} );
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type IconProps = React.ComponentProps< 'svg' > & {
|
|
2
|
+
/**
|
|
3
|
+
* The icon to render, which must be an svg element or an `SVG` from `@wordpress/primitives`.
|
|
4
|
+
*
|
|
5
|
+
* In most cases, you should use an icon from
|
|
6
|
+
* [the `@wordpress/icons` package](https://wordpress.github.io/gutenberg/?path=/story/icons-icon--library).
|
|
7
|
+
*/
|
|
8
|
+
icon: React.ReactElement< React.ComponentProps< 'svg' > >;
|
|
9
|
+
/**
|
|
10
|
+
* The size (width and height) of the icon.
|
|
11
|
+
* @default 24
|
|
12
|
+
*/
|
|
13
|
+
size?: number;
|
|
14
|
+
};
|
package/src/index.ts
CHANGED
package/src/stack/index.ts
CHANGED