@bettercms-ai/kit 0.1.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/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/_chunks-cjs/_visual-editing.js +5898 -0
- package/dist/_chunks-cjs/refractor.js +22 -0
- package/dist/_chunks-es/_visual-editing.mjs +5904 -0
- package/dist/_chunks-es/refractor.mjs +25 -0
- package/dist/_color.d.mts +119 -0
- package/dist/_color.d.ts +119 -0
- package/dist/_color.js +1412 -0
- package/dist/_color.mjs +1411 -0
- package/dist/_visual-editing.d.mts +1126 -0
- package/dist/_visual-editing.d.ts +1126 -0
- package/dist/_visual-editing.js +30 -0
- package/dist/_visual-editing.mjs +30 -0
- package/dist/index.d.mts +3140 -0
- package/dist/index.d.ts +3140 -0
- package/dist/index.js +2036 -0
- package/dist/index.mjs +2044 -0
- package/dist/theme.d.mts +1506 -0
- package/dist/theme.d.ts +1506 -0
- package/dist/theme.js +4126 -0
- package/dist/theme.mjs +4126 -0
- package/exports/_visual-editing.ts +31 -0
- package/exports/index.ts +1 -0
- package/exports/theme.ts +1 -0
- package/package.json +78 -0
- package/src/color/index.d.mts +119 -0
- package/src/color/index.mjs +1411 -0
- package/src/core/__workshop__/constants.ts +293 -0
- package/src/core/_compat.ts +264 -0
- package/src/core/components/autocomplete/__mocks__/apiStore.ts +49 -0
- package/src/core/components/autocomplete/__mocks__/countries.ts +245 -0
- package/src/core/components/autocomplete/__workshop__/async.tsx +156 -0
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +137 -0
- package/src/core/components/autocomplete/__workshop__/custom.tsx +89 -0
- package/src/core/components/autocomplete/__workshop__/example.tsx +79 -0
- package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +36 -0
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +294 -0
- package/src/core/components/autocomplete/__workshop__/index.ts +39 -0
- package/src/core/components/autocomplete/__workshop__/types.ts +4 -0
- package/src/core/components/autocomplete/autocomplete.styles.tsx +39 -0
- package/src/core/components/autocomplete/autocomplete.tsx +767 -0
- package/src/core/components/autocomplete/autocompleteOption.tsx +45 -0
- package/src/core/components/autocomplete/autocompleteReducer.ts +47 -0
- package/src/core/components/autocomplete/constants.ts +28 -0
- package/src/core/components/autocomplete/index.ts +2 -0
- package/src/core/components/autocomplete/types.ts +108 -0
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +62 -0
- package/src/core/components/breadcrumbs/__workshop__/index.ts +14 -0
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +18 -0
- package/src/core/components/breadcrumbs/breadcrumbs.test.tsx +51 -0
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +133 -0
- package/src/core/components/breadcrumbs/index.ts +1 -0
- package/src/core/components/dialog/__workshop__/activate.tsx +134 -0
- package/src/core/components/dialog/__workshop__/autoFocus.tsx +29 -0
- package/src/core/components/dialog/__workshop__/index.ts +19 -0
- package/src/core/components/dialog/__workshop__/layering.tsx +41 -0
- package/src/core/components/dialog/__workshop__/nested.tsx +72 -0
- package/src/core/components/dialog/__workshop__/onScroll.tsx +39 -0
- package/src/core/components/dialog/__workshop__/panes.tsx +82 -0
- package/src/core/components/dialog/__workshop__/position.tsx +30 -0
- package/src/core/components/dialog/__workshop__/props.tsx +75 -0
- package/src/core/components/dialog/__workshop__/provider.tsx +11 -0
- package/src/core/components/dialog/__workshop__/wrapped.tsx +76 -0
- package/src/core/components/dialog/dialog.tsx +430 -0
- package/src/core/components/dialog/dialogContext.ts +20 -0
- package/src/core/components/dialog/dialogProvider.tsx +35 -0
- package/src/core/components/dialog/index.ts +4 -0
- package/src/core/components/dialog/styles.ts +77 -0
- package/src/core/components/dialog/useDialog.ts +11 -0
- package/src/core/components/hotkeys/__workshop__/index.ts +14 -0
- package/src/core/components/hotkeys/__workshop__/plain.tsx +9 -0
- package/src/core/components/hotkeys/hotkeys.test.tsx +42 -0
- package/src/core/components/hotkeys/hotkeys.tsx +66 -0
- package/src/core/components/hotkeys/index.ts +1 -0
- package/src/core/components/index.ts +9 -0
- package/src/core/components/menu/__workshop__/asComponent.tsx +45 -0
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +51 -0
- package/src/core/components/menu/__workshop__/closableMenuButton.tsx +46 -0
- package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +134 -0
- package/src/core/components/menu/__workshop__/customMenuItem.tsx +45 -0
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +39 -0
- package/src/core/components/menu/__workshop__/disableFocusOnClose.tsx +40 -0
- package/src/core/components/menu/__workshop__/groups.tsx +156 -0
- package/src/core/components/menu/__workshop__/index.ts +89 -0
- package/src/core/components/menu/__workshop__/menuButton.tsx +80 -0
- package/src/core/components/menu/__workshop__/menuGroupRight.tsx +58 -0
- package/src/core/components/menu/__workshop__/nestedMenu.tsx +22 -0
- package/src/core/components/menu/__workshop__/onCloseMenuButton.tsx +41 -0
- package/src/core/components/menu/__workshop__/selectedItem.tsx +69 -0
- package/src/core/components/menu/__workshop__/shouldFocus.tsx +47 -0
- package/src/core/components/menu/__workshop__/tones.tsx +25 -0
- package/src/core/components/menu/__workshop__/withoutArrow.tsx +32 -0
- package/src/core/components/menu/helpers.ts +82 -0
- package/src/core/components/menu/index.ts +5 -0
- package/src/core/components/menu/menu.spacing.test.tsx +63 -0
- package/src/core/components/menu/menu.test.tsx +125 -0
- package/src/core/components/menu/menu.tsx +178 -0
- package/src/core/components/menu/menuButton.tsx +268 -0
- package/src/core/components/menu/menuContext.ts +18 -0
- package/src/core/components/menu/menuDivider.ts +23 -0
- package/src/core/components/menu/menuGroup.spacing.test.tsx +63 -0
- package/src/core/components/menu/menuGroup.tsx +233 -0
- package/src/core/components/menu/menuItem.spacing.test.tsx +59 -0
- package/src/core/components/menu/menuItem.tsx +197 -0
- package/src/core/components/menu/useMenu.ts +21 -0
- package/src/core/components/menu/useMenuController.ts +231 -0
- package/src/core/components/skeleton/__workshop__/delay.tsx +70 -0
- package/src/core/components/skeleton/__workshop__/index.ts +11 -0
- package/src/core/components/skeleton/__workshop__/skeleton.tsx +64 -0
- package/src/core/components/skeleton/index.ts +2 -0
- package/src/core/components/skeleton/skeleton.tsx +57 -0
- package/src/core/components/skeleton/styles.ts +50 -0
- package/src/core/components/skeleton/textSkeleton.tsx +122 -0
- package/src/core/components/tab/__workshop__/example.tsx +79 -0
- package/src/core/components/tab/__workshop__/index.ts +14 -0
- package/src/core/components/tab/index.ts +3 -0
- package/src/core/components/tab/tab.tsx +101 -0
- package/src/core/components/tab/tabList.test.tsx +48 -0
- package/src/core/components/tab/tabList.tsx +70 -0
- package/src/core/components/tab/tabPanel.tsx +39 -0
- package/src/core/components/toast/__workshop__/hook.tsx +71 -0
- package/src/core/components/toast/__workshop__/index.ts +19 -0
- package/src/core/components/toast/__workshop__/toast.tsx +26 -0
- package/src/core/components/toast/index.ts +4 -0
- package/src/core/components/toast/styles.ts +77 -0
- package/src/core/components/toast/toast.test.tsx +101 -0
- package/src/core/components/toast/toast.tsx +198 -0
- package/src/core/components/toast/toastContext.ts +7 -0
- package/src/core/components/toast/toastLayer.tsx +51 -0
- package/src/core/components/toast/toastProvider.tsx +113 -0
- package/src/core/components/toast/toastState.ts +6 -0
- package/src/core/components/toast/types.ts +26 -0
- package/src/core/components/toast/useToast.ts +25 -0
- package/src/core/components/tree/__workshop__/basic.perf.ts +19 -0
- package/src/core/components/tree/__workshop__/basic.tsx +105 -0
- package/src/core/components/tree/__workshop__/index.ts +21 -0
- package/src/core/components/tree/__workshop__/tabFromElement.tsx +84 -0
- package/src/core/components/tree/helpers.ts +105 -0
- package/src/core/components/tree/index.ts +4 -0
- package/src/core/components/tree/style.ts +105 -0
- package/src/core/components/tree/tree.test.tsx +55 -0
- package/src/core/components/tree/tree.tsx +240 -0
- package/src/core/components/tree/treeContext.ts +10 -0
- package/src/core/components/tree/treeGroup.tsx +28 -0
- package/src/core/components/tree/treeItem.test.tsx +65 -0
- package/src/core/components/tree/treeItem.tsx +224 -0
- package/src/core/components/tree/types.ts +25 -0
- package/src/core/components/tree/useTree.ts +17 -0
- package/src/core/constants.ts +79 -0
- package/src/core/helpers/animation.ts +27 -0
- package/src/core/helpers/element.ts +55 -0
- package/src/core/helpers/focus.ts +100 -0
- package/src/core/helpers/index.ts +4 -0
- package/src/core/helpers/scroll.ts +15 -0
- package/src/core/hooks/index.ts +12 -0
- package/src/core/hooks/useArrayProp.ts +17 -0
- package/src/core/hooks/useClickOutside.test.tsx +482 -0
- package/src/core/hooks/useClickOutside.ts +118 -0
- package/src/core/hooks/useClickOutsideEvent.test.tsx +115 -0
- package/src/core/hooks/useClickOutsideEvent.ts +73 -0
- package/src/core/hooks/useCustomValidity.ts +13 -0
- package/src/core/hooks/useDelayed.test.ts +88 -0
- package/src/core/hooks/useDelayedState.ts +36 -0
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +32 -0
- package/src/core/hooks/useElementRect/__workshop__/index.ts +14 -0
- package/src/core/hooks/useElementRect/index.ts +1 -0
- package/src/core/hooks/useElementRect/useElementRect.ts +13 -0
- package/src/core/hooks/useElementSize.ts +19 -0
- package/src/core/hooks/useForwardedRef.ts +19 -0
- package/src/core/hooks/useGlobalKeyDown.ts +24 -0
- package/src/core/hooks/useIsomorphicEffect.ts +7 -0
- package/src/core/hooks/useMatchMedia.ts +28 -0
- package/src/core/hooks/useMediaIndex/__workshop__/index.ts +14 -0
- package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +14 -0
- package/src/core/hooks/useMediaIndex/index.ts +1 -0
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +36 -0
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +102 -0
- package/src/core/hooks/useMounted.ts +15 -0
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +56 -0
- package/src/core/hooks/usePrefersDark.test.tsx +19 -0
- package/src/core/hooks/usePrefersDark.ts +16 -0
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +56 -0
- package/src/core/hooks/usePrefersReducedMotion.test.tsx +19 -0
- package/src/core/hooks/usePrefersReducedMotion.ts +16 -0
- package/src/core/index.ts +10 -0
- package/src/core/lib/createGlobalScopedContext.ts +36 -0
- package/src/core/lib/globalScope.ts +19 -0
- package/src/core/lib/isRecord.ts +3 -0
- package/src/core/middleware/origin.ts +47 -0
- package/src/core/observers/elementSizeObserver.ts +116 -0
- package/src/core/observers/index.ts +2 -0
- package/src/core/observers/resizeObserver.ts +9 -0
- package/src/core/primitives/_selectable/index.ts +1 -0
- package/src/core/primitives/_selectable/selectable.tsx +15 -0
- package/src/core/primitives/_selectable/style.ts +115 -0
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +14 -0
- package/src/core/primitives/avatar/__workshop__/index.ts +29 -0
- package/src/core/primitives/avatar/__workshop__/stack.tsx +25 -0
- package/src/core/primitives/avatar/__workshop__/withinButton.tsx +63 -0
- package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +70 -0
- package/src/core/primitives/avatar/avatar.tsx +200 -0
- package/src/core/primitives/avatar/avatarCounter.tsx +91 -0
- package/src/core/primitives/avatar/avatarStack.tsx +100 -0
- package/src/core/primitives/avatar/index.ts +4 -0
- package/src/core/primitives/avatar/styles.ts +167 -0
- package/src/core/primitives/avatar/types.ts +17 -0
- package/src/core/primitives/badge/__workshop__/index.ts +19 -0
- package/src/core/primitives/badge/__workshop__/props.tsx +30 -0
- package/src/core/primitives/badge/__workshop__/tones.tsx +21 -0
- package/src/core/primitives/badge/badge.test.tsx +16 -0
- package/src/core/primitives/badge/badge.tsx +70 -0
- package/src/core/primitives/badge/index.ts +1 -0
- package/src/core/primitives/badge/styles.ts +20 -0
- package/src/core/primitives/badge/types.ts +8 -0
- package/src/core/primitives/box/__workshop__/asComponent.tsx +31 -0
- package/src/core/primitives/box/__workshop__/index.ts +24 -0
- package/src/core/primitives/box/__workshop__/props.tsx +20 -0
- package/src/core/primitives/box/__workshop__/responsive.tsx +20 -0
- package/src/core/primitives/box/box.test.tsx +142 -0
- package/src/core/primitives/box/box.tsx +154 -0
- package/src/core/primitives/box/index.ts +1 -0
- package/src/core/primitives/button/__workshop__/custom.tsx +51 -0
- package/src/core/primitives/button/__workshop__/customIcons.tsx +30 -0
- package/src/core/primitives/button/__workshop__/disabled.tsx +74 -0
- package/src/core/primitives/button/__workshop__/index.ts +59 -0
- package/src/core/primitives/button/__workshop__/labelUploadButton.tsx +36 -0
- package/src/core/primitives/button/__workshop__/mixedChildren.tsx +12 -0
- package/src/core/primitives/button/__workshop__/props.tsx +55 -0
- package/src/core/primitives/button/__workshop__/stacked.tsx +58 -0
- package/src/core/primitives/button/__workshop__/styled1.tsx +17 -0
- package/src/core/primitives/button/__workshop__/styled2.tsx +19 -0
- package/src/core/primitives/button/__workshop__/uploadButton.tsx +28 -0
- package/src/core/primitives/button/button.test.tsx +82 -0
- package/src/core/primitives/button/button.tsx +210 -0
- package/src/core/primitives/button/index.ts +1 -0
- package/src/core/primitives/button/styles.ts +117 -0
- package/src/core/primitives/card/__workshop__/allTones.tsx +25 -0
- package/src/core/primitives/card/__workshop__/asButton.tsx +107 -0
- package/src/core/primitives/card/__workshop__/asComponent.tsx +27 -0
- package/src/core/primitives/card/__workshop__/checkered.tsx +26 -0
- package/src/core/primitives/card/__workshop__/index.ts +18 -0
- package/src/core/primitives/card/__workshop__/interactive.tsx +30 -0
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +80 -0
- package/src/core/primitives/card/__workshop__/props.tsx +53 -0
- package/src/core/primitives/card/__workshop__/selected.tsx +94 -0
- package/src/core/primitives/card/__workshop__/styled.tsx +14 -0
- package/src/core/primitives/card/card.tsx +128 -0
- package/src/core/primitives/card/index.ts +2 -0
- package/src/core/primitives/card/styles.ts +147 -0
- package/src/core/primitives/card/types.ts +11 -0
- package/src/core/primitives/checkbox/__workshop__/example.tsx +25 -0
- package/src/core/primitives/checkbox/__workshop__/index.ts +13 -0
- package/src/core/primitives/checkbox/__workshop__/props.tsx +33 -0
- package/src/core/primitives/checkbox/__workshop__/readOnly.tsx +16 -0
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +28 -0
- package/src/core/primitives/checkbox/checkbox.tsx +73 -0
- package/src/core/primitives/checkbox/index.ts +1 -0
- package/src/core/primitives/checkbox/styles.ts +128 -0
- package/src/core/primitives/code/__workshop__/index.ts +19 -0
- package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +48 -0
- package/src/core/primitives/code/__workshop__/props.tsx +21 -0
- package/src/core/primitives/code/code.tsx +55 -0
- package/src/core/primitives/code/index.ts +1 -0
- package/src/core/primitives/code/refractor.tsx +20 -0
- package/src/core/primitives/code/styles.ts +77 -0
- package/src/core/primitives/container/__workshop__/example.tsx +20 -0
- package/src/core/primitives/container/__workshop__/index.ts +8 -0
- package/src/core/primitives/container/container.tsx +54 -0
- package/src/core/primitives/container/index.ts +2 -0
- package/src/core/primitives/container/styles.ts +23 -0
- package/src/core/primitives/container/types.ts +6 -0
- package/src/core/primitives/flex/__workshop__/example.tsx +34 -0
- package/src/core/primitives/flex/__workshop__/gap.tsx +25 -0
- package/src/core/primitives/flex/__workshop__/index.ts +11 -0
- package/src/core/primitives/flex/flex.tsx +64 -0
- package/src/core/primitives/flex/index.ts +1 -0
- package/src/core/primitives/grid/__workshop__/index.ts +10 -0
- package/src/core/primitives/grid/__workshop__/responsive.tsx +54 -0
- package/src/core/primitives/grid/grid.test.tsx +80 -0
- package/src/core/primitives/grid/grid.tsx +74 -0
- package/src/core/primitives/grid/index.ts +1 -0
- package/src/core/primitives/heading/__workshop__/index.ts +19 -0
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +54 -0
- package/src/core/primitives/heading/__workshop__/plain.tsx +32 -0
- package/src/core/primitives/heading/heading.tsx +88 -0
- package/src/core/primitives/heading/index.ts +1 -0
- package/src/core/primitives/heading/styles.ts +64 -0
- package/src/core/primitives/heading/types.ts +7 -0
- package/src/core/primitives/index.ts +27 -0
- package/src/core/primitives/inline/__workshop__/index.ts +8 -0
- package/src/core/primitives/inline/__workshop__/plain.tsx +27 -0
- package/src/core/primitives/inline/index.ts +1 -0
- package/src/core/primitives/inline/inline.test.tsx +51 -0
- package/src/core/primitives/inline/inline.tsx +63 -0
- package/src/core/primitives/inline/styles.ts +32 -0
- package/src/core/primitives/inline/types.ts +6 -0
- package/src/core/primitives/kbd/__workshop__/index.ts +8 -0
- package/src/core/primitives/kbd/__workshop__/plain.tsx +9 -0
- package/src/core/primitives/kbd/index.ts +1 -0
- package/src/core/primitives/kbd/kbd.tsx +69 -0
- package/src/core/primitives/label/__workshop__/index.ts +19 -0
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +48 -0
- package/src/core/primitives/label/__workshop__/plain.tsx +24 -0
- package/src/core/primitives/label/index.ts +1 -0
- package/src/core/primitives/label/label.tsx +87 -0
- package/src/core/primitives/label/styles.ts +45 -0
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +77 -0
- package/src/core/primitives/popover/__workshop__/MarginsStory.tsx +31 -0
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +32 -0
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +11 -0
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +71 -0
- package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +71 -0
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +89 -0
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +97 -0
- package/src/core/primitives/popover/__workshop__/index.ts +49 -0
- package/src/core/primitives/popover/constants.ts +22 -0
- package/src/core/primitives/popover/floating-ui/size.ts +99 -0
- package/src/core/primitives/popover/helpers.ts +31 -0
- package/src/core/primitives/popover/index.ts +2 -0
- package/src/core/primitives/popover/popover.tsx +511 -0
- package/src/core/primitives/popover/popoverCard.tsx +166 -0
- package/src/core/primitives/popover/types.ts +7 -0
- package/src/core/primitives/radio/__workshop__/example.tsx +63 -0
- package/src/core/primitives/radio/__workshop__/index.ts +11 -0
- package/src/core/primitives/radio/__workshop__/plain.tsx +28 -0
- package/src/core/primitives/radio/index.ts +1 -0
- package/src/core/primitives/radio/radio.tsx +51 -0
- package/src/core/primitives/radio/styles.ts +117 -0
- package/src/core/primitives/select/__workshop__/index.ts +11 -0
- package/src/core/primitives/select/__workshop__/plain.tsx +27 -0
- package/src/core/primitives/select/__workshop__/readOnly.tsx +23 -0
- package/src/core/primitives/select/index.ts +1 -0
- package/src/core/primitives/select/select.test.tsx +52 -0
- package/src/core/primitives/select/select.tsx +94 -0
- package/src/core/primitives/select/styles.ts +166 -0
- package/src/core/primitives/spinner/__workshop__/Props.tsx +15 -0
- package/src/core/primitives/spinner/__workshop__/index.ts +14 -0
- package/src/core/primitives/spinner/index.ts +1 -0
- package/src/core/primitives/spinner/spinner.tsx +46 -0
- package/src/core/primitives/stack/__workshop__/index.ts +14 -0
- package/src/core/primitives/stack/__workshop__/plain.tsx +32 -0
- package/src/core/primitives/stack/index.ts +1 -0
- package/src/core/primitives/stack/stack.test.tsx +57 -0
- package/src/core/primitives/stack/stack.tsx +57 -0
- package/src/core/primitives/stack/styles.ts +32 -0
- package/src/core/primitives/switch/__workshop__/example.tsx +23 -0
- package/src/core/primitives/switch/__workshop__/index.ts +11 -0
- package/src/core/primitives/switch/__workshop__/props.tsx +21 -0
- package/src/core/primitives/switch/index.ts +1 -0
- package/src/core/primitives/switch/styles.ts +173 -0
- package/src/core/primitives/switch/switch.tsx +68 -0
- package/src/core/primitives/text/__workshop__/colored.tsx +30 -0
- package/src/core/primitives/text/__workshop__/example.tsx +39 -0
- package/src/core/primitives/text/__workshop__/index.ts +24 -0
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +48 -0
- package/src/core/primitives/text/index.ts +1 -0
- package/src/core/primitives/text/styles.ts +74 -0
- package/src/core/primitives/text/text.tsx +89 -0
- package/src/core/primitives/textArea/__workshop__/index.ts +14 -0
- package/src/core/primitives/textArea/__workshop__/plain.tsx +50 -0
- package/src/core/primitives/textArea/index.ts +1 -0
- package/src/core/primitives/textArea/textArea.tsx +120 -0
- package/src/core/primitives/textInput/__workshop__/clearButton.tsx +30 -0
- package/src/core/primitives/textInput/__workshop__/customValidity.tsx +17 -0
- package/src/core/primitives/textInput/__workshop__/index.ts +44 -0
- package/src/core/primitives/textInput/__workshop__/plain.tsx +98 -0
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +9 -0
- package/src/core/primitives/textInput/__workshop__/states.tsx +53 -0
- package/src/core/primitives/textInput/__workshop__/tones.tsx +277 -0
- package/src/core/primitives/textInput/__workshop__/typed.tsx +23 -0
- package/src/core/primitives/textInput/index.ts +1 -0
- package/src/core/primitives/textInput/textInput.test.tsx +48 -0
- package/src/core/primitives/textInput/textInput.tsx +395 -0
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +102 -0
- package/src/core/primitives/tooltip/__workshop__/index.ts +29 -0
- package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +74 -0
- package/src/core/primitives/tooltip/__workshop__/props.tsx +107 -0
- package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +86 -0
- package/src/core/primitives/tooltip/constants.ts +23 -0
- package/src/core/primitives/tooltip/index.ts +2 -0
- package/src/core/primitives/tooltip/tooltip.test.tsx +452 -0
- package/src/core/primitives/tooltip/tooltip.tsx +495 -0
- package/src/core/primitives/tooltip/tooltipCard.tsx +109 -0
- package/src/core/primitives/tooltip/tooltipDelayGroup/index.ts +4 -0
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupContext.tsx +11 -0
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +57 -0
- package/src/core/primitives/tooltip/tooltipDelayGroup/types.ts +10 -0
- package/src/core/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts +13 -0
- package/src/core/primitives/types.ts +179 -0
- package/src/core/styles/border/borderStyle.ts +56 -0
- package/src/core/styles/border/index.ts +2 -0
- package/src/core/styles/border/types.ts +10 -0
- package/src/core/styles/box/boxStyle.ts +69 -0
- package/src/core/styles/box/index.ts +2 -0
- package/src/core/styles/box/types.ts +11 -0
- package/src/core/styles/card/_cardColorStyle.ts +108 -0
- package/src/core/styles/card/index.ts +1 -0
- package/src/core/styles/flex/flexItemStyle.ts +27 -0
- package/src/core/styles/flex/flexStyle.ts +70 -0
- package/src/core/styles/flex/index.ts +3 -0
- package/src/core/styles/flex/types.ts +25 -0
- package/src/core/styles/focusRing/index.ts +25 -0
- package/src/core/styles/font/codeFontStyle.ts +13 -0
- package/src/core/styles/font/headingFontStyle.ts +13 -0
- package/src/core/styles/font/index.ts +6 -0
- package/src/core/styles/font/labelFontStyle.ts +13 -0
- package/src/core/styles/font/responsiveFont.ts +103 -0
- package/src/core/styles/font/textAlignStyle.ts +19 -0
- package/src/core/styles/font/textFontStyle.ts +13 -0
- package/src/core/styles/font/types.ts +35 -0
- package/src/core/styles/grid/gridItemStyle.ts +82 -0
- package/src/core/styles/grid/gridStyle.ts +108 -0
- package/src/core/styles/grid/index.ts +3 -0
- package/src/core/styles/grid/types.ts +37 -0
- package/src/core/styles/helpers.ts +72 -0
- package/src/core/styles/index.ts +5 -0
- package/src/core/styles/input/index.ts +2 -0
- package/src/core/styles/input/responsiveInputPaddingStyle.ts +78 -0
- package/src/core/styles/input/textInputStyle.ts +263 -0
- package/src/core/styles/internal.ts +12 -0
- package/src/core/styles/margin/index.ts +2 -0
- package/src/core/styles/margin/marginStyle.ts +21 -0
- package/src/core/styles/margin/marginsStyle.test.ts +33 -0
- package/src/core/styles/margin/types.ts +9 -0
- package/src/core/styles/padding/index.ts +2 -0
- package/src/core/styles/padding/paddingStyle.test.ts +33 -0
- package/src/core/styles/padding/paddingStyle.ts +21 -0
- package/src/core/styles/padding/types.ts +12 -0
- package/src/core/styles/radius/index.ts +2 -0
- package/src/core/styles/radius/radiusStyle.ts +23 -0
- package/src/core/styles/radius/types.ts +8 -0
- package/src/core/styles/shadow/index.ts +2 -0
- package/src/core/styles/shadow/shadowStyle.ts +29 -0
- package/src/core/styles/shadow/types.ts +6 -0
- package/src/core/styles/types.ts +8 -0
- package/src/core/theme/__workshop__/build/Root.tsx +367 -0
- package/src/core/theme/__workshop__/build/helpers.ts +46 -0
- package/src/core/theme/__workshop__/build/story.tsx +465 -0
- package/src/core/theme/__workshop__/canvas.tsx +352 -0
- package/src/core/theme/__workshop__/color.tsx +62 -0
- package/src/core/theme/__workshop__/debug/story.tsx +408 -0
- package/src/core/theme/__workshop__/index.ts +39 -0
- package/src/core/theme/__workshop__/layer.tsx +78 -0
- package/src/core/theme/__workshop__/nestedProvider.tsx +15 -0
- package/src/core/theme/index.ts +5 -0
- package/src/core/theme/theme.test.tsx +73 -0
- package/src/core/theme/themeColorProvider.tsx +29 -0
- package/src/core/theme/themeContext.ts +10 -0
- package/src/core/theme/themeProvider.tsx +62 -0
- package/src/core/theme/types.ts +12 -0
- package/src/core/theme/useRootTheme.ts +17 -0
- package/src/core/theme/useTheme.ts +16 -0
- package/src/core/types/avatar.ts +14 -0
- package/src/core/types/badge.ts +12 -0
- package/src/core/types/box.ts +19 -0
- package/src/core/types/button.ts +21 -0
- package/src/core/types/card.ts +6 -0
- package/src/core/types/component.ts +32 -0
- package/src/core/types/dialog.ts +4 -0
- package/src/core/types/flex.ts +30 -0
- package/src/core/types/grid.ts +14 -0
- package/src/core/types/gridItem.ts +29 -0
- package/src/core/types/index.ts +15 -0
- package/src/core/types/placement.ts +18 -0
- package/src/core/types/popover.ts +4 -0
- package/src/core/types/radius.ts +4 -0
- package/src/core/types/selectable.ts +6 -0
- package/src/core/types/text.ts +4 -0
- package/src/core/utils/arrow/arrow.tsx +123 -0
- package/src/core/utils/arrow/cmds.ts +91 -0
- package/src/core/utils/arrow/index.ts +1 -0
- package/src/core/utils/boundaryElement/__workshop__/index.ts +14 -0
- package/src/core/utils/boundaryElement/__workshop__/plain.tsx +19 -0
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +100 -0
- package/src/core/utils/boundaryElement/boundaryElementContext.ts +7 -0
- package/src/core/utils/boundaryElement/boundaryElementProvider.tsx +24 -0
- package/src/core/utils/boundaryElement/index.ts +3 -0
- package/src/core/utils/boundaryElement/types.ts +7 -0
- package/src/core/utils/boundaryElement/useBoundaryElement.ts +26 -0
- package/src/core/utils/conditionalWrapper/conditionalWrapper.tsx +21 -0
- package/src/core/utils/conditionalWrapper/index.ts +1 -0
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +30 -0
- package/src/core/utils/elementQuery/__workshop__/index.ts +14 -0
- package/src/core/utils/elementQuery/elementQuery.tsx +53 -0
- package/src/core/utils/elementQuery/helpers.ts +27 -0
- package/src/core/utils/elementQuery/index.ts +1 -0
- package/src/core/utils/errorBoundary.tsx +48 -0
- package/src/core/utils/getElementRef.ts +26 -0
- package/src/core/utils/index.ts +9 -0
- package/src/core/utils/layer/__workshop__/_debug.tsx +17 -0
- package/src/core/utils/layer/__workshop__/index.ts +24 -0
- package/src/core/utils/layer/__workshop__/multipleRoots.tsx +49 -0
- package/src/core/utils/layer/__workshop__/nested.tsx +98 -0
- package/src/core/utils/layer/__workshop__/responsiveZOffset.tsx +13 -0
- package/src/core/utils/layer/getLayerContext.test.ts +30 -0
- package/src/core/utils/layer/getLayerContext.ts +21 -0
- package/src/core/utils/layer/index.ts +4 -0
- package/src/core/utils/layer/layer.test.tsx +108 -0
- package/src/core/utils/layer/layer.tsx +98 -0
- package/src/core/utils/layer/layerContext.ts +7 -0
- package/src/core/utils/layer/layerProvider.tsx +111 -0
- package/src/core/utils/layer/types.ts +9 -0
- package/src/core/utils/layer/useLayer.ts +26 -0
- package/src/core/utils/portal/__workshop__/index.ts +14 -0
- package/src/core/utils/portal/__workshop__/named.tsx +63 -0
- package/src/core/utils/portal/index.ts +4 -0
- package/src/core/utils/portal/portal.test.tsx +103 -0
- package/src/core/utils/portal/portal.ts +32 -0
- package/src/core/utils/portal/portalContext.ts +31 -0
- package/src/core/utils/portal/portalProvider.tsx +47 -0
- package/src/core/utils/portal/types.ts +9 -0
- package/src/core/utils/portal/usePortal.ts +25 -0
- package/src/core/utils/spanWithTextOverflow.tsx +10 -0
- package/src/core/utils/srOnly/index.ts +1 -0
- package/src/core/utils/srOnly/srOnly.tsx +36 -0
- package/src/core/utils/virtualList/__workshop__/changingProps.tsx +36 -0
- package/src/core/utils/virtualList/__workshop__/elementScroll.tsx +24 -0
- package/src/core/utils/virtualList/__workshop__/index.ts +29 -0
- package/src/core/utils/virtualList/__workshop__/infiniteList.tsx +48 -0
- package/src/core/utils/virtualList/__workshop__/windowScrolll.tsx +22 -0
- package/src/core/utils/virtualList/index.ts +1 -0
- package/src/core/utils/virtualList/virtualList.tsx +200 -0
- package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +76 -0
- package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +54 -0
- package/src/theme/build/_deprecated/color/button/createButtonModes.ts +22 -0
- package/src/theme/build/_deprecated/color/button/createButtonTones.ts +55 -0
- package/src/theme/build/_deprecated/color/card/createCardStates.ts +60 -0
- package/src/theme/build/_deprecated/color/color.test.ts +63 -0
- package/src/theme/build/_deprecated/color/defaults.ts +390 -0
- package/src/theme/build/_deprecated/color/factory.ts +142 -0
- package/src/theme/build/_deprecated/color/index.ts +1 -0
- package/src/theme/build/_deprecated/color/input/createInputModes.ts +81 -0
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +54 -0
- package/src/theme/build/_deprecated/color/spot/createSpot.ts +20 -0
- package/src/theme/build/buildColorTheme.test.ts +183 -0
- package/src/theme/build/buildColorTheme.ts +499 -0
- package/src/theme/build/buildTheme.test.ts +87 -0
- package/src/theme/build/buildTheme.ts +36 -0
- package/src/theme/build/colorToken/colorToken.ts +19 -0
- package/src/theme/build/colorToken/compileColorToken.ts +21 -0
- package/src/theme/build/colorToken/index.ts +2 -0
- package/src/theme/build/colorToken/types.ts +6 -0
- package/src/theme/build/index.ts +3 -0
- package/src/theme/build/lib/color-fns/blend/index.ts +3 -0
- package/src/theme/build/lib/color-fns/blend/mix.ts +21 -0
- package/src/theme/build/lib/color-fns/blend/multiply.ts +18 -0
- package/src/theme/build/lib/color-fns/blend/screen.ts +18 -0
- package/src/theme/build/lib/color-fns/color-fns.test.ts +68 -0
- package/src/theme/build/lib/color-fns/contrastRatio.ts +31 -0
- package/src/theme/build/lib/color-fns/convert.ts +150 -0
- package/src/theme/build/lib/color-fns/index.ts +6 -0
- package/src/theme/build/lib/color-fns/parse.ts +60 -0
- package/src/theme/build/lib/color-fns/rgba.ts +10 -0
- package/src/theme/build/lib/color-fns/types.ts +28 -0
- package/src/theme/build/lib/isRecord.ts +3 -0
- package/src/theme/build/lib/lazy.ts +30 -0
- package/src/theme/build/lib/utils.ts +19 -0
- package/src/theme/build/merge.ts +26 -0
- package/src/theme/build/mixThemeColor.test.ts +21 -0
- package/src/theme/build/mixThemeColor.ts +53 -0
- package/src/theme/build/renderColorTheme.ts +532 -0
- package/src/theme/build/renderColorValue.ts +85 -0
- package/src/theme/build/resolveColorTokens.ts +268 -0
- package/src/theme/build/theme.test.ts +27 -0
- package/src/theme/config/helpers.ts +55 -0
- package/src/theme/config/index.ts +4 -0
- package/src/theme/config/system.ts +115 -0
- package/src/theme/config/tokens/color/index.ts +1 -0
- package/src/theme/config/tokens/color/types.ts +133 -0
- package/src/theme/config/tokens/index.ts +4 -0
- package/src/theme/config/tokens/parseTokenKey.test.ts +64 -0
- package/src/theme/config/tokens/parseTokenKey.ts +67 -0
- package/src/theme/config/tokens/parseTokenValue.test.ts +42 -0
- package/src/theme/config/tokens/parseTokenValue.ts +133 -0
- package/src/theme/config/tokens/types.ts +53 -0
- package/src/theme/config/types.ts +46 -0
- package/src/theme/defaults/colorPalette.ts +5 -0
- package/src/theme/defaults/colorTokens.ts +648 -0
- package/src/theme/defaults/config.ts +84 -0
- package/src/theme/defaults/fonts.ts +227 -0
- package/src/theme/getScopedTheme.ts +98 -0
- package/src/theme/index.ts +5 -0
- package/src/theme/system/avatar.ts +14 -0
- package/src/theme/system/color/_constants.ts +45 -0
- package/src/theme/system/color/_helpers.ts +24 -0
- package/src/theme/system/color/_system.ts +40 -0
- package/src/theme/system/color/avatar.ts +15 -0
- package/src/theme/system/color/badge.ts +16 -0
- package/src/theme/system/color/button.ts +17 -0
- package/src/theme/system/color/color.ts +34 -0
- package/src/theme/system/color/index.ts +13 -0
- package/src/theme/system/color/input.ts +25 -0
- package/src/theme/system/color/kbd.ts +8 -0
- package/src/theme/system/color/selectable.ts +12 -0
- package/src/theme/system/color/shadow.ts +7 -0
- package/src/theme/system/color/state.ts +43 -0
- package/src/theme/system/color/syntax.ts +41 -0
- package/src/theme/system/css.ts +14 -0
- package/src/theme/system/focusRing.ts +7 -0
- package/src/theme/system/font.ts +52 -0
- package/src/theme/system/index.ts +11 -0
- package/src/theme/system/input.ts +33 -0
- package/src/theme/system/layer.ts +8 -0
- package/src/theme/system/shadow.ts +19 -0
- package/src/theme/system/styles.ts +13 -0
- package/src/theme/system/theme.ts +138 -0
- package/src/theme/system/v0/avatar.ts +10 -0
- package/src/theme/system/v0/color/_generic.ts +35 -0
- package/src/theme/system/v0/color/_system.ts +17 -0
- package/src/theme/system/v0/color/base.ts +21 -0
- package/src/theme/system/v0/color/button.ts +42 -0
- package/src/theme/system/v0/color/card.ts +19 -0
- package/src/theme/system/v0/color/color.ts +40 -0
- package/src/theme/system/v0/color/index.ts +11 -0
- package/src/theme/system/v0/color/input.ts +34 -0
- package/src/theme/system/v0/color/muted.ts +26 -0
- package/src/theme/system/v0/color/selectable.ts +31 -0
- package/src/theme/system/v0/color/solid.ts +26 -0
- package/src/theme/system/v0/color/spot.ts +13 -0
- package/src/theme/system/v0/index.ts +3 -0
- package/src/theme/system/v0/input.ts +23 -0
- package/src/theme/versioning/getTheme_v2.ts +57 -0
- package/src/theme/versioning/index.ts +5 -0
- package/src/theme/versioning/is_v0.ts +6 -0
- package/src/theme/versioning/is_v2.ts +6 -0
- package/src/theme/versioning/themeColor_v0_v2.ts +243 -0
- package/src/theme/versioning/themeColor_v2_v2_9.ts +49 -0
- package/src/theme/versioning/v0_v2.ts +94 -0
- package/src/theme/versioning/v2_v0.ts +135 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {useCallback, useEffect, useRef, useState} from 'react'
|
|
2
|
+
|
|
3
|
+
import {_getFocusableElements, _sortElements} from './helpers'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface MenuController {
|
|
9
|
+
activeElement: HTMLElement | null
|
|
10
|
+
activeIndex: number
|
|
11
|
+
handleItemMouseEnter: (event: React.MouseEvent<HTMLElement>) => void
|
|
12
|
+
handleItemMouseLeave: () => void
|
|
13
|
+
handleKeyDown: (event: React.KeyboardEvent<HTMLDivElement>) => void
|
|
14
|
+
mount: (element: HTMLElement | null, selected?: boolean) => () => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This controller is responsible for controlling UI menu state.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export function useMenuController(props: {
|
|
23
|
+
onKeyDown?: React.KeyboardEventHandler
|
|
24
|
+
originElement?: HTMLElement | null
|
|
25
|
+
shouldFocus: 'first' | 'last' | null
|
|
26
|
+
rootElementRef: React.MutableRefObject<HTMLDivElement | null>
|
|
27
|
+
}): MenuController {
|
|
28
|
+
const {onKeyDown, originElement, shouldFocus, rootElementRef} = props
|
|
29
|
+
const elementsRef = useRef<HTMLElement[]>([])
|
|
30
|
+
const [activeIndex, _setActiveIndex] = useState(-1)
|
|
31
|
+
const activeIndexRef = useRef(activeIndex)
|
|
32
|
+
const [activeElement, setActiveElement] = useState<HTMLElement | null>(null)
|
|
33
|
+
|
|
34
|
+
const setActiveIndex = useCallback((nextActiveIndex: number) => {
|
|
35
|
+
_setActiveIndex(nextActiveIndex)
|
|
36
|
+
activeIndexRef.current = nextActiveIndex
|
|
37
|
+
setActiveElement(elementsRef.current[nextActiveIndex] || null)
|
|
38
|
+
}, [])
|
|
39
|
+
|
|
40
|
+
const mount = useCallback(
|
|
41
|
+
(element: HTMLElement | null, selected?: boolean): (() => void) => {
|
|
42
|
+
if (!element) return () => undefined
|
|
43
|
+
|
|
44
|
+
if (elementsRef.current.indexOf(element) === -1) {
|
|
45
|
+
elementsRef.current.push(element)
|
|
46
|
+
_sortElements(rootElementRef.current, elementsRef.current)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (selected) {
|
|
50
|
+
const selectedIndex = elementsRef.current.indexOf(element)
|
|
51
|
+
|
|
52
|
+
setActiveIndex(selectedIndex)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return () => {
|
|
56
|
+
const idx = elementsRef.current.indexOf(element)
|
|
57
|
+
|
|
58
|
+
if (idx > -1) {
|
|
59
|
+
elementsRef.current.splice(idx, 1)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
[rootElementRef, setActiveIndex],
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const handleKeyDown = useCallback(
|
|
67
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
68
|
+
// Move focus to the element that opened the menu before handling the `Tab` press
|
|
69
|
+
if (event.key === 'Tab') {
|
|
70
|
+
if (originElement) {
|
|
71
|
+
originElement.focus()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Move focus to the first focusable menuitem
|
|
78
|
+
if (event.key === 'Home') {
|
|
79
|
+
event.preventDefault()
|
|
80
|
+
event.stopPropagation()
|
|
81
|
+
|
|
82
|
+
const focusableElements = _getFocusableElements(elementsRef.current)
|
|
83
|
+
const el = focusableElements[0]
|
|
84
|
+
|
|
85
|
+
if (!el) return
|
|
86
|
+
|
|
87
|
+
const currentIndex = elementsRef.current.indexOf(el)
|
|
88
|
+
|
|
89
|
+
setActiveIndex(currentIndex)
|
|
90
|
+
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Move focus to the last focusable menuitem
|
|
95
|
+
if (event.key === 'End') {
|
|
96
|
+
event.preventDefault()
|
|
97
|
+
event.stopPropagation()
|
|
98
|
+
|
|
99
|
+
const focusableElements = _getFocusableElements(elementsRef.current)
|
|
100
|
+
const el = focusableElements[focusableElements.length - 1]
|
|
101
|
+
|
|
102
|
+
if (!el) return
|
|
103
|
+
|
|
104
|
+
const currentIndex = elementsRef.current.indexOf(el)
|
|
105
|
+
|
|
106
|
+
setActiveIndex(currentIndex)
|
|
107
|
+
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (event.key === 'ArrowUp') {
|
|
112
|
+
event.preventDefault()
|
|
113
|
+
event.stopPropagation()
|
|
114
|
+
|
|
115
|
+
const focusableElements = _getFocusableElements(elementsRef.current)
|
|
116
|
+
const focusableLen = focusableElements.length
|
|
117
|
+
|
|
118
|
+
if (focusableLen === 0) return
|
|
119
|
+
|
|
120
|
+
const focusedElement = elementsRef.current[activeIndexRef.current]
|
|
121
|
+
|
|
122
|
+
let focusedIndex = focusableElements.indexOf(focusedElement)
|
|
123
|
+
|
|
124
|
+
focusedIndex = (focusedIndex - 1 + focusableLen) % focusableLen
|
|
125
|
+
|
|
126
|
+
const el = focusableElements[focusedIndex]
|
|
127
|
+
const currentIndex = elementsRef.current.indexOf(el)
|
|
128
|
+
|
|
129
|
+
setActiveIndex(currentIndex)
|
|
130
|
+
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (event.key === 'ArrowDown') {
|
|
135
|
+
event.preventDefault()
|
|
136
|
+
event.stopPropagation()
|
|
137
|
+
|
|
138
|
+
const focusableElements = _getFocusableElements(elementsRef.current)
|
|
139
|
+
const focusableLen = focusableElements.length
|
|
140
|
+
|
|
141
|
+
if (focusableLen === 0) return
|
|
142
|
+
|
|
143
|
+
const focusedElement = elementsRef.current[activeIndexRef.current]
|
|
144
|
+
|
|
145
|
+
let focusedIndex = focusableElements.indexOf(focusedElement)
|
|
146
|
+
|
|
147
|
+
focusedIndex = (focusedIndex + 1) % focusableLen
|
|
148
|
+
|
|
149
|
+
const el = focusableElements[focusedIndex]
|
|
150
|
+
const currentIndex = elementsRef.current.indexOf(el)
|
|
151
|
+
|
|
152
|
+
setActiveIndex(currentIndex)
|
|
153
|
+
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (onKeyDown) {
|
|
158
|
+
onKeyDown(event)
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
[onKeyDown, originElement, setActiveIndex],
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
const handleItemMouseEnter = useCallback(
|
|
165
|
+
(event: React.MouseEvent<HTMLElement>) => {
|
|
166
|
+
const element = event.currentTarget
|
|
167
|
+
const currentIndex = elementsRef.current.indexOf(element)
|
|
168
|
+
|
|
169
|
+
setActiveIndex(currentIndex)
|
|
170
|
+
},
|
|
171
|
+
[setActiveIndex],
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
const handleItemMouseLeave = useCallback(() => {
|
|
175
|
+
// Set the active index to -2 to deactivate all menu items
|
|
176
|
+
// when the user moves the mouse away from the menu item.
|
|
177
|
+
// We avoid using -1 because it would focus the first menu item,
|
|
178
|
+
// which would be incorrect when the user hovers over a gap
|
|
179
|
+
// between two menu items or a menu divider.
|
|
180
|
+
setActiveIndex(-2)
|
|
181
|
+
rootElementRef.current?.focus()
|
|
182
|
+
}, [rootElementRef, setActiveIndex])
|
|
183
|
+
|
|
184
|
+
// Set focus on the currently active element
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (!rootElementRef.current) return
|
|
187
|
+
|
|
188
|
+
const rafId = requestAnimationFrame(() => {
|
|
189
|
+
if (activeIndex === -1) {
|
|
190
|
+
if (shouldFocus === 'first') {
|
|
191
|
+
const focusableElements = _getFocusableElements(elementsRef.current)
|
|
192
|
+
const el = focusableElements[0]
|
|
193
|
+
|
|
194
|
+
if (el) {
|
|
195
|
+
const currentIndex = elementsRef.current.indexOf(el)
|
|
196
|
+
|
|
197
|
+
setActiveIndex(currentIndex)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (shouldFocus === 'last') {
|
|
202
|
+
const focusableElements = _getFocusableElements(elementsRef.current)
|
|
203
|
+
const el = focusableElements[focusableElements.length - 1]
|
|
204
|
+
|
|
205
|
+
if (el) {
|
|
206
|
+
const currentIndex = elementsRef.current.indexOf(el)
|
|
207
|
+
|
|
208
|
+
setActiveIndex(currentIndex)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const element = elementsRef.current[activeIndex] || null
|
|
216
|
+
|
|
217
|
+
element?.focus()
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
return () => cancelAnimationFrame(rafId)
|
|
221
|
+
}, [activeIndex, rootElementRef, setActiveIndex, shouldFocus])
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
activeElement,
|
|
225
|
+
activeIndex,
|
|
226
|
+
handleItemMouseEnter,
|
|
227
|
+
handleItemMouseLeave,
|
|
228
|
+
handleKeyDown,
|
|
229
|
+
mount,
|
|
230
|
+
}
|
|
231
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
Card,
|
|
4
|
+
CodeSkeleton,
|
|
5
|
+
Container,
|
|
6
|
+
Flex,
|
|
7
|
+
HeadingSkeleton,
|
|
8
|
+
LabelSkeleton,
|
|
9
|
+
Skeleton,
|
|
10
|
+
Stack,
|
|
11
|
+
Text,
|
|
12
|
+
TextSkeleton,
|
|
13
|
+
} from '@bettercms-ai/kit'
|
|
14
|
+
import {useBoolean, useSelect} from '@bettercms-ai/kit-workshop'
|
|
15
|
+
|
|
16
|
+
import {WORKSHOP_CARD_TONE_OPTIONS} from '../../../__workshop__/constants'
|
|
17
|
+
|
|
18
|
+
export default function SkeletonDelayStory() {
|
|
19
|
+
const tone = useSelect('Tone', WORKSHOP_CARD_TONE_OPTIONS, '', 'Props') || 'default'
|
|
20
|
+
const animated = useBoolean('Animated', true)
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Box padding={[4, 5, 6]}>
|
|
24
|
+
<Container width={1}>
|
|
25
|
+
<Text muted>Delayed by 2000ms</Text>
|
|
26
|
+
<Card tone={tone} marginTop={4} padding={2} radius={2} border>
|
|
27
|
+
<Flex align="center">
|
|
28
|
+
<Skeleton
|
|
29
|
+
style={{width: 90, height: 90}}
|
|
30
|
+
radius={2}
|
|
31
|
+
animated={animated}
|
|
32
|
+
marginRight={3}
|
|
33
|
+
delay={1000}
|
|
34
|
+
/>
|
|
35
|
+
<Stack space={2} flex={1}>
|
|
36
|
+
<HeadingSkeleton
|
|
37
|
+
size={4}
|
|
38
|
+
style={{width: '100%'}}
|
|
39
|
+
radius={1}
|
|
40
|
+
animated={animated}
|
|
41
|
+
delay={1000}
|
|
42
|
+
/>
|
|
43
|
+
<TextSkeleton
|
|
44
|
+
size={1}
|
|
45
|
+
style={{width: '100%'}}
|
|
46
|
+
radius={1}
|
|
47
|
+
animated={animated}
|
|
48
|
+
delay={1000}
|
|
49
|
+
/>
|
|
50
|
+
<LabelSkeleton
|
|
51
|
+
size={1}
|
|
52
|
+
style={{width: '100%'}}
|
|
53
|
+
radius={1}
|
|
54
|
+
animated={animated}
|
|
55
|
+
delay={1000}
|
|
56
|
+
/>
|
|
57
|
+
<CodeSkeleton
|
|
58
|
+
size={1}
|
|
59
|
+
style={{width: '100%'}}
|
|
60
|
+
radius={1}
|
|
61
|
+
animated={animated}
|
|
62
|
+
delay={1000}
|
|
63
|
+
/>
|
|
64
|
+
</Stack>
|
|
65
|
+
</Flex>
|
|
66
|
+
</Card>
|
|
67
|
+
</Container>
|
|
68
|
+
</Box>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {defineScope} from '@bettercms-ai/kit-workshop'
|
|
2
|
+
import {lazy} from 'react'
|
|
3
|
+
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'components/skeleton',
|
|
6
|
+
title: 'Skeleton',
|
|
7
|
+
stories: [
|
|
8
|
+
{name: 'skeleton', title: 'Skeleton', component: lazy(() => import('./skeleton'))},
|
|
9
|
+
{name: 'skeleton-delay', title: 'Skeleton delay', component: lazy(() => import('./delay'))},
|
|
10
|
+
],
|
|
11
|
+
})
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
Card,
|
|
4
|
+
CodeSkeleton,
|
|
5
|
+
Container,
|
|
6
|
+
Flex,
|
|
7
|
+
Grid,
|
|
8
|
+
HeadingSkeleton,
|
|
9
|
+
LabelSkeleton,
|
|
10
|
+
Skeleton,
|
|
11
|
+
Stack,
|
|
12
|
+
TextSkeleton,
|
|
13
|
+
} from '@bettercms-ai/kit'
|
|
14
|
+
import {useBoolean, useSelect} from '@bettercms-ai/kit-workshop'
|
|
15
|
+
|
|
16
|
+
import {WORKSHOP_CARD_TONE_OPTIONS} from '../../../__workshop__/constants'
|
|
17
|
+
|
|
18
|
+
export default function SkeletonStory() {
|
|
19
|
+
const tone = useSelect('Tone', WORKSHOP_CARD_TONE_OPTIONS, '', 'Props') || 'default'
|
|
20
|
+
const animated = useBoolean('Animated', true)
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Box padding={[4, 5, 6]}>
|
|
24
|
+
<Container width={1}>
|
|
25
|
+
<Stack space={4}>
|
|
26
|
+
{[1, 2, 3].map((item) => (
|
|
27
|
+
<Card key={item} tone={tone} padding={2} radius={2} border>
|
|
28
|
+
<Flex align="center">
|
|
29
|
+
<Grid gap={2} columns={2} marginRight={3}>
|
|
30
|
+
<Skeleton style={{width: 40, height: 40}} radius={2} animated={animated} />
|
|
31
|
+
<Skeleton style={{width: 40, height: 40}} radius={2} animated={animated} />
|
|
32
|
+
<Skeleton style={{width: 40, height: 40}} radius={2} animated={animated} />
|
|
33
|
+
<Skeleton style={{width: 40, height: 40}} radius={2} animated={animated} />
|
|
34
|
+
</Grid>
|
|
35
|
+
<Stack space={2} flex={1}>
|
|
36
|
+
<HeadingSkeleton style={{width: '100%'}} radius={1} animated={animated} />
|
|
37
|
+
<TextSkeleton style={{width: '100%'}} radius={1} animated={animated} />
|
|
38
|
+
<LabelSkeleton style={{width: '100%'}} radius={1} animated={animated} />
|
|
39
|
+
<CodeSkeleton style={{width: '100%'}} radius={1} animated={animated} />
|
|
40
|
+
</Stack>
|
|
41
|
+
</Flex>
|
|
42
|
+
<Flex marginTop={2}>
|
|
43
|
+
<Skeleton
|
|
44
|
+
style={{height: 50}}
|
|
45
|
+
flex={1}
|
|
46
|
+
marginRight={1}
|
|
47
|
+
radius={2}
|
|
48
|
+
animated={animated}
|
|
49
|
+
/>
|
|
50
|
+
<Skeleton
|
|
51
|
+
style={{height: 50}}
|
|
52
|
+
flex={1}
|
|
53
|
+
marginLeft={1}
|
|
54
|
+
radius={2}
|
|
55
|
+
animated={animated}
|
|
56
|
+
/>
|
|
57
|
+
</Flex>
|
|
58
|
+
</Card>
|
|
59
|
+
))}
|
|
60
|
+
</Stack>
|
|
61
|
+
</Container>
|
|
62
|
+
</Box>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {forwardRef, useEffect, useState} from 'react'
|
|
2
|
+
import {styled} from 'styled-components'
|
|
3
|
+
|
|
4
|
+
import {Box, BoxOwnProps, ResponsiveRadiusProps} from '../../primitives'
|
|
5
|
+
import {_getArrayProp} from '../../styles'
|
|
6
|
+
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
7
|
+
import {skeletonStyle} from './styles'
|
|
8
|
+
|
|
9
|
+
const StyledSkeleton = styled(Box)<
|
|
10
|
+
{$animated: boolean; $visible: boolean} & ResponsiveRadiusStyleProps
|
|
11
|
+
>(responsiveRadiusStyle, skeletonStyle)
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This API might change. DO NOT USE IN PRODUCTION.
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
export interface SkeletonProps extends ResponsiveRadiusProps, Omit<BoxOwnProps, 'children'> {
|
|
18
|
+
animated?: boolean
|
|
19
|
+
delay?: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* This API might change. DO NOT USE IN PRODUCTION.
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
26
|
+
export const Skeleton = forwardRef(function Skeleton(
|
|
27
|
+
props: SkeletonProps & React.HTMLProps<HTMLDivElement>,
|
|
28
|
+
ref: React.Ref<HTMLDivElement>,
|
|
29
|
+
) {
|
|
30
|
+
const {animated = false, delay, radius, ...restProps} = props
|
|
31
|
+
const [visible, setVisible] = useState<boolean>(delay ? false : true)
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!delay) {
|
|
35
|
+
return undefined
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const timeout = setTimeout(() => {
|
|
39
|
+
setVisible(true)
|
|
40
|
+
}, delay)
|
|
41
|
+
|
|
42
|
+
return () => {
|
|
43
|
+
clearTimeout(timeout)
|
|
44
|
+
}
|
|
45
|
+
}, [delay])
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<StyledSkeleton
|
|
49
|
+
{...restProps}
|
|
50
|
+
$animated={animated}
|
|
51
|
+
$radius={_getArrayProp(radius)}
|
|
52
|
+
$visible={delay ? visible : true}
|
|
53
|
+
ref={ref}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
})
|
|
57
|
+
Skeleton.displayName = 'ForwardRef(Skeleton)'
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {css, keyframes} from 'styled-components'
|
|
2
|
+
|
|
3
|
+
const keyframe = keyframes`
|
|
4
|
+
0% {
|
|
5
|
+
background-position: 100%;
|
|
6
|
+
}
|
|
7
|
+
100% {
|
|
8
|
+
background-position: -100%;
|
|
9
|
+
}
|
|
10
|
+
`
|
|
11
|
+
|
|
12
|
+
const animation = css`
|
|
13
|
+
background-image: linear-gradient(
|
|
14
|
+
to right,
|
|
15
|
+
var(--card-skeleton-color-from),
|
|
16
|
+
var(--card-skeleton-color-to),
|
|
17
|
+
var(--card-skeleton-color-from),
|
|
18
|
+
var(--card-skeleton-color-from),
|
|
19
|
+
var(--card-skeleton-color-from)
|
|
20
|
+
);
|
|
21
|
+
background-position: 100%;
|
|
22
|
+
background-size: 200% 100%;
|
|
23
|
+
background-attachment: fixed;
|
|
24
|
+
animation-name: ${keyframe};
|
|
25
|
+
animation-timing-function: ease-in-out;
|
|
26
|
+
animation-iteration-count: infinite;
|
|
27
|
+
animation-duration: 2000ms;
|
|
28
|
+
`
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* This API might change. DO NOT USE IN PRODUCTION.
|
|
32
|
+
* @beta
|
|
33
|
+
*/
|
|
34
|
+
export const skeletonStyle = css<{$animated: boolean; $visible: boolean}>`
|
|
35
|
+
opacity: ${({$visible}) => ($visible ? 1 : 0)};
|
|
36
|
+
transition: opacity 200ms ease-in;
|
|
37
|
+
|
|
38
|
+
@media screen and (prefers-reduced-motion: no-preference) {
|
|
39
|
+
${({$animated}) =>
|
|
40
|
+
$animated
|
|
41
|
+
? animation
|
|
42
|
+
: css`
|
|
43
|
+
background-color: var(--card-skeleton-color-from);
|
|
44
|
+
`}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@media screen and (prefers-reduced-motion: reduce) {
|
|
48
|
+
background-color: var(--card-skeleton-color-from);
|
|
49
|
+
}
|
|
50
|
+
`
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {getTheme_v2, ThemeFontKey} from '@bettercms-ai/kit/theme'
|
|
2
|
+
import {forwardRef} from 'react'
|
|
3
|
+
import {styled} from 'styled-components'
|
|
4
|
+
|
|
5
|
+
import {_getArrayProp, _responsive, ThemeProps} from '../../styles'
|
|
6
|
+
import {Skeleton, SkeletonProps} from './skeleton'
|
|
7
|
+
|
|
8
|
+
const StyledSkeleton = styled(Skeleton)<{$size: number[]; $style: ThemeFontKey}>((
|
|
9
|
+
props: {
|
|
10
|
+
$size: number[]
|
|
11
|
+
$style: ThemeFontKey
|
|
12
|
+
} & ThemeProps,
|
|
13
|
+
) => {
|
|
14
|
+
const {$size, $style} = props
|
|
15
|
+
const {font, media} = getTheme_v2(props.theme)
|
|
16
|
+
const fontStyle = font[$style]
|
|
17
|
+
|
|
18
|
+
const styles = _responsive(media, $size, (sizeIndex) => {
|
|
19
|
+
const fontSize = fontStyle.sizes[sizeIndex]
|
|
20
|
+
const capHeight = fontSize.lineHeight - fontSize.ascenderHeight - fontSize.descenderHeight
|
|
21
|
+
|
|
22
|
+
return {height: capHeight}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
return styles
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* This API might change. DO NOT USE IN PRODUCTION.
|
|
30
|
+
* @beta
|
|
31
|
+
*/
|
|
32
|
+
export interface TextSkeletonProps extends SkeletonProps {
|
|
33
|
+
size?: number | number[]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* This API might change. DO NOT USE IN PRODUCTION.
|
|
38
|
+
* @beta
|
|
39
|
+
*/
|
|
40
|
+
export interface LabelSkeletonProps extends SkeletonProps {
|
|
41
|
+
size?: number | number[]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* This API might change. DO NOT USE IN PRODUCTION.
|
|
46
|
+
* @beta
|
|
47
|
+
*/
|
|
48
|
+
export interface HeadingSkeletonProps extends SkeletonProps {
|
|
49
|
+
size?: number | number[]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* This API might change. DO NOT USE IN PRODUCTION.
|
|
54
|
+
* @beta
|
|
55
|
+
*/
|
|
56
|
+
export interface CodeSkeletonProps extends SkeletonProps {
|
|
57
|
+
size?: number | number[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* This API might change. DO NOT USE IN PRODUCTION.
|
|
62
|
+
* @beta
|
|
63
|
+
*/
|
|
64
|
+
export const TextSkeleton = forwardRef(function TextSkeleton(
|
|
65
|
+
props: TextSkeletonProps &
|
|
66
|
+
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'height' | 'size'>,
|
|
67
|
+
ref: React.Ref<HTMLDivElement>,
|
|
68
|
+
) {
|
|
69
|
+
const {size = 2, ...restProps} = props
|
|
70
|
+
const $size = _getArrayProp(size)
|
|
71
|
+
|
|
72
|
+
return <StyledSkeleton {...restProps} $size={$size} ref={ref} $style="text" />
|
|
73
|
+
})
|
|
74
|
+
TextSkeleton.displayName = 'ForwardRef(TextSkeleton)'
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* This API might change. DO NOT USE IN PRODUCTION.
|
|
78
|
+
* @beta
|
|
79
|
+
*/
|
|
80
|
+
export const LabelSkeleton = forwardRef(function TextSkeleton(
|
|
81
|
+
props: LabelSkeletonProps &
|
|
82
|
+
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'height' | 'size'>,
|
|
83
|
+
ref: React.Ref<HTMLDivElement>,
|
|
84
|
+
) {
|
|
85
|
+
const {size = 2, ...restProps} = props
|
|
86
|
+
const $size = _getArrayProp(size)
|
|
87
|
+
|
|
88
|
+
return <StyledSkeleton {...restProps} $size={$size} ref={ref} $style="label" />
|
|
89
|
+
})
|
|
90
|
+
LabelSkeleton.displayName = 'ForwardRef(LabelSkeleton)'
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* This API might change. DO NOT USE IN PRODUCTION.
|
|
94
|
+
* @beta
|
|
95
|
+
*/
|
|
96
|
+
export const HeadingSkeleton = forwardRef(function TextSkeleton(
|
|
97
|
+
props: HeadingSkeletonProps &
|
|
98
|
+
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'height' | 'size'>,
|
|
99
|
+
ref: React.Ref<HTMLDivElement>,
|
|
100
|
+
) {
|
|
101
|
+
const {size = 2, ...restProps} = props
|
|
102
|
+
const $size = _getArrayProp(size)
|
|
103
|
+
|
|
104
|
+
return <StyledSkeleton {...restProps} $size={$size} ref={ref} $style="heading" />
|
|
105
|
+
})
|
|
106
|
+
HeadingSkeleton.displayName = 'ForwardRef(HeadingSkeleton)'
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* This API might change. DO NOT USE IN PRODUCTION.
|
|
110
|
+
* @beta
|
|
111
|
+
*/
|
|
112
|
+
export const CodeSkeleton = forwardRef(function TextSkeleton(
|
|
113
|
+
props: CodeSkeletonProps &
|
|
114
|
+
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'height' | 'size'>,
|
|
115
|
+
ref: React.Ref<HTMLDivElement>,
|
|
116
|
+
) {
|
|
117
|
+
const {size = 2, ...restProps} = props
|
|
118
|
+
const $size = _getArrayProp(size)
|
|
119
|
+
|
|
120
|
+
return <StyledSkeleton {...restProps} $size={$size} ref={ref} $style="code" />
|
|
121
|
+
})
|
|
122
|
+
CodeSkeleton.displayName = 'ForwardRef(CodeSkeleton)'
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {OkHandIcon, RocketIcon, SunIcon} from '@bettercms-ai/icons'
|
|
2
|
+
import {Box, Card, Tab, TabList, TabPanel, Text} from '@bettercms-ai/kit'
|
|
3
|
+
import {useBoolean} from '@bettercms-ai/kit-workshop'
|
|
4
|
+
import {useState} from 'react'
|
|
5
|
+
|
|
6
|
+
export default function ExampleStory() {
|
|
7
|
+
const [tab, setTab] = useState('foo')
|
|
8
|
+
const useLongTitle = useBoolean('Use long title', false, 'Props') || false
|
|
9
|
+
|
|
10
|
+
const longTitle =
|
|
11
|
+
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Box padding={[4, 5, 6]}>
|
|
15
|
+
<TabList space={[1, 2, 3]}>
|
|
16
|
+
<Tab
|
|
17
|
+
aria-controls="example-panel-foo"
|
|
18
|
+
icon={SunIcon}
|
|
19
|
+
id="example-tab-foo"
|
|
20
|
+
label="Foo"
|
|
21
|
+
onClick={() => setTab('foo')}
|
|
22
|
+
selected={tab === 'foo'}
|
|
23
|
+
/>
|
|
24
|
+
<Tab
|
|
25
|
+
aria-controls="example-panel-bar"
|
|
26
|
+
icon={RocketIcon}
|
|
27
|
+
id="example-tab-bar"
|
|
28
|
+
label="Bar"
|
|
29
|
+
onClick={() => setTab('bar')}
|
|
30
|
+
selected={tab === 'bar'}
|
|
31
|
+
/>
|
|
32
|
+
<Tab
|
|
33
|
+
aria-controls="example-panel-baz"
|
|
34
|
+
icon={OkHandIcon}
|
|
35
|
+
id="example-tab-baz"
|
|
36
|
+
label={useLongTitle ? longTitle : 'Baz'}
|
|
37
|
+
onClick={() => setTab('baz')}
|
|
38
|
+
selected={tab === 'baz'}
|
|
39
|
+
/>
|
|
40
|
+
</TabList>
|
|
41
|
+
<TabPanel
|
|
42
|
+
aria-labelledby="example-panel-foo"
|
|
43
|
+
hidden={tab !== 'foo'}
|
|
44
|
+
id="example-panel-foo"
|
|
45
|
+
marginTop={[3, 4, 5]}
|
|
46
|
+
>
|
|
47
|
+
<Card border padding={3}>
|
|
48
|
+
<Text>
|
|
49
|
+
This is the <strong>Foo</strong> panel
|
|
50
|
+
</Text>
|
|
51
|
+
</Card>
|
|
52
|
+
</TabPanel>
|
|
53
|
+
<TabPanel
|
|
54
|
+
aria-labelledby="example-panel-bar"
|
|
55
|
+
hidden={tab !== 'bar'}
|
|
56
|
+
id="example-panel-bar"
|
|
57
|
+
marginTop={[3, 4, 5]}
|
|
58
|
+
>
|
|
59
|
+
<Card border padding={3}>
|
|
60
|
+
<Text>
|
|
61
|
+
This is the <strong>Bar</strong> panel
|
|
62
|
+
</Text>
|
|
63
|
+
</Card>
|
|
64
|
+
</TabPanel>
|
|
65
|
+
<TabPanel
|
|
66
|
+
aria-labelledby="example-panel-baz"
|
|
67
|
+
hidden={tab !== 'baz'}
|
|
68
|
+
id="example-panel-baz"
|
|
69
|
+
marginTop={[3, 4, 5]}
|
|
70
|
+
>
|
|
71
|
+
<Card border padding={3}>
|
|
72
|
+
<Text>
|
|
73
|
+
This is the <strong>Baz</strong> panel
|
|
74
|
+
</Text>
|
|
75
|
+
</Card>
|
|
76
|
+
</TabPanel>
|
|
77
|
+
</Box>
|
|
78
|
+
)
|
|
79
|
+
}
|