@basic-ui/core 0.0.35 → 0.0.38
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/build/cjs/index.js +84 -83
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Accordion/Accordion.d.ts +0 -0
- package/build/esm/Accordion/Accordion.js +0 -0
- package/build/esm/Accordion/Accordion.js.map +0 -0
- package/build/esm/Accordion/AccordionBody.d.ts +0 -0
- package/build/esm/Accordion/AccordionBody.js +0 -0
- package/build/esm/Accordion/AccordionBody.js.map +0 -0
- package/build/esm/Accordion/AccordionHeader.d.ts +0 -0
- package/build/esm/Accordion/AccordionHeader.js +0 -0
- package/build/esm/Accordion/AccordionHeader.js.map +0 -0
- package/build/esm/Accordion/AccordionItem.d.ts +0 -0
- package/build/esm/Accordion/AccordionItem.js +1 -2
- package/build/esm/Accordion/AccordionItem.js.map +1 -1
- package/build/esm/Accordion/context.d.ts +0 -0
- package/build/esm/Accordion/context.js +0 -0
- package/build/esm/Accordion/context.js.map +0 -0
- package/build/esm/Accordion/index.d.ts +0 -0
- package/build/esm/Accordion/index.js +0 -0
- package/build/esm/Accordion/index.js.map +0 -0
- package/build/esm/Accordion/scopeQuery.d.ts +0 -0
- package/build/esm/Accordion/scopeQuery.js +0 -0
- package/build/esm/Accordion/scopeQuery.js.map +0 -0
- package/build/esm/CheckBox/CheckBox.d.ts +0 -0
- package/build/esm/CheckBox/CheckBox.js +0 -0
- package/build/esm/CheckBox/CheckBox.js.map +0 -0
- package/build/esm/CheckBox/index.d.ts +0 -0
- package/build/esm/CheckBox/index.js +0 -0
- package/build/esm/CheckBox/index.js.map +0 -0
- package/build/esm/ComboBox/Combobox.d.ts +0 -0
- package/build/esm/ComboBox/Combobox.js +2 -2
- package/build/esm/ComboBox/Combobox.js.map +1 -1
- package/build/esm/ComboBox/ComboboxButton.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxButton.js +0 -0
- package/build/esm/ComboBox/ComboboxButton.js.map +0 -0
- package/build/esm/ComboBox/ComboboxInput.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxInput.js +0 -0
- package/build/esm/ComboBox/ComboboxInput.js.map +0 -0
- package/build/esm/ComboBox/ComboboxLabel.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxLabel.js +0 -0
- package/build/esm/ComboBox/ComboboxLabel.js.map +0 -0
- package/build/esm/ComboBox/ComboboxList.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxList.js +0 -0
- package/build/esm/ComboBox/ComboboxList.js.map +0 -0
- package/build/esm/ComboBox/ComboboxOption.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxOption.js +0 -0
- package/build/esm/ComboBox/ComboboxOption.js.map +0 -0
- package/build/esm/ComboBox/ComboboxPopover.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxPopover.js +0 -0
- package/build/esm/ComboBox/ComboboxPopover.js.map +0 -0
- package/build/esm/ComboBox/cities.d.ts +0 -0
- package/build/esm/ComboBox/cities.js +0 -0
- package/build/esm/ComboBox/cities.js.map +0 -0
- package/build/esm/ComboBox/context.d.ts +0 -0
- package/build/esm/ComboBox/context.js +0 -0
- package/build/esm/ComboBox/context.js.map +0 -0
- package/build/esm/ComboBox/hooks.d.ts +0 -0
- package/build/esm/ComboBox/hooks.js +0 -0
- package/build/esm/ComboBox/hooks.js.map +0 -0
- package/build/esm/ComboBox/index.d.ts +0 -0
- package/build/esm/ComboBox/index.js +0 -0
- package/build/esm/ComboBox/index.js.map +0 -0
- package/build/esm/ComboBox/makeHash.d.ts +0 -0
- package/build/esm/ComboBox/makeHash.js +0 -0
- package/build/esm/ComboBox/makeHash.js.map +0 -0
- package/build/esm/ComboBox/scopeQuery.d.ts +0 -0
- package/build/esm/ComboBox/scopeQuery.js +0 -0
- package/build/esm/ComboBox/scopeQuery.js.map +0 -0
- package/build/esm/FocusLock/FocusLock.d.ts +0 -0
- package/build/esm/FocusLock/FocusLock.js +0 -0
- package/build/esm/FocusLock/FocusLock.js.map +0 -0
- package/build/esm/FocusLock/index.d.ts +0 -0
- package/build/esm/FocusLock/index.js +0 -0
- package/build/esm/FocusLock/index.js.map +0 -0
- package/build/esm/FocusLock/tabUtils.d.ts +1 -0
- package/build/esm/FocusLock/tabUtils.js +12 -0
- package/build/esm/FocusLock/tabUtils.js.map +1 -1
- package/build/esm/FocusLock/useFocusLock.d.ts +0 -0
- package/build/esm/FocusLock/useFocusLock.js +4 -11
- package/build/esm/FocusLock/useFocusLock.js.map +1 -1
- package/build/esm/List/List.d.ts +0 -0
- package/build/esm/List/List.js +0 -0
- package/build/esm/List/List.js.map +0 -0
- package/build/esm/List/ListItem.d.ts +0 -0
- package/build/esm/List/ListItem.js +0 -0
- package/build/esm/List/ListItem.js.map +0 -0
- package/build/esm/List/context.d.ts +0 -0
- package/build/esm/List/context.js +0 -0
- package/build/esm/List/context.js.map +0 -0
- package/build/esm/List/index.d.ts +0 -0
- package/build/esm/List/index.js +0 -0
- package/build/esm/List/index.js.map +0 -0
- package/build/esm/Menu/Menu.d.ts +0 -0
- package/build/esm/Menu/Menu.js +1 -2
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/MenuButton.d.ts +0 -0
- package/build/esm/Menu/MenuButton.js +3 -3
- package/build/esm/Menu/MenuButton.js.map +1 -1
- package/build/esm/Menu/MenuItem.d.ts +0 -0
- package/build/esm/Menu/MenuItem.js +3 -4
- package/build/esm/Menu/MenuItem.js.map +1 -1
- package/build/esm/Menu/MenuList.d.ts +0 -0
- package/build/esm/Menu/MenuList.js +0 -0
- package/build/esm/Menu/MenuList.js.map +0 -0
- package/build/esm/Menu/MenuPopover.d.ts +0 -0
- package/build/esm/Menu/MenuPopover.js +0 -0
- package/build/esm/Menu/MenuPopover.js.map +0 -0
- package/build/esm/Menu/context.d.ts +0 -0
- package/build/esm/Menu/context.js +0 -0
- package/build/esm/Menu/context.js.map +0 -0
- package/build/esm/Menu/index.d.ts +0 -0
- package/build/esm/Menu/index.js +0 -0
- package/build/esm/Menu/index.js.map +0 -0
- package/build/esm/Menu/scope.d.ts +0 -0
- package/build/esm/Menu/scope.js +0 -0
- package/build/esm/Menu/scope.js.map +0 -0
- package/build/esm/Modal/Modal.d.ts +0 -0
- package/build/esm/Modal/Modal.js +2 -2
- package/build/esm/Modal/Modal.js.map +1 -1
- package/build/esm/Modal/ModalBackdrop.d.ts +0 -0
- package/build/esm/Modal/ModalBackdrop.js +0 -0
- package/build/esm/Modal/ModalBackdrop.js.map +0 -0
- package/build/esm/Modal/index.d.ts +0 -0
- package/build/esm/Modal/index.js +0 -0
- package/build/esm/Modal/index.js.map +0 -0
- package/build/esm/Popper/Popper.d.ts +0 -0
- package/build/esm/Popper/Popper.js +5 -0
- package/build/esm/Popper/Popper.js.map +1 -1
- package/build/esm/Popper/PopperArrow.d.ts +0 -0
- package/build/esm/Popper/PopperArrow.js +0 -0
- package/build/esm/Popper/PopperArrow.js.map +0 -0
- package/build/esm/Popper/context.d.ts +0 -0
- package/build/esm/Popper/context.js +0 -0
- package/build/esm/Popper/context.js.map +0 -0
- package/build/esm/Popper/index.d.ts +0 -0
- package/build/esm/Popper/index.js +0 -0
- package/build/esm/Popper/index.js.map +0 -0
- package/build/esm/Portal/Portal.d.ts +0 -0
- package/build/esm/Portal/Portal.js +0 -0
- package/build/esm/Portal/Portal.js.map +0 -0
- package/build/esm/Portal/index.d.ts +0 -0
- package/build/esm/Portal/index.js +0 -0
- package/build/esm/Portal/index.js.map +0 -0
- package/build/esm/RadioButton/RadioButton.d.ts +0 -0
- package/build/esm/RadioButton/RadioButton.js +0 -0
- package/build/esm/RadioButton/RadioButton.js.map +0 -0
- package/build/esm/RadioButton/RadioGroup.d.ts +0 -0
- package/build/esm/RadioButton/RadioGroup.js +2 -2
- package/build/esm/RadioButton/RadioGroup.js.map +1 -1
- package/build/esm/RadioButton/context.d.ts +0 -0
- package/build/esm/RadioButton/context.js +0 -0
- package/build/esm/RadioButton/context.js.map +0 -0
- package/build/esm/RadioButton/index.d.ts +0 -0
- package/build/esm/RadioButton/index.js +0 -0
- package/build/esm/RadioButton/index.js.map +0 -0
- package/build/esm/SkipNav/SkipNav.d.ts +0 -0
- package/build/esm/SkipNav/SkipNav.js +0 -0
- package/build/esm/SkipNav/SkipNav.js.map +0 -0
- package/build/esm/SkipNav/index.d.ts +0 -0
- package/build/esm/SkipNav/index.js +0 -0
- package/build/esm/SkipNav/index.js.map +0 -0
- package/build/esm/Spinner/Spinner.d.ts +0 -0
- package/build/esm/Spinner/Spinner.js +0 -0
- package/build/esm/Spinner/Spinner.js.map +0 -0
- package/build/esm/Spinner/SpinnerButton.d.ts +0 -0
- package/build/esm/Spinner/SpinnerButton.js +0 -0
- package/build/esm/Spinner/SpinnerButton.js.map +0 -0
- package/build/esm/Spinner/context.d.ts +0 -0
- package/build/esm/Spinner/context.js +0 -0
- package/build/esm/Spinner/context.js.map +0 -0
- package/build/esm/Spinner/index.d.ts +0 -0
- package/build/esm/Spinner/index.js +0 -0
- package/build/esm/Spinner/index.js.map +0 -0
- package/build/esm/Tabs/Tab.d.ts +0 -0
- package/build/esm/Tabs/Tab.js +0 -0
- package/build/esm/Tabs/Tab.js.map +0 -0
- package/build/esm/Tabs/TabList.d.ts +0 -0
- package/build/esm/Tabs/TabList.js +2 -2
- package/build/esm/Tabs/TabList.js.map +1 -1
- package/build/esm/Tabs/TabPanel.d.ts +0 -0
- package/build/esm/Tabs/TabPanel.js +0 -0
- package/build/esm/Tabs/TabPanel.js.map +0 -0
- package/build/esm/Tabs/TabPanels.d.ts +0 -0
- package/build/esm/Tabs/TabPanels.js +0 -0
- package/build/esm/Tabs/TabPanels.js.map +0 -0
- package/build/esm/Tabs/Tabs.d.ts +0 -0
- package/build/esm/Tabs/Tabs.js +0 -0
- package/build/esm/Tabs/Tabs.js.map +0 -0
- package/build/esm/Tabs/context.d.ts +0 -0
- package/build/esm/Tabs/context.js +0 -0
- package/build/esm/Tabs/context.js.map +0 -0
- package/build/esm/Tabs/index.d.ts +0 -0
- package/build/esm/Tabs/index.js +0 -0
- package/build/esm/Tabs/index.js.map +0 -0
- package/build/esm/Tabs/scopeQuery.d.ts +0 -0
- package/build/esm/Tabs/scopeQuery.js +0 -0
- package/build/esm/Tabs/scopeQuery.js.map +0 -0
- package/build/esm/Tooltip/Tooltip.d.ts +0 -0
- package/build/esm/Tooltip/Tooltip.js +0 -0
- package/build/esm/Tooltip/Tooltip.js.map +0 -0
- package/build/esm/Tooltip/index.d.ts +0 -0
- package/build/esm/Tooltip/index.js +0 -0
- package/build/esm/Tooltip/index.js.map +0 -0
- package/build/esm/Tooltip/stateMachine.d.ts +0 -0
- package/build/esm/Tooltip/stateMachine.js +0 -0
- package/build/esm/Tooltip/stateMachine.js.map +0 -0
- package/build/esm/Tooltip/useTooltip.d.ts +1 -1
- package/build/esm/Tooltip/useTooltip.js +2 -3
- package/build/esm/Tooltip/useTooltip.js.map +1 -1
- package/build/esm/hooks/index.d.ts +0 -1
- package/build/esm/hooks/index.js +0 -1
- package/build/esm/hooks/index.js.map +1 -1
- package/build/esm/hooks/useAutoFocus.d.ts +0 -0
- package/build/esm/hooks/useAutoFocus.js +5 -1
- package/build/esm/hooks/useAutoFocus.js.map +1 -1
- package/build/esm/hooks/useChildrenCounter.d.ts +0 -0
- package/build/esm/hooks/useChildrenCounter.js +0 -0
- package/build/esm/hooks/useChildrenCounter.js.map +0 -0
- package/build/esm/hooks/useControlledState.d.ts +0 -0
- package/build/esm/hooks/useControlledState.js +0 -0
- package/build/esm/hooks/useControlledState.js.map +0 -0
- package/build/esm/hooks/useFocusReturn.d.ts +2 -1
- package/build/esm/hooks/useFocusReturn.js +24 -13
- package/build/esm/hooks/useFocusReturn.js.map +1 -1
- package/build/esm/hooks/useFocusState.d.ts +2 -2
- package/build/esm/hooks/useFocusState.js +0 -0
- package/build/esm/hooks/useFocusState.js.map +0 -0
- package/build/esm/hooks/useGestureHandlers.d.ts +0 -0
- package/build/esm/hooks/useGestureHandlers.js +0 -0
- package/build/esm/hooks/useGestureHandlers.js.map +0 -0
- package/build/esm/hooks/useId.d.ts +0 -0
- package/build/esm/hooks/useId.js +0 -0
- package/build/esm/hooks/useId.js.map +0 -0
- package/build/esm/hooks/useMeasure.d.ts +0 -0
- package/build/esm/hooks/useMeasure.js +0 -0
- package/build/esm/hooks/useMeasure.js.map +0 -0
- package/build/esm/hooks/useOnClickOutside.d.ts +0 -0
- package/build/esm/hooks/useOnClickOutside.js +0 -0
- package/build/esm/hooks/useOnClickOutside.js.map +0 -0
- package/build/esm/hooks/useOnKeyDown.d.ts +0 -0
- package/build/esm/hooks/useOnKeyDown.js +0 -0
- package/build/esm/hooks/useOnKeyDown.js.map +0 -0
- package/build/esm/hooks/useReducerMachine.d.ts +0 -0
- package/build/esm/hooks/useReducerMachine.js +0 -0
- package/build/esm/hooks/useReducerMachine.js.map +0 -0
- package/build/esm/hooks/useRemoveBodyScroll.d.ts +0 -0
- package/build/esm/hooks/useRemoveBodyScroll.js +12 -19
- package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
- package/build/esm/hooks/useScope.d.ts +0 -0
- package/build/esm/hooks/useScope.js +0 -0
- package/build/esm/hooks/useScope.js.map +0 -0
- package/build/esm/hooks/useThrottle.d.ts +0 -0
- package/build/esm/hooks/useThrottle.js +0 -0
- package/build/esm/hooks/useThrottle.js.map +0 -0
- package/build/esm/index.d.ts +0 -0
- package/build/esm/index.js +0 -0
- package/build/esm/index.js.map +0 -0
- package/build/esm/utils/assignRef.d.ts +0 -0
- package/build/esm/utils/assignRef.js +0 -0
- package/build/esm/utils/assignRef.js.map +0 -0
- package/build/esm/utils/clamp.d.ts +0 -0
- package/build/esm/utils/clamp.js +0 -0
- package/build/esm/utils/clamp.js.map +0 -0
- package/build/esm/utils/createSubscription.d.ts +0 -0
- package/build/esm/utils/createSubscription.js +0 -0
- package/build/esm/utils/createSubscription.js.map +0 -0
- package/build/esm/utils/getCircularIndex.d.ts +0 -0
- package/build/esm/utils/getCircularIndex.js +0 -0
- package/build/esm/utils/getCircularIndex.js.map +0 -0
- package/build/esm/utils/index.d.ts +0 -0
- package/build/esm/utils/index.js +0 -0
- package/build/esm/utils/index.js.map +0 -0
- package/build/esm/utils/rubberBandClamp.d.ts +0 -0
- package/build/esm/utils/rubberBandClamp.js +0 -0
- package/build/esm/utils/rubberBandClamp.js.map +0 -0
- package/build/esm/utils/wrapEvent.d.ts +0 -0
- package/build/esm/utils/wrapEvent.js +0 -0
- package/build/esm/utils/wrapEvent.js.map +0 -0
- package/build/tsconfig.tsbuildinfo +1 -7127
- package/package.json +15 -15
- package/src/Accordion/Accordion.story.tsx +5 -4
- package/src/Accordion/AccordionItem.tsx +1 -2
- package/src/ComboBox/ComboBox.story.tsx +11 -9
- package/src/ComboBox/Combobox.tsx +2 -2
- package/src/FocusLock/tabUtils.ts +12 -0
- package/src/FocusLock/useFocusLock.ts +4 -11
- package/src/List/List.story.tsx +5 -4
- package/src/Menu/Menu.story.tsx +9 -8
- package/src/Menu/Menu.tsx +1 -2
- package/src/Menu/MenuButton.tsx +3 -3
- package/src/Menu/MenuItem.tsx +4 -6
- package/src/Modal/Modal.story.tsx +34 -19
- package/src/Modal/Modal.tsx +2 -2
- package/src/Modal/NavDrawer.story.tsx +5 -4
- package/src/Popper/Popper.story.tsx +13 -16
- package/src/Popper/Popper.tsx +4 -0
- package/src/RadioButton/RadioButton.story.tsx +12 -9
- package/src/RadioButton/RadioGroup.tsx +2 -2
- package/src/Spinner/Spinner.story.tsx +5 -5
- package/src/Tabs/Tab.story.tsx +9 -8
- package/src/Tabs/TabList.tsx +9 -2
- package/src/Tooltip/Tooltip.story.tsx +6 -5
- package/src/Tooltip/useTooltip.ts +2 -3
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useAutoFocus.ts +8 -1
- package/src/hooks/useFocusReturn.ts +33 -14
- package/src/hooks/useRemoveBodyScroll.ts +10 -18
- package/src/hooks/useId.ts +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basic-ui/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38",
|
|
4
4
|
"description": "Accessible React Components used as building blocks for UI patterns",
|
|
5
5
|
"author": "Lucas Terra <lucasterra7@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,26 +15,26 @@
|
|
|
15
15
|
"sideEffects": false,
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "run -T concurrently \"yarn:build:*\"",
|
|
18
|
-
"build:dts": "tsc -p ./tsconfig.json --isolatedModules false --declaration --emitDeclarationOnly",
|
|
19
|
-
"build:cjs": "rollup -c ../../rollup.config.js",
|
|
20
|
-
"build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --extensions \".ts,.tsx,.js,.jsx\" --source-maps --out-dir ./build/esm --ignore \"**/*.story.tsx,**/*.story.ts,**/*.test.tsx,**/*.test.ts\"",
|
|
21
|
-
"build-storybook": "build-storybook -c ../../scripts/storybook -o .out",
|
|
22
|
-
"storybook": "
|
|
23
|
-
"start": "
|
|
24
|
-
"serve": "http-server .out",
|
|
25
|
-
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
|
|
26
|
-
"typecheck": "tsc --noEmit -p ./tsconfig.json",
|
|
27
|
-
"test": "jest --config ../../jest.config.js",
|
|
18
|
+
"build:dts": "run -T tsc -p ./tsconfig.json --isolatedModules false --declaration --emitDeclarationOnly",
|
|
19
|
+
"build:cjs": "run -T rollup -c ../../rollup.config.js",
|
|
20
|
+
"build:esm": "run -T cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --extensions \".ts,.tsx,.js,.jsx\" --source-maps --out-dir ./build/esm --ignore \"**/*.story.tsx,**/*.story.ts,**/*.test.tsx,**/*.test.ts\"",
|
|
21
|
+
"build-storybook": "run -T build-storybook -c ../../scripts/storybook -o .out",
|
|
22
|
+
"storybook": "run -T start-storybook -p 9001 -c ../../scripts/storybook",
|
|
23
|
+
"start": "run storybook",
|
|
24
|
+
"serve": "run -T http-server .out",
|
|
25
|
+
"lint": "run -T eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
|
|
26
|
+
"typecheck": "run -T tsc --noEmit -p ./tsconfig.json",
|
|
27
|
+
"test": "run -T jest --config ../../jest.config.js",
|
|
28
28
|
"test:watch": "yarn test --watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@popperjs/core": "^2.
|
|
31
|
+
"@popperjs/core": "^2.11.5",
|
|
32
32
|
"resize-observer-polyfill": "^1.5.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@babel/runtime": "^7.0.0",
|
|
36
|
-
"react": "
|
|
37
|
-
"react-dom": "
|
|
36
|
+
"react": "^16.14.0 || ^17.0.0 || ^18.0.0",
|
|
37
|
+
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "f3a2affbe87fb4f5e59f5528f9e3af53fc311120"
|
|
40
40
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { Accordion, AccordionBody, AccordionHeader, AccordionItem } from './';
|
|
3
|
-
import { storiesOf } from '@storybook/react';
|
|
4
3
|
import './styles.css';
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export default {
|
|
6
|
+
title: 'components/Accordion',
|
|
7
|
+
};
|
|
7
8
|
|
|
8
9
|
function AccordionControlled() {
|
|
9
10
|
const [expandedId, setExpandedId] = useState(0);
|
|
@@ -67,6 +68,6 @@ function SingleAccordionItem() {
|
|
|
67
68
|
);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
export const Controlled = () => <AccordionControlled />;
|
|
71
72
|
|
|
72
|
-
|
|
73
|
+
export const SingleAccordionControlled = () => <SingleAccordionItem />;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Fragment, forwardRef } from 'react';
|
|
1
|
+
import { Fragment, forwardRef, useId } from 'react';
|
|
2
2
|
import type * as React from 'react';
|
|
3
3
|
import { AccordionItemContextProps, AccordionItemProvider } from './context';
|
|
4
|
-
import { useId } from '../hooks';
|
|
5
4
|
|
|
6
5
|
export interface AccordionItemProps
|
|
7
6
|
extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { useMemo, useState } from 'react';
|
|
1
|
+
import { useMemo, useState, useRef } from 'react';
|
|
2
2
|
import type * as React from 'react';
|
|
3
|
-
import { storiesOf } from '@storybook/react';
|
|
4
3
|
import { ComboboxOption } from './ComboboxOption';
|
|
5
4
|
import { ComboboxList } from './ComboboxList';
|
|
6
5
|
import { ComboboxPopover } from './ComboboxPopover';
|
|
7
6
|
import { ComboboxInput } from './ComboboxInput';
|
|
8
7
|
import { ComboboxLabel } from './ComboboxLabel';
|
|
9
8
|
import { Combobox } from './Combobox';
|
|
9
|
+
import { Popper } from '../Popper';
|
|
10
10
|
import cities from './cities';
|
|
11
11
|
import './styles.css';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
export default {
|
|
14
|
+
title: 'components/Combobox',
|
|
15
|
+
};
|
|
14
16
|
|
|
15
17
|
function useCityMatch(searchTerm: string) {
|
|
16
18
|
return useMemo(() => {
|
|
@@ -108,11 +110,11 @@ export function ControlledClientSideExample({ initialValue = '' }) {
|
|
|
108
110
|
);
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
export const UncontrolledClientSide = () => <UncontrolledClientSideExample />;
|
|
114
|
+
export const UncontrolledClientSideInitial = () => (
|
|
113
115
|
<UncontrolledClientSideExample initialValue="Aberdeen" />
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
);
|
|
117
|
+
export const ControlledClientSide = () => <ControlledClientSideExample />;
|
|
118
|
+
export const ControlledClientsideInitial = () => (
|
|
117
119
|
<ControlledClientSideExample initialValue="Aberdeen" />
|
|
118
|
-
)
|
|
120
|
+
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef, useRef, useMemo } from 'react';
|
|
1
|
+
import { forwardRef, useRef, useMemo, useId } from 'react';
|
|
2
2
|
import type * as React from 'react';
|
|
3
3
|
import {
|
|
4
4
|
stateChart,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from './hooks';
|
|
10
10
|
import { ComboBoxProvider, ComboBoxContextProps } from './context';
|
|
11
11
|
import { useReducerMachine } from '../hooks/useReducerMachine';
|
|
12
|
-
import {
|
|
12
|
+
import { Scope, getScope } from '../hooks';
|
|
13
13
|
|
|
14
14
|
export type SelectEventHandler = (
|
|
15
15
|
text: string,
|
|
@@ -26,3 +26,15 @@ export const getTabblableNodes = (
|
|
|
26
26
|
|
|
27
27
|
return Array.from(parentNode.querySelectorAll(tabblable));
|
|
28
28
|
};
|
|
29
|
+
|
|
30
|
+
export function focusOnChildNode(parentNode: HTMLElement, itemIndex: 0 | -1) {
|
|
31
|
+
const elements = getTabblableNodes(parentNode);
|
|
32
|
+
if (elements.length > 0) {
|
|
33
|
+
elements[itemIndex === -1 ? elements.length - 1 : 0].focus();
|
|
34
|
+
} else {
|
|
35
|
+
const currentTabIndex = parentNode.tabIndex;
|
|
36
|
+
parentNode.tabIndex = 0;
|
|
37
|
+
parentNode.focus();
|
|
38
|
+
parentNode.tabIndex = currentTabIndex;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { focusOnChildNode } from './tabUtils';
|
|
3
3
|
|
|
4
4
|
export interface FocusLockOptions {
|
|
5
5
|
enabled: boolean;
|
|
@@ -28,23 +28,16 @@ export function useFocusLock(
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
if (event.target === lockEndRef.current) {
|
|
31
|
-
rootEl
|
|
31
|
+
focusOnChildNode(rootEl, 0);
|
|
32
32
|
} else if (event.target === lockStartRef.current) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (nodes.length > 0) {
|
|
36
|
-
const nodeToFocus = nodes.length - 1;
|
|
37
|
-
nodes[nodeToFocus].focus();
|
|
38
|
-
} else {
|
|
39
|
-
rootEl.focus();
|
|
40
|
-
}
|
|
33
|
+
focusOnChildNode(rootEl, -1);
|
|
41
34
|
} else if (
|
|
42
35
|
document !== event.target &&
|
|
43
36
|
rootEl !== event.target &&
|
|
44
37
|
!rootEl.contains(event.target as any)
|
|
45
38
|
) {
|
|
46
39
|
event.preventDefault();
|
|
47
|
-
rootEl
|
|
40
|
+
focusOnChildNode(rootEl, 0);
|
|
48
41
|
}
|
|
49
42
|
};
|
|
50
43
|
|
package/src/List/List.story.tsx
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { List, ListItem } from './';
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
2
|
// import './styles.css';
|
|
4
3
|
|
|
4
|
+
export default {
|
|
5
|
+
title: 'components/List',
|
|
6
|
+
};
|
|
7
|
+
|
|
5
8
|
const Example = () => {
|
|
6
9
|
return (
|
|
7
10
|
<List>
|
|
@@ -12,6 +15,4 @@ const Example = () => {
|
|
|
12
15
|
);
|
|
13
16
|
};
|
|
14
17
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
stories.add('controlled', () => <Example />);
|
|
18
|
+
export const Controlled = () => <Example />;
|
package/src/Menu/Menu.story.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import type * as React from 'react';
|
|
3
|
-
import { storiesOf } from '@storybook/react';
|
|
4
3
|
import { Menu, MenuButton, MenuItem, MenuList, MenuPopover } from './';
|
|
5
4
|
import { animated, useSpring } from 'react-spring';
|
|
6
5
|
import './styles.css';
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export default {
|
|
8
|
+
title: 'components/Menu',
|
|
9
|
+
};
|
|
9
10
|
|
|
10
11
|
const noop = () => {
|
|
11
12
|
// noop function to be used on onRest, as a cleanup
|
|
@@ -139,20 +140,20 @@ const MenuWithMultipleButtons = () => {
|
|
|
139
140
|
);
|
|
140
141
|
};
|
|
141
142
|
|
|
142
|
-
|
|
143
|
+
export const Controlled = () => (
|
|
143
144
|
<Wrapper>
|
|
144
145
|
<MenuControlled />
|
|
145
146
|
</Wrapper>
|
|
146
|
-
)
|
|
147
|
+
);
|
|
147
148
|
|
|
148
|
-
|
|
149
|
+
export const WithAnimationControlled = () => (
|
|
149
150
|
<Wrapper>
|
|
150
151
|
<MenuControlledWithAnimation />
|
|
151
152
|
</Wrapper>
|
|
152
|
-
)
|
|
153
|
+
);
|
|
153
154
|
|
|
154
|
-
|
|
155
|
+
export const WithMultipleButtons = () => (
|
|
155
156
|
<Wrapper>
|
|
156
157
|
<MenuWithMultipleButtons />
|
|
157
158
|
</Wrapper>
|
|
158
|
-
)
|
|
159
|
+
);
|
package/src/Menu/Menu.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { forwardRef, useRef, Fragment } from 'react';
|
|
1
|
+
import { forwardRef, useRef, Fragment, useId } from 'react';
|
|
2
2
|
import type * as React from 'react';
|
|
3
3
|
import { MenuProvider, MenuContextProps } from './context';
|
|
4
|
-
import { useId } from '../hooks/useId';
|
|
5
4
|
import { useControlledState } from '../hooks';
|
|
6
5
|
|
|
7
6
|
export interface MenuProps {
|
package/src/Menu/MenuButton.tsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
1
|
+
import { forwardRef, useId } from 'react';
|
|
2
2
|
import type * as React from 'react';
|
|
3
3
|
import { useMenuContext } from './context';
|
|
4
4
|
import { wrapEvent } from '../utils/wrapEvent';
|
|
5
|
-
import { useId } from '../hooks';
|
|
6
5
|
|
|
7
6
|
export type MenuButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
8
7
|
as?: React.ElementType<any>;
|
|
@@ -32,7 +31,8 @@ export const MenuButton = forwardRef<HTMLButtonElement, MenuButtonProps>(
|
|
|
32
31
|
onChange,
|
|
33
32
|
} = useMenuContext();
|
|
34
33
|
|
|
35
|
-
const
|
|
34
|
+
const buttonIdGenerated = useId();
|
|
35
|
+
const buttonId = preferredId || buttonIdGenerated;
|
|
36
36
|
|
|
37
37
|
const handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>) => {
|
|
38
38
|
if (disabled) {
|
package/src/Menu/MenuItem.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef, useRef } from 'react';
|
|
1
|
+
import { forwardRef, useRef, useId } from 'react';
|
|
2
2
|
import type * as React from 'react';
|
|
3
3
|
import { useMenuContext, useMenuListContext } from './context';
|
|
4
4
|
import { assignMultipleRefs } from '../utils/assignRef';
|
|
@@ -25,10 +25,10 @@ export const MenuItem = forwardRef<any, MenuItemProps>(function MenuItem(
|
|
|
25
25
|
onKeyDown,
|
|
26
26
|
...otherProps
|
|
27
27
|
} = props;
|
|
28
|
-
const {
|
|
28
|
+
const { onChange, buttonRef } = useMenuContext();
|
|
29
29
|
const { navigationItem, onNavigate } = useMenuListContext();
|
|
30
30
|
const ref = useRef<HTMLLIElement>();
|
|
31
|
-
const
|
|
31
|
+
const itemId = useId();
|
|
32
32
|
|
|
33
33
|
const isActive = ref.current && ref.current === navigationItem;
|
|
34
34
|
|
|
@@ -65,9 +65,7 @@ export const MenuItem = forwardRef<any, MenuItemProps>(function MenuItem(
|
|
|
65
65
|
return (
|
|
66
66
|
<Comp
|
|
67
67
|
ref={assignMultipleRefs(ref, forwardedRef)}
|
|
68
|
-
id={
|
|
69
|
-
disabled ? undefined : `${menuListIdRef.current}_${itemIndex.current}`
|
|
70
|
-
}
|
|
68
|
+
id={disabled ? undefined : itemId}
|
|
71
69
|
data-menu-item=""
|
|
72
70
|
data-highlighted={isActive ? '' : undefined}
|
|
73
71
|
role="menuitem"
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
2
|
import { useSpring, animated } from 'react-spring';
|
|
4
3
|
import { Modal, ModalBackdrop } from './';
|
|
5
4
|
import { Portal } from '../Portal';
|
|
6
5
|
import './styles.css';
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export default {
|
|
8
|
+
title: 'components/Modal',
|
|
9
|
+
};
|
|
9
10
|
|
|
10
11
|
const LoremIpsum = ({ numOfParagraphs = 20 }) => {
|
|
11
12
|
const content = [];
|
|
@@ -81,7 +82,7 @@ const Wrapper = ({ children }) => {
|
|
|
81
82
|
);
|
|
82
83
|
};
|
|
83
84
|
|
|
84
|
-
const
|
|
85
|
+
const SimpleModalControlledExample = () => {
|
|
85
86
|
const [open, setOpen] = useState(false);
|
|
86
87
|
|
|
87
88
|
const handleClose = () => {
|
|
@@ -90,7 +91,9 @@ const SimpleModalControlled = () => {
|
|
|
90
91
|
|
|
91
92
|
return (
|
|
92
93
|
<>
|
|
93
|
-
<button onClick={() => setOpen(!open)}>
|
|
94
|
+
<button id="open-modal" onClick={() => setOpen(!open)}>
|
|
95
|
+
Open modal
|
|
96
|
+
</button>
|
|
94
97
|
{open && (
|
|
95
98
|
<Portal>
|
|
96
99
|
<ModalBackdrop onClose={handleClose}>
|
|
@@ -106,18 +109,22 @@ const SimpleModalControlled = () => {
|
|
|
106
109
|
);
|
|
107
110
|
};
|
|
108
111
|
|
|
109
|
-
const
|
|
112
|
+
const NestedModalControlledExample = () => {
|
|
110
113
|
const [open, setOpen] = useState(false);
|
|
111
114
|
const [open2, setOpen2] = useState(false);
|
|
112
115
|
|
|
113
116
|
return (
|
|
114
117
|
<>
|
|
115
|
-
<button onClick={() => setOpen(!open)}>
|
|
118
|
+
<button id="open-modal" onClick={() => setOpen(!open)}>
|
|
119
|
+
Open modal
|
|
120
|
+
</button>
|
|
116
121
|
{open && (
|
|
117
122
|
<Portal>
|
|
118
123
|
<ModalBackdrop onClose={() => setOpen(false)}>
|
|
119
124
|
<Modal trapFocus={true}>
|
|
120
|
-
<button onClick={() => setOpen2(true)}>
|
|
125
|
+
<button id="open-another-modal" onClick={() => setOpen2(true)}>
|
|
126
|
+
Open another modal
|
|
127
|
+
</button>
|
|
121
128
|
{open2 && (
|
|
122
129
|
<Portal>
|
|
123
130
|
<ModalBackdrop onClose={() => setOpen2(false)}>
|
|
@@ -129,7 +136,13 @@ const NestedModalControlled = () => {
|
|
|
129
136
|
</Portal>
|
|
130
137
|
)}
|
|
131
138
|
<LoremIpsum numOfParagraphs={1} />
|
|
132
|
-
<button
|
|
139
|
+
<button
|
|
140
|
+
autoFocus
|
|
141
|
+
id="close-button"
|
|
142
|
+
onClick={() => setOpen(false)}
|
|
143
|
+
>
|
|
144
|
+
Close
|
|
145
|
+
</button>
|
|
133
146
|
</Modal>
|
|
134
147
|
</ModalBackdrop>
|
|
135
148
|
</Portal>
|
|
@@ -138,7 +151,7 @@ const NestedModalControlled = () => {
|
|
|
138
151
|
);
|
|
139
152
|
};
|
|
140
153
|
|
|
141
|
-
const
|
|
154
|
+
const SimpleModalControlledAnimatedExample = () => {
|
|
142
155
|
const [open, setOpen] = useState(false);
|
|
143
156
|
const [pointerEvents, setPointerEvents] = useState('none');
|
|
144
157
|
const [{ scale, opacity }, set] = useSpring(() => ({
|
|
@@ -186,7 +199,9 @@ const SimpleModalControlledAnimated = () => {
|
|
|
186
199
|
|
|
187
200
|
return (
|
|
188
201
|
<>
|
|
189
|
-
<button onClick={handleOpen}>
|
|
202
|
+
<button id="open-modal" onClick={handleOpen}>
|
|
203
|
+
Open modal
|
|
204
|
+
</button>
|
|
190
205
|
{open && (
|
|
191
206
|
<Portal>
|
|
192
207
|
<animated.div
|
|
@@ -223,20 +238,20 @@ const SimpleModalControlledAnimated = () => {
|
|
|
223
238
|
);
|
|
224
239
|
};
|
|
225
240
|
|
|
226
|
-
|
|
241
|
+
export const SimpleModalControlled = () => (
|
|
227
242
|
<Wrapper>
|
|
228
|
-
<
|
|
243
|
+
<SimpleModalControlledExample />
|
|
229
244
|
</Wrapper>
|
|
230
|
-
)
|
|
245
|
+
);
|
|
231
246
|
|
|
232
|
-
|
|
247
|
+
export const NestedModalControlled = () => (
|
|
233
248
|
<Wrapper>
|
|
234
|
-
<
|
|
249
|
+
<NestedModalControlledExample />
|
|
235
250
|
</Wrapper>
|
|
236
|
-
)
|
|
251
|
+
);
|
|
237
252
|
|
|
238
|
-
|
|
253
|
+
export const SimpleModalControlledAnimated = () => (
|
|
239
254
|
<Wrapper>
|
|
240
|
-
<
|
|
255
|
+
<SimpleModalControlledAnimatedExample />
|
|
241
256
|
</Wrapper>
|
|
242
|
-
)
|
|
257
|
+
);
|
package/src/Modal/Modal.tsx
CHANGED
|
@@ -19,7 +19,7 @@ export const Modal = forwardRef<HTMLDivElement, ModalProps>(
|
|
|
19
19
|
) => {
|
|
20
20
|
const modalRef = useRef<HTMLDivElement>(null);
|
|
21
21
|
|
|
22
|
-
useFocusReturn(trapFocus);
|
|
22
|
+
useFocusReturn(trapFocus, modalRef);
|
|
23
23
|
useRemoveBodyScroll(trapFocus);
|
|
24
24
|
useAutoFocus(trapFocus, modalRef);
|
|
25
25
|
|
|
@@ -31,7 +31,7 @@ export const Modal = forwardRef<HTMLDivElement, ModalProps>(
|
|
|
31
31
|
role="dialog"
|
|
32
32
|
aria-modal="true"
|
|
33
33
|
style={style}
|
|
34
|
-
tabIndex={
|
|
34
|
+
tabIndex={-1}
|
|
35
35
|
{...otherProps}
|
|
36
36
|
>
|
|
37
37
|
{children}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
2
|
import { useSpring, animated } from 'react-spring';
|
|
4
3
|
import { Modal, ModalBackdrop } from './';
|
|
5
4
|
import { Portal } from '../Portal';
|
|
6
5
|
import './styles.css';
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export default {
|
|
8
|
+
title: 'components/Modal/NavDrawer',
|
|
9
|
+
};
|
|
9
10
|
|
|
10
11
|
const LoremIpsum = ({ numOfParagraphs = 20 }) => {
|
|
11
12
|
const content = [];
|
|
@@ -150,8 +151,8 @@ const SimpleModalControlledAnimated = () => {
|
|
|
150
151
|
);
|
|
151
152
|
};
|
|
152
153
|
|
|
153
|
-
|
|
154
|
+
export const ControlledAnimated = () => (
|
|
154
155
|
<Wrapper>
|
|
155
156
|
<SimpleModalControlledAnimated />
|
|
156
157
|
</Wrapper>
|
|
157
|
-
)
|
|
158
|
+
);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useRef, useState, useEffect } from 'react';
|
|
2
2
|
import { useSpring, animated } from 'react-spring';
|
|
3
|
-
import { storiesOf } from '@storybook/react';
|
|
4
3
|
import { Popper } from './Popper';
|
|
5
4
|
import { PopperArrow } from './PopperArrow';
|
|
6
5
|
import './styles.css';
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export default {
|
|
8
|
+
title: 'components/Popper',
|
|
9
|
+
};
|
|
9
10
|
|
|
10
11
|
const noop = () => {
|
|
11
12
|
// noop function to be used on onRest, as a cleanup
|
|
@@ -188,7 +189,7 @@ const PopperFixedExample = ({ showAll = false, showArrow = false }) => {
|
|
|
188
189
|
);
|
|
189
190
|
};
|
|
190
191
|
|
|
191
|
-
const
|
|
192
|
+
const JumpingPopperExample = () => {
|
|
192
193
|
const [currentPopperIndex, setCurrentPopperIndex] = useState(0);
|
|
193
194
|
const ref1 = useRef();
|
|
194
195
|
const ref2 = useRef();
|
|
@@ -227,7 +228,7 @@ const JumpingPopper = () => {
|
|
|
227
228
|
);
|
|
228
229
|
};
|
|
229
230
|
|
|
230
|
-
const
|
|
231
|
+
const RerenderingPopperExample = () => {
|
|
231
232
|
const [value, setValue] = useState('');
|
|
232
233
|
const ref = useRef<HTMLButtonElement>(null);
|
|
233
234
|
return (
|
|
@@ -248,20 +249,16 @@ const RerenderingPopper = () => {
|
|
|
248
249
|
);
|
|
249
250
|
};
|
|
250
251
|
|
|
251
|
-
|
|
252
|
+
export const SinglePoint = () => <PopperExample />;
|
|
252
253
|
|
|
253
|
-
|
|
254
|
+
export const AllPoints = () => <PopperExample showAll={true} />;
|
|
254
255
|
|
|
255
|
-
|
|
256
|
-
<PopperExample showArrow={true} />
|
|
257
|
-
));
|
|
256
|
+
export const SinglePointWithArrow = () => <PopperExample showArrow={true} />;
|
|
258
257
|
|
|
259
|
-
|
|
258
|
+
export const AllPointsWithArrow = () => (
|
|
260
259
|
<PopperExample showAll={true} showArrow={true} />
|
|
261
|
-
)
|
|
260
|
+
);
|
|
262
261
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
)
|
|
266
|
-
stories.add('Re-rendering popper', () => <RerenderingPopper />);
|
|
267
|
-
stories.add('Jumping popper', () => <JumpingPopper />);
|
|
262
|
+
export const FixedPopperAllPoints = () => <PopperFixedExample showAll={true} />;
|
|
263
|
+
export const RerenderingPopper = () => <RerenderingPopperExample />;
|
|
264
|
+
export const JumpingPopper = () => <JumpingPopperExample />;
|
package/src/Popper/Popper.tsx
CHANGED
|
@@ -123,6 +123,10 @@ export const Popper = memo(
|
|
|
123
123
|
};
|
|
124
124
|
}, [anchorEl, modifiers, placement, strategy, defaultModifiers]);
|
|
125
125
|
|
|
126
|
+
useEnhancedEffect(() => {
|
|
127
|
+
popperEngineInstance.current?.forceUpdate();
|
|
128
|
+
}, [props.hidden || props['aria-hidden']]);
|
|
129
|
+
|
|
126
130
|
const contextValue: PopperContextProps = {
|
|
127
131
|
arrowRef,
|
|
128
132
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { RadioButton, RadioGroup } from './';
|
|
3
|
-
import { storiesOf } from '@storybook/react';
|
|
4
3
|
// import './styles.css';
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export default {
|
|
6
|
+
title: 'components/RadioButton',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const UncontrolledExample = (props: { initialValue?: string }) => {
|
|
7
10
|
return (
|
|
8
11
|
<RadioGroup defaultValue={props.initialValue}>
|
|
9
12
|
<label>
|
|
@@ -30,7 +33,7 @@ const Uncontrolled = (props: { initialValue?: string }) => {
|
|
|
30
33
|
);
|
|
31
34
|
};
|
|
32
35
|
|
|
33
|
-
const
|
|
36
|
+
const ControlledExample = () => {
|
|
34
37
|
const [value, setValue] = useState(undefined);
|
|
35
38
|
|
|
36
39
|
return (
|
|
@@ -64,10 +67,10 @@ const Controlled = () => {
|
|
|
64
67
|
);
|
|
65
68
|
};
|
|
66
69
|
|
|
67
|
-
const
|
|
70
|
+
export const Uncontrolled = () => <UncontrolledExample />;
|
|
71
|
+
|
|
72
|
+
export const UncontrolledWithInitialValue = () => (
|
|
73
|
+
<UncontrolledExample initialValue={'highly disagree'} />
|
|
74
|
+
);
|
|
68
75
|
|
|
69
|
-
|
|
70
|
-
stories.add('uncontrolled, initial value set', () => (
|
|
71
|
-
<Uncontrolled initialValue={'highly disagree'} />
|
|
72
|
-
));
|
|
73
|
-
stories.add('controlled', () => <Controlled />);
|
|
76
|
+
export const Controlled = () => <ControlledExample />;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
1
|
+
import { forwardRef, useId } from 'react';
|
|
2
2
|
import type * as React from 'react';
|
|
3
3
|
import { RadioGroupProvider, RadioValue } from './context';
|
|
4
|
-
import { useControlledState
|
|
4
|
+
import { useControlledState } from '../hooks';
|
|
5
5
|
|
|
6
6
|
export interface RadioGroupProps
|
|
7
7
|
extends Omit<
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { Spinner, SpinnerButton } from './';
|
|
3
|
-
import { storiesOf } from '@storybook/react';
|
|
4
3
|
import './styles.css';
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
export default {
|
|
6
|
+
title: 'components/Spinner',
|
|
7
|
+
};
|
|
7
8
|
|
|
8
9
|
const Example = ({ vertical = false }) => {
|
|
9
10
|
const [value, setValue] = useState(0);
|
|
@@ -25,6 +26,5 @@ const Example = ({ vertical = false }) => {
|
|
|
25
26
|
);
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
stories.add('vertical', () => <Example vertical={true} />);
|
|
29
|
+
export const Horizontal = () => <Example />;
|
|
30
|
+
export const Vertical = () => <Example vertical={true} />;
|