@wonderflow/react-components 10.20.0 → 11.0.1
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/core/basic.css +1 -1
- package/core.css +1 -1
- package/dist/components/accordion/accordion.test.js +0 -15
- package/dist/components/aspect-ratio/aspect-ratio.test.js +0 -15
- package/dist/components/autocomplete/autocomplete.d.ts +4 -0
- package/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/dist/components/autocomplete/autocomplete.js +2 -4
- package/dist/components/autocomplete/autocomplete.module.css +1 -1
- package/dist/components/autocomplete/autocomplete.test.js +0 -15
- package/dist/components/avatar/avatar.module.css +1 -1
- package/dist/components/avatar/avatar.test.js +0 -15
- package/dist/components/button/button.d.ts +1 -2
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.module.css +1 -1
- package/dist/components/button/button.stories.d.ts +4 -4
- package/dist/components/button/button.stories.d.ts.map +1 -1
- package/dist/components/button/button.test.js +0 -15
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/card.js +1 -1
- package/dist/components/card/card.module.css +1 -1
- package/dist/components/card/card.test.js +0 -15
- package/dist/components/chip/chip.module.css +1 -1
- package/dist/components/chip/chip.test.js +0 -15
- package/dist/components/circular-progress/circular-progress.test.js +0 -15
- package/dist/components/clamp-text/clamp-text.test.js +0 -15
- package/dist/components/container/container.d.ts +1 -1
- package/dist/components/container/container.d.ts.map +1 -1
- package/dist/components/container/container.module.css +1 -1
- package/dist/components/container/container.stories.d.ts +4 -5
- package/dist/components/container/container.stories.d.ts.map +1 -1
- package/dist/components/container/container.stories.js +11 -14
- package/dist/components/container/container.test.js +0 -15
- package/dist/components/datetime/datetime.test.js +0 -15
- package/dist/components/disclosure/disclosure.module.css +1 -1
- package/dist/components/disclosure/disclosure.test.d.ts.map +1 -1
- package/dist/components/disclosure/disclosure.test.js +0 -15
- package/dist/components/elevator/elevator.test.js +0 -15
- package/dist/components/expander/expander.test.js +0 -15
- package/dist/components/grid/grid.test.js +0 -15
- package/dist/components/info-state/info-state.d.ts.map +1 -1
- package/dist/components/info-state/info-state.js +1 -9
- package/dist/components/info-state/info-state.module.css +1 -1
- package/dist/components/info-state/info-state.stories.d.ts +31 -31
- package/dist/components/info-state/info-state.stories.d.ts.map +1 -1
- package/dist/components/info-state/info-state.stories.js +5 -5
- package/dist/components/info-state/info-state.test.js +0 -15
- package/dist/components/input-group/input-group.test.js +0 -15
- package/dist/components/linear-progress/linear-progress.module.css +1 -1
- package/dist/components/linear-progress/linear-progress.test.js +0 -15
- package/dist/components/list/list.module.css +1 -1
- package/dist/components/list/list.test.js +0 -15
- package/dist/components/masonry/masonry.test.js +0 -15
- package/dist/components/menu/menu-item/menu-item.d.ts.map +1 -1
- package/dist/components/menu/menu-item/menu-item.js +3 -1
- package/dist/components/menu/menu-item/menu-item.module.css +1 -1
- package/dist/components/menu/menu-item/menu-item.stories.d.ts.map +1 -1
- package/dist/components/menu/menu-item/menu-item.stories.js +1 -0
- package/dist/components/menu/menu.test.js +0 -15
- package/dist/components/modal/content/modal-content.d.ts +7 -8
- package/dist/components/modal/content/modal-content.d.ts.map +1 -1
- package/dist/components/modal/content/modal-content.js +3 -7
- package/dist/components/modal/content/modal-content.module.css +1 -1
- package/dist/components/modal/footer/modal-footer.d.ts +32 -0
- package/dist/components/modal/footer/modal-footer.d.ts.map +1 -0
- package/dist/components/modal/footer/modal-footer.js +22 -0
- package/dist/components/modal/footer/modal-footer.module.css +1 -0
- package/dist/components/modal/header/modal-header.d.ts +20 -0
- package/dist/components/modal/header/modal-header.d.ts.map +1 -0
- package/dist/components/modal/header/modal-header.js +26 -0
- package/dist/components/modal/header/modal-header.module.css +1 -0
- package/dist/components/modal/modal.d.ts +79 -7
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/modal/modal.js +16 -6
- package/dist/components/modal/modal.module.css +1 -1
- package/dist/components/modal/modal.stories.d.ts +69 -5
- package/dist/components/modal/modal.stories.d.ts.map +1 -1
- package/dist/components/modal/modal.stories.js +145 -10
- package/dist/components/modal/modal.test.d.ts +2 -0
- package/dist/components/modal/modal.test.d.ts.map +1 -0
- package/dist/components/modal/modal.test.js +60 -0
- package/dist/components/overlay-container/overlay-container.test.d.ts +2 -0
- package/dist/components/overlay-container/overlay-container.test.d.ts.map +1 -0
- package/dist/components/overlay-container/overlay-container.test.js +19 -0
- package/dist/components/pagination/pagination.test.js +0 -15
- package/dist/components/popover/popover.d.ts +4 -0
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/popover/popover.js +6 -8
- package/dist/components/popover/popover.module.css +1 -1
- package/dist/components/popover/popover.stories.d.ts +13 -9
- package/dist/components/popover/popover.stories.d.ts.map +1 -1
- package/dist/components/popover/popover.stories.js +8 -2
- package/dist/components/popover/popover.test.js +0 -15
- package/dist/components/prose/prose.test.js +0 -15
- package/dist/components/select/select.js +1 -1
- package/dist/components/select/select.module.css +1 -1
- package/dist/components/select/select.test.js +0 -15
- package/dist/components/selection-controls/selection-controls.test.js +0 -15
- package/dist/components/separator/separator.test.js +0 -15
- package/dist/components/skeleton/skeleton.test.js +0 -15
- package/dist/components/slider/slider.test.js +0 -15
- package/dist/components/snackbar/snackbar.test.js +0 -15
- package/dist/components/spinner/spinner.test.js +0 -15
- package/dist/components/split-button/split-button.test.js +0 -15
- package/dist/components/stack/stack.test.js +0 -15
- package/dist/components/star-meter/star-meter.module.css +1 -1
- package/dist/components/star-meter/star-meter.test.js +0 -15
- package/dist/components/symbol/symbol.test.js +0 -15
- package/dist/components/tab/tab.js +1 -1
- package/dist/components/tab/tab.module.css +1 -1
- package/dist/components/tab/tab.stories.d.ts +1 -0
- package/dist/components/tab/tab.stories.d.ts.map +1 -1
- package/dist/components/tab/tab.stories.js +4 -17
- package/dist/components/tab/tab.test.js +0 -15
- package/dist/components/table/table-cell/table-cell.test.js +0 -15
- package/dist/components/table/table-checkbox/table-checkbox.test.js +0 -15
- package/dist/components/table/table-controls/table-controls.test.js +0 -15
- package/dist/components/table/table-header/table-header.test.js +0 -15
- package/dist/components/table/table-pagination/table-pagination.test.js +0 -15
- package/dist/components/table/table-row/table-row.test.js +0 -15
- package/dist/components/table/table.module.css +1 -1
- package/dist/components/table/table.stories.d.ts.map +1 -1
- package/dist/components/table/table.stories.js +1 -0
- package/dist/components/table/table.test.js +0 -15
- package/dist/components/text/text.module.css +1 -1
- package/dist/components/text/text.test.js +0 -15
- package/dist/components/textfield/textfield.module.css +1 -1
- package/dist/components/textfield/textfield.test.js +0 -15
- package/dist/components/title/title.module.css +1 -1
- package/dist/components/title/title.test.js +0 -15
- package/dist/components/toggle-button/toggle-button.test.js +0 -15
- package/dist/components/tooltip/tooltip.d.ts +4 -0
- package/dist/components/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/tooltip/tooltip.js +2 -4
- package/dist/components/tooltip/tooltip.module.css +1 -1
- package/dist/components/tooltip/tooltip.stories.d.ts +1 -1
- package/dist/components/tooltip/tooltip.stories.d.ts.map +1 -1
- package/dist/components/tooltip/tooltip.stories.js +4 -3
- package/dist/components/tooltip/tooltip.test.js +0 -15
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/useBreakpoints.d.ts +11 -0
- package/dist/hooks/useBreakpoints.d.ts.map +1 -0
- package/dist/hooks/useBreakpoints.js +84 -0
- package/dist/hooks/useBreakpoints.test.d.ts +2 -0
- package/dist/hooks/useBreakpoints.test.d.ts.map +1 -0
- package/dist/hooks/useBreakpoints.test.js +35 -0
- package/dist/hooks/useBreakpointsConfig.d.ts +12 -0
- package/dist/hooks/useBreakpointsConfig.d.ts.map +1 -0
- package/dist/hooks/useBreakpointsConfig.js +31 -0
- package/dist/hooks/useBreakpointsConfig.test.d.ts +2 -0
- package/dist/hooks/useBreakpointsConfig.test.d.ts.map +1 -0
- package/dist/hooks/useBreakpointsConfig.test.js +16 -0
- package/dist/hooks/useSSR.d.ts +5 -0
- package/dist/hooks/useSSR.d.ts.map +1 -0
- package/dist/hooks/useSSR.js +24 -0
- package/dist/hooks/useSSR.test.d.ts +2 -0
- package/dist/hooks/useSSR.test.d.ts.map +1 -0
- package/dist/hooks/useSSR.test.js +11 -0
- package/dist/providers/providers.test.js +11 -17
- package/package.json +5 -4
- package/dist/hooks/usePopupWrapper.d.ts +0 -4
- package/dist/hooks/usePopupWrapper.d.ts.map +0 -1
- package/dist/hooks/usePopupWrapper.js +0 -42
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Wonderflow Design Team
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
2
|
import { render } from '@testing-library/react';
|
|
18
3
|
import { Table } from './table';
|
|
19
4
|
const DATA = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.Text{font-size:var(--fs-max);max-inline-size:var(--max-w,initial);min-block-size:.01vh;text-align:var(--t-align)}.Text[data-text-dimmed="5"]{color:var(--dimmed-5)}.Text[data-text-dimmed="6"]{color:var(--dimmed-6)}.Text[data-text-dimmed="7"]{color:var(--dimmed-7)}.Text[data-text-sentiment=positive]{color:var(--highlight-green-foreground)}.Text[data-text-sentiment=informative]{color:var(--highlight-blue-foreground)}.Text[data-text-sentiment=danger]{color:var(--highlight-red-foreground)}.Text[data-text-sentiment=warning]{color:var(--highlight-yellow-foreground)}.Text[data-text-size="14"]{--fs-min:0.
|
|
1
|
+
@layer components{.Text{font-size:var(--fs-max);max-inline-size:var(--max-w,initial);min-block-size:.01vh;text-align:var(--t-align)}.Text[data-text-dimmed="5"]{color:var(--dimmed-5)}.Text[data-text-dimmed="6"]{color:var(--dimmed-6)}.Text[data-text-dimmed="7"]{color:var(--dimmed-7)}.Text[data-text-sentiment=positive]{color:var(--highlight-green-foreground)}.Text[data-text-sentiment=informative]{color:var(--highlight-blue-foreground)}.Text[data-text-sentiment=danger]{color:var(--highlight-red-foreground)}.Text[data-text-sentiment=warning]{color:var(--highlight-yellow-foreground)}.Text[data-text-size="14"]{--fs-min:0.875rem;--fs-max:0.875rem}.Text[data-text-size="16"]{--fs-min:0.875rem;--fs-max:1.000rem}.Text[data-text-size="18"]{--fs-min:1.000rem;--fs-max:1.125rem}.Text[data-text-size="22"]{--fs-min:1.125rem;--fs-max:1.375rem}.Text[data-text-size="28"]{--fs-min:1.375rem;--fs-max:1.750rem}.Text[data-text-weight=thin]{font-weight:100}.Text[data-text-weight=bold]{font-weight:600}.Text[data-text-responsive=true]{font-size:var(--fs-min)}@media (min-width:48em){.Text[data-text-responsive=true]{font-size:var(--fs-max)}}.Text[data-text-line-height=none]{line-height:1}.Text[data-text-line-height=small]{line-height:1.2}.Text[data-text-line-height=large]{line-height:1.5}}
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Wonderflow Design Team
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
2
|
import { render } from '@testing-library/react';
|
|
18
3
|
import { Text } from './text';
|
|
19
4
|
describe('<Text>', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.Textfield{appearance:none;padding:0;position:relative}.Textfield[data-textfield-dimension=small]{--field-height:1.
|
|
1
|
+
@layer components{.Textfield{appearance:none;padding:0;position:relative}.Textfield[data-textfield-dimension=small]{--field-height:1.500rem;--field-padding:0.33rem;--font-size:0.875rem}.Textfield[data-textfield-dimension=regular]{--field-height:2.500rem;--field-padding:1.000rem;--font-size:1.000rem}.Textfield[data-textfield-dimension=big]{--field-height:3.000rem;--field-padding:1.000rem;--font-size:1.125rem}.Textfield[data-textfield-fullwidth=true]{inline-size:100%}.FieldContainer{position:relative}.InputField{--factor:4}[data-textfield-has-icon=true][data-textfield-icon-position=right] .InputField{padding:0 calc(var(--field-padding)*var(--factor)) 0 var(--field-padding)}[data-textfield-has-icon=true][data-textfield-icon-position=left] .InputField{padding:0 var(--field-padding) 0 calc(var(--field-padding)*var(--factor))}[data-textfield-dimension*=big] .InputField,[data-textfield-dimension*=regular] .InputField{--factor:3}.Icon{border-radius:.25rem;pointer-events:none;position:absolute;top:50%;transform:translateY(-50%)}[data-textfield-icon-position=left] .Icon{left:var(--field-padding);right:auto}[data-textfield-icon-position=right] .Icon{left:auto;right:var(--field-padding)}.Textfield[data-textfield-invalid=true] .Icon{fill:var(--highlight-red-foreground)}.InputField:invalid+.Icon{fill:var(--highlight-red-foreground)}.Label[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}}@layer overrides{.IconButton{--x:25%;outline-offset:-.25em;position:absolute;top:50%;transform:translateY(-50%) translateX(var(--x))}.IconButton[data-button-kind=flat]:is(:hover,:active,:focus,[data-button-disabled=true]){-webkit-backdrop-filter:none;backdrop-filter:none;background-color:transparent}[data-textfield-icon-position=left] .IconButton{--x:-19%;left:var(--field-padding);right:auto}[data-textfield-icon-position=right] .IconButton{left:auto;right:var(--field-padding)}.Textfield[data-textfield-invalid=true] .IconButton{color:var(--highlight-red-foreground)}}
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Wonderflow Design Team
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
2
|
import { fireEvent, render } from '@testing-library/react';
|
|
18
3
|
import { Textfield } from './textfield';
|
|
19
4
|
describe('<Textfield>', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.Title:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){--lh:1.5;color:var(--heading-foreground,var(--dimmed-9));display:block;font-size:var(--fs-max);line-height:1.2;max-inline-size:var(--max-w,initial);min-block-size:.01vh;overflow-wrap:break-word;text-align:var(--t-align)}.Title[data-title-line-height=small]:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){--lh:1.2}.Title[data-title-line-height=large]:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){line-height:1.5}.Title:is(.H6){--fs-min:0.
|
|
1
|
+
@layer components{.Title:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){--lh:1.5;color:var(--heading-foreground,var(--dimmed-9));display:block;font-size:var(--fs-max);line-height:1.2;max-inline-size:var(--max-w,initial);min-block-size:.01vh;overflow-wrap:break-word;text-align:var(--t-align)}.Title[data-title-line-height=small]:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){--lh:1.2}.Title[data-title-line-height=large]:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){line-height:1.5}.Title:is(.H6){--fs-min:0.875rem;--fs-max:1.125rem;font-weight:700}.Title:is(.H5){--fs-min:1rem;--fs-max:1.33rem;font-weight:700}.Title:is(.H5):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H4){--fs-min:1.33rem;--fs-max:1.77rem;font-weight:700}.Title:is(.H4):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H3){--fs-min:1.77rem;--fs-max:2.37rem;font-weight:800}.Title:is(.H3):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H2){--fs-min:2.37rem;--fs-max:3.16rem;font-weight:800}.Title:is(.H2):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H1){--fs-min:3.16rem;--fs-max:4.2rem;font-weight:800}.Title:is(.H1):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title.Display{--fs-min:4.2rem;--fs-max:5.6rem;font-weight:800}.Title.Display:before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title[data-title-responsive=true]{font-size:var(--fs-min)}@media (min-width:48em){.Title[data-title-responsive=true]{font-size:var(--fs-max)}}}@layer overrides{.Anchor{align-items:center;background-color:var(--highlight-cyan-background);background-image:none;block-size:max(16px,.6em);border-radius:.5rem;color:var(--heading-foreground,var(--dimmed-9));display:inline-flex;inline-size:max(16px,.6em);justify-content:center;line-height:1;margin-left:.2em;padding:.1em;visibility:hidden}.Title:focus-within .Anchor,.Title:hover .Anchor{visibility:visible}.Anchor svg{height:100%;width:100%}}
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Wonderflow Design Team
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
2
|
import { render } from '@testing-library/react';
|
|
18
3
|
import { Text } from '../text';
|
|
19
4
|
import { Title } from './title';
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Wonderflow Design Team
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
2
|
import { fireEvent, render } from '@testing-library/react';
|
|
18
3
|
import { ToggleButton } from './toggle-button';
|
|
19
4
|
describe('<ToggleButton>', () => {
|
|
@@ -40,6 +40,10 @@ export declare type TooltipProps = {
|
|
|
40
40
|
* Set the trigger container to behave like inline or block element
|
|
41
41
|
*/
|
|
42
42
|
fill?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Set the root element to render the Tooltip into.
|
|
45
|
+
*/
|
|
46
|
+
root?: HTMLElement;
|
|
43
47
|
};
|
|
44
48
|
export declare const Tooltip: FCChildrenClass<TooltipProps>;
|
|
45
49
|
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/tooltip.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEtF,OAAO,EACgE,SAAS,EAC/E,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/tooltip.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEtF,OAAO,EACgE,SAAS,EAC/E,MAAM,OAAO,CAAC;AASf,oBAAY,YAAY,GAAG;IACzB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAC/D;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,eAAe,CAAC,YAAY,CAoFjD,CAAC"}
|
|
@@ -5,15 +5,13 @@ import { createPortal } from 'react-dom';
|
|
|
5
5
|
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
6
6
|
import { useUIDSeed } from 'react-uid';
|
|
7
7
|
import { Elevator } from '../..';
|
|
8
|
-
import { usePopUpWrapper } from '../../hooks';
|
|
9
8
|
import * as styles from './tooltip.module.css';
|
|
10
|
-
export const Tooltip = ({ children, trigger, placement = 'bottom-start', open, style, maxWidth = '40ch', fill = false, interactive = false, delay = 500, }) => {
|
|
9
|
+
export const Tooltip = ({ children, trigger, placement = 'bottom-start', open, style, maxWidth = '40ch', fill = false, interactive = false, delay = 500, root = document.body, }) => {
|
|
11
10
|
const [isOpen, setIsOpen] = useState(false);
|
|
12
11
|
const seedID = useUIDSeed();
|
|
13
12
|
const id = seedID('tooltip-content');
|
|
14
13
|
const tooltipContainerRef = useRef(null);
|
|
15
14
|
useKeyPress('esc', () => setIsOpen(false));
|
|
16
|
-
const { wrapper } = usePopUpWrapper('tooltip-popup-root');
|
|
17
15
|
const { getArrowProps, getTooltipProps, setTooltipRef, setTriggerRef,
|
|
18
16
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
19
17
|
visible, } = usePopperTooltip({
|
|
@@ -45,5 +43,5 @@ export const Tooltip = ({ children, trigger, placement = 'bottom-start', open, s
|
|
|
45
43
|
ref: setTriggerRef,
|
|
46
44
|
tabIndex: 0,
|
|
47
45
|
'aria-describedby': id,
|
|
48
|
-
})), visible && createPortal(_jsx(Elevator, { resting: 1, children: _jsxs("div", { ref: setTooltipRef, role: "tooltip", id: id, "data-theme": "dark", ...getTooltipProps({ className: styles.Balloon, style: dynamycStyle }), children: [children, _jsx("div", { ...getArrowProps({ className: styles.Arrow }) })] }) }),
|
|
46
|
+
})), visible && createPortal(_jsx(Elevator, { resting: 1, children: _jsxs("div", { ref: setTooltipRef, role: "tooltip", id: id, "data-theme": "dark", ...getTooltipProps({ className: styles.Balloon, style: dynamycStyle }), children: [children, _jsx("div", { ...getArrowProps({ className: styles.Arrow }) })] }) }), root)] }));
|
|
49
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.Tooltip{display:contents}.Balloon{word-wrap:break-word;background-color:#31363f;border-radius:.25rem;font-size:1rem;max-inline-size:var(--max-w);padding:.5rem 1rem;position:relative;z-index:
|
|
1
|
+
@layer components{.Tooltip{display:contents}.Balloon{word-wrap:break-word;background-color:#31363f;border-radius:.25rem;font-size:1rem;max-inline-size:var(--max-w);padding:.5rem 1rem;position:relative;z-index:5}.Balloon[data-popper-reference-hidden=true]{pointer-events:none;visibility:hidden}.Arrow:before{background-color:#31363f;block-size:12px;content:"";inline-size:12px;position:absolute;transform:rotate(45deg);visibility:visible}.Balloon[data-popper-reference-hidden=true] .Arrow{pointer-events:none;visibility:hidden}.Balloon[data-popper-placement^=top] .Arrow{bottom:6px}.Balloon[data-popper-placement^=top] .Arrow:before{transform:translateX(-50%) rotate(45deg)}.Balloon[data-popper-placement^=left] .Arrow{right:6px}.Balloon[data-popper-placement^=left] .Arrow:before{transform:translateY(-50%) rotate(45deg)}.Balloon[data-popper-placement^=bottom] .Arrow{top:-6px}.Balloon[data-popper-placement^=bottom] .Arrow:before{transform:translateX(-50%) rotate(45deg)}.Balloon[data-popper-placement^=right] .Arrow{left:-6px}.Balloon[data-popper-placement^=right] .Arrow:before{transform:translateY(-50%) rotate(45deg)}}
|
|
@@ -5,5 +5,5 @@ export default story;
|
|
|
5
5
|
export declare const Interactive: ComponentStory<FCChildrenClass<import("./tooltip").TooltipProps>>;
|
|
6
6
|
export declare const NonInteractive: ComponentStory<FCChildrenClass<import("./tooltip").TooltipProps>>;
|
|
7
7
|
export declare const Open: ComponentStory<FCChildrenClass<import("./tooltip").TooltipProps>>;
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const WithButton: ComponentStory<FCChildrenClass<import("./tooltip").TooltipProps>>;
|
|
9
9
|
//# sourceMappingURL=tooltip.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.stories.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/tooltip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIjE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,OAAO,CAiBxC,CAAC;AAEF,eAAe,KAAK,CAAC;AAoCrB,eAAO,MAAM,WAAW,mEAAoB,CAAC;AAK7C,eAAO,MAAM,cAAc,mEAAqB,CAAC;AAMjD,eAAO,MAAM,IAAI,mEAAoB,CAAC;AAMtC,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"tooltip.stories.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/tooltip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIjE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,OAAO,CAiBxC,CAAC;AAEF,eAAe,KAAK,CAAC;AAoCrB,eAAO,MAAM,WAAW,mEAAoB,CAAC;AAK7C,eAAO,MAAM,cAAc,mEAAqB,CAAC;AAMjD,eAAO,MAAM,IAAI,mEAAoB,CAAC;AAMtC,eAAO,MAAM,UAAU,mEAAqB,CAAC"}
|
|
@@ -43,8 +43,9 @@ Open.args = {
|
|
|
43
43
|
interactive: true,
|
|
44
44
|
open: true,
|
|
45
45
|
};
|
|
46
|
-
export const
|
|
47
|
-
|
|
48
|
-
trigger: _jsx(Button, { children: "
|
|
46
|
+
export const WithButton = Template2.bind({});
|
|
47
|
+
WithButton.args = {
|
|
48
|
+
trigger: _jsx(Button, { children: "Click Me" }),
|
|
49
|
+
placement: 'top-end',
|
|
49
50
|
interactive: true,
|
|
50
51
|
};
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Wonderflow Design Team
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
2
|
import { fireEvent, render } from '@testing-library/react';
|
|
18
3
|
import { Button } from '../button';
|
|
19
4
|
import { Tooltip } from './tooltip';
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -13,4 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export {
|
|
16
|
+
export { useBreakpoints } from './useBreakpoints';
|
|
17
|
+
export { useBreakpointsConfig } from './useBreakpointsConfig';
|
|
18
|
+
export { useSSR } from './useSSR';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
export declare type BreakpointsNames = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
3
|
+
export declare type Breakpoints<T> = Record<BreakpointsNames, T>;
|
|
4
|
+
export declare type BreakpointsSettings = Breakpoints<number>;
|
|
5
|
+
export declare type BreakpointsValues = Breakpoints<boolean>;
|
|
6
|
+
export declare const useBreakpoints: (target?: MutableRefObject<HTMLElement | null>, settings?: BreakpointsSettings) => {
|
|
7
|
+
breakpoints: BreakpointsValues;
|
|
8
|
+
matches: BreakpointsNames;
|
|
9
|
+
size: number;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useBreakpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBreakpoints.d.ts","sourceRoot":"","sources":["../../src/hooks/useBreakpoints.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,gBAAgB,EACjB,MAAM,OAAO,CAAC;AAIf,oBAAY,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAE/D,oBAAY,WAAW,CAAC,CAAC,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAA;AAExD,oBAAY,mBAAmB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;AAErD,oBAAY,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;AAkBpD,eAAO,MAAM,cAAc,YAChB,iBAAiB,WAAW,GAAG,IAAI,CAAC,aACnC,mBAAmB;;;;CA6D9B,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Wonderflow Design Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { useSize } from 'ahooks';
|
|
17
|
+
import { useEffect, useState, } from 'react';
|
|
18
|
+
import { useSSR } from './useSSR';
|
|
19
|
+
const DefaultBreakpointsSettings = {
|
|
20
|
+
xs: 480,
|
|
21
|
+
sm: 768,
|
|
22
|
+
md: 960,
|
|
23
|
+
lg: 1280,
|
|
24
|
+
xl: 1600,
|
|
25
|
+
};
|
|
26
|
+
const DefaultBreakpointsValues = {
|
|
27
|
+
xs: false,
|
|
28
|
+
sm: false,
|
|
29
|
+
md: false,
|
|
30
|
+
lg: false,
|
|
31
|
+
xl: false,
|
|
32
|
+
};
|
|
33
|
+
export const useBreakpoints = (target, settings = DefaultBreakpointsSettings) => {
|
|
34
|
+
const { isBrowser } = useSSR();
|
|
35
|
+
const [breakpoints, setBreakpoints] = useState(DefaultBreakpointsValues);
|
|
36
|
+
const [matches, setMatches] = useState('xs');
|
|
37
|
+
const [windowSize, setWindowSize] = useState(0);
|
|
38
|
+
const size = useSize(target);
|
|
39
|
+
const targetBreakpoints = (size?.width) ? {
|
|
40
|
+
xs: size.width <= settings.xs,
|
|
41
|
+
sm: size.width > settings.xs && size.width <= settings.sm,
|
|
42
|
+
md: size.width > settings.sm && size.width <= settings.md,
|
|
43
|
+
lg: size.width > settings.md && size.width <= settings.lg,
|
|
44
|
+
xl: size.width > settings.lg,
|
|
45
|
+
} : undefined;
|
|
46
|
+
const targetMatches = targetBreakpoints
|
|
47
|
+
&& Object.keys(targetBreakpoints)
|
|
48
|
+
.filter(k => (targetBreakpoints[k]))[0];
|
|
49
|
+
const handleResize = () => {
|
|
50
|
+
if (isBrowser) {
|
|
51
|
+
const w = window.innerWidth;
|
|
52
|
+
const v = {
|
|
53
|
+
xs: w <= settings.xs,
|
|
54
|
+
sm: w > settings.xs && w <= settings.sm,
|
|
55
|
+
md: w > settings.sm && w <= settings.md,
|
|
56
|
+
lg: w > settings.md && w <= settings.lg,
|
|
57
|
+
xl: w > settings.lg,
|
|
58
|
+
};
|
|
59
|
+
const b = Object.keys(v).filter(k => (v[k]))[0];
|
|
60
|
+
setMatches(b);
|
|
61
|
+
setBreakpoints(v);
|
|
62
|
+
setWindowSize(window.innerWidth);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (isBrowser) {
|
|
67
|
+
handleResize();
|
|
68
|
+
window.addEventListener('resize', handleResize);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
setBreakpoints(DefaultBreakpointsValues);
|
|
72
|
+
}
|
|
73
|
+
return () => {
|
|
74
|
+
if (isBrowser)
|
|
75
|
+
window.removeEventListener('resize', handleResize);
|
|
76
|
+
};
|
|
77
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
|
+
}, []);
|
|
79
|
+
return {
|
|
80
|
+
breakpoints: targetBreakpoints ?? breakpoints,
|
|
81
|
+
matches: (targetMatches ?? matches),
|
|
82
|
+
size: size?.width ?? windowSize,
|
|
83
|
+
};
|
|
84
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBreakpoints.test.d.ts","sourceRoot":"","sources":["../../src/hooks/useBreakpoints.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { renderHook } from '@testing-library/react-hooks';
|
|
2
|
+
import { useBreakpoints } from './useBreakpoints';
|
|
3
|
+
describe('useBreakpoints()', () => {
|
|
4
|
+
test('it should return defined values as default', () => {
|
|
5
|
+
const { result } = renderHook(() => useBreakpoints());
|
|
6
|
+
const { breakpoints, matches, size } = result.current;
|
|
7
|
+
const w = window?.innerWidth;
|
|
8
|
+
expect(breakpoints).toBeDefined();
|
|
9
|
+
expect(matches).toBeDefined();
|
|
10
|
+
expect(size).toBe(w);
|
|
11
|
+
});
|
|
12
|
+
test('it should return defined values with custom settings', () => {
|
|
13
|
+
const custom = {
|
|
14
|
+
xs: 576,
|
|
15
|
+
sm: 768,
|
|
16
|
+
md: 992,
|
|
17
|
+
lg: 1200,
|
|
18
|
+
xl: 1400,
|
|
19
|
+
};
|
|
20
|
+
const { result } = renderHook(() => useBreakpoints(undefined, custom));
|
|
21
|
+
const { breakpoints, matches, size } = result.current;
|
|
22
|
+
const w = window?.innerWidth;
|
|
23
|
+
expect(breakpoints).toBeDefined();
|
|
24
|
+
expect(matches).toBeDefined();
|
|
25
|
+
expect(size).toBe(w);
|
|
26
|
+
});
|
|
27
|
+
test('it should return default values', () => {
|
|
28
|
+
const { result } = renderHook(() => useBreakpoints());
|
|
29
|
+
const { breakpoints, matches, size } = result.current;
|
|
30
|
+
const w = window?.innerWidth;
|
|
31
|
+
expect(breakpoints).toBeDefined();
|
|
32
|
+
expect(matches).toBeDefined();
|
|
33
|
+
expect(size).toBe(w);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
import { BreakpointsNames, BreakpointsSettings } from './useBreakpoints';
|
|
3
|
+
export declare type BreakpointsConfig<T> = Partial<Record<BreakpointsNames, T>> & {
|
|
4
|
+
fallback: T;
|
|
5
|
+
};
|
|
6
|
+
export declare const useBreakpointsConfig: <T>(config: BreakpointsConfig<T>, target?: MutableRefObject<HTMLElement | null>, settings?: BreakpointsSettings) => {
|
|
7
|
+
value: T;
|
|
8
|
+
matches: BreakpointsNames;
|
|
9
|
+
breakpoints: import("./useBreakpoints").BreakpointsValues;
|
|
10
|
+
size: number;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useBreakpointsConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBreakpointsConfig.d.ts","sourceRoot":"","sources":["../../src/hooks/useBreakpointsConfig.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAkB,MAAM,kBAAkB,CAAC;AAEzF,oBAAY,iBAAiB,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,GAAG;IAAE,QAAQ,EAAE,CAAC,CAAA;CAAE,CAAA;AAEzF,eAAO,MAAM,oBAAoB,6CAEtB,iBAAiB,WAAW,GAAG,IAAI,CAAC,aAClC,mBAAmB;;;;;CAkB/B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Wonderflow Design Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { useEffect, useState } from 'react';
|
|
17
|
+
import { useBreakpoints } from './useBreakpoints';
|
|
18
|
+
export const useBreakpointsConfig = (config, target, settings) => {
|
|
19
|
+
const { fallback } = config;
|
|
20
|
+
const [value, setValue] = useState(fallback);
|
|
21
|
+
const { matches, breakpoints, size, } = useBreakpoints(target, settings);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
setValue(config[matches] ?? fallback);
|
|
24
|
+
}, [matches, config, fallback]);
|
|
25
|
+
return ({
|
|
26
|
+
value,
|
|
27
|
+
matches,
|
|
28
|
+
breakpoints,
|
|
29
|
+
size,
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBreakpointsConfig.test.d.ts","sourceRoot":"","sources":["../../src/hooks/useBreakpointsConfig.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { renderHook } from '@testing-library/react-hooks';
|
|
2
|
+
import { useBreakpointsConfig } from './useBreakpointsConfig';
|
|
3
|
+
describe('useBreakpointsConfig()', () => {
|
|
4
|
+
test('it should return fallback value', () => {
|
|
5
|
+
const v = {
|
|
6
|
+
fallback: { answer: '42' },
|
|
7
|
+
};
|
|
8
|
+
const { result } = renderHook(() => useBreakpointsConfig(v));
|
|
9
|
+
const { breakpoints, matches, size, value, } = result.current;
|
|
10
|
+
const w = window?.innerWidth;
|
|
11
|
+
expect(breakpoints).toBeDefined();
|
|
12
|
+
expect(matches).toBeDefined();
|
|
13
|
+
expect(size).toBe(w);
|
|
14
|
+
expect(value.answer).toBe('42');
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSSR.d.ts","sourceRoot":"","sources":["../../src/hooks/useSSR.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,MAAM;;;CASlB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Wonderflow Design Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export const useSSR = () => {
|
|
17
|
+
const isBrowser = typeof window !== 'undefined'
|
|
18
|
+
&& window.document
|
|
19
|
+
&& window.document.documentElement;
|
|
20
|
+
return {
|
|
21
|
+
isBrowser: !!isBrowser,
|
|
22
|
+
isServer: !isBrowser,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSSR.test.d.ts","sourceRoot":"","sources":["../../src/hooks/useSSR.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { renderHook } from '@testing-library/react-hooks';
|
|
2
|
+
import { useSSR } from './useSSR';
|
|
3
|
+
describe('useSSR()', () => {
|
|
4
|
+
test('it should return true in Browser', () => {
|
|
5
|
+
const { result } = renderHook(() => useSSR());
|
|
6
|
+
const d = window?.document;
|
|
7
|
+
expect(d).toBeTruthy();
|
|
8
|
+
expect(result.current.isBrowser).toBe(true);
|
|
9
|
+
expect(result.current.isServer).not.toBe(true);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Wonderflow Design Team
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
2
|
import { render } from '@testing-library/react';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
3
|
+
import { renderHook } from '@testing-library/react-hooks';
|
|
4
|
+
import { OverlayProvider, useOverlayContext } from './overlay';
|
|
5
|
+
import { ResponsiveProvider, useResponsiveContext } from './responsive';
|
|
20
6
|
describe('<Providers>', () => {
|
|
21
7
|
test('OverlayProvider should render properly', () => {
|
|
22
8
|
const { container } = render(_jsx(OverlayProvider, { children: "Content" }));
|
|
@@ -31,4 +17,12 @@ describe('<Providers>', () => {
|
|
|
31
17
|
const { container } = render(_jsx(ResponsiveProvider, { children: "Content" }));
|
|
32
18
|
expect(container).not.toBeNull();
|
|
33
19
|
});
|
|
20
|
+
test('useResponsiveContext', () => {
|
|
21
|
+
const { result } = renderHook(() => useResponsiveContext());
|
|
22
|
+
expect(result).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
test('useOverlayContext', () => {
|
|
25
|
+
const { result } = renderHook(() => useOverlayContext());
|
|
26
|
+
expect(result).toBeDefined();
|
|
27
|
+
});
|
|
34
28
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wonderflow/react-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.1",
|
|
4
4
|
"description": "UI components from Wonderflow's Wanda design system",
|
|
5
5
|
"author": "Wonderflow",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -81,8 +81,9 @@
|
|
|
81
81
|
"@types/react": "17.0.43",
|
|
82
82
|
"@types/react-dom": "17.0.14",
|
|
83
83
|
"@types/react-table": "7.7.12",
|
|
84
|
-
"@
|
|
85
|
-
"@wonderflow/
|
|
84
|
+
"@types/react-test-renderer": "18.0.0",
|
|
85
|
+
"@wonderflow/config": "11.0.1",
|
|
86
|
+
"@wonderflow/tokens": "11.0.1",
|
|
86
87
|
"babel-loader": "8.2.5",
|
|
87
88
|
"cpy-cli": "3.1.1",
|
|
88
89
|
"postcss": "8.4.17",
|
|
@@ -99,7 +100,7 @@
|
|
|
99
100
|
},
|
|
100
101
|
"dependencies": {
|
|
101
102
|
"@radix-ui/react-tabs": "1.0.0",
|
|
102
|
-
"ahooks": "3.7.
|
|
103
|
+
"ahooks": "3.7.5",
|
|
103
104
|
"clsx": "1.2.1",
|
|
104
105
|
"constate": "3.3.2",
|
|
105
106
|
"framer-motion": "6.5.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePopupWrapper.d.ts","sourceRoot":"","sources":["../../src/hooks/usePopupWrapper.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,eAAe,OAAQ,MAAM;;CAgCzC,CAAC"}
|