tiny-ui 0.0.92 → 0.0.95
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/.stylelintrc +19 -0
- package/CHANGELOG.md +15 -0
- package/babel.config.js +30 -0
- package/components/_utils/dom.ts +1 -1
- package/components/alert/__tests__/alert.test.tsx +36 -38
- package/components/anchor/anchor.tsx +1 -1
- package/components/aspect-ratio/__tests__/aspect-ratio.test.tsx +7 -4
- package/components/button/__tests__/button-group.test.tsx +49 -8
- package/components/button/__tests__/button.test.tsx +95 -7
- package/components/button/button-group.tsx +8 -4
- package/components/button/button.tsx +12 -7
- package/components/button/style/_mixin.scss +1 -0
- package/components/button/types.ts +1 -1
- package/components/checkbox/checkbox.tsx +3 -3
- package/components/dropdown/demo/placement.md +13 -11
- package/components/dropdown/style/_index.scss +4 -0
- package/components/grid/style/_index.scss +2 -2
- package/components/index.ts +6 -3
- package/components/input/input.tsx +1 -1
- package/components/layout/layout.tsx +1 -1
- package/components/link/__test__/__snapshots__/link.test.tsx.snap +17 -0
- package/components/link/__test__/link.test.tsx +27 -0
- package/components/popup/index.tsx +3 -4
- package/components/popup/style/_index.scss +5 -4
- package/components/radio/radio.tsx +1 -1
- package/components/split/index.md +15 -0
- package/components/split/resizer.tsx +15 -2
- package/components/split/split.tsx +2 -2
- package/components/split/types.ts +2 -1
- package/components/split-button/demo/basic.md +36 -0
- package/components/split-button/demo/disabled.md +22 -0
- package/components/split-button/demo/placement.md +61 -0
- package/components/split-button/index.md +32 -0
- package/components/split-button/index.tsx +50 -0
- package/components/split-button/style/_index.scss +9 -0
- package/components/split-button/style/index.tsx +5 -0
- package/components/split-button/types.ts +16 -0
- package/components/sticky/style/_index.scss +4 -1
- package/components/style/_animation.scss +3 -0
- package/components/style/_component.scss +1 -1
- package/components/style/_font.scss +247 -246
- package/components/style/_mixins.scss +1 -1
- package/components/style/_normalise.scss +7 -0
- package/components/style/_variables.scss +183 -183
- package/components/switch/index.tsx +1 -1
- package/components/switch/style/_mixin.scss +2 -2
- package/components/tooltip/style/_index.scss +5 -4
- package/dist/styles/index.css +7144 -5422
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/index.min.css +1 -1
- package/dist/styles/index.min.css.map +1 -1
- package/dist/tiny.js +3700 -1909
- package/dist/tiny.map +1 -1
- package/dist/tiny.min.js +2 -6
- package/dist/tiny.min.js.LICENSE.txt +20 -0
- package/lib/_utils/dom.d.ts +8 -1
- package/lib/_utils/general.js +2 -2
- package/lib/_utils/general.js.map +1 -1
- package/lib/_utils/props.js +1 -0
- package/lib/_utils/warning.js +1 -1
- package/lib/_utils/warning.js.map +1 -1
- package/lib/alert/index.js +7 -7
- package/lib/alert/index.js.map +1 -1
- package/lib/alert/types.js +1 -0
- package/lib/anchor/anchor-link.d.ts +1 -1
- package/lib/anchor/anchor-link.js +3 -3
- package/lib/anchor/anchor-link.js.map +1 -1
- package/lib/anchor/anchor.js +8 -8
- package/lib/anchor/anchor.js.map +1 -1
- package/lib/anchor/types.js +1 -0
- package/lib/aspect-ratio/index.js +2 -2
- package/lib/aspect-ratio/index.js.map +1 -1
- package/lib/aspect-ratio/types.js +1 -0
- package/lib/autocomplete/types.js +1 -0
- package/lib/avatar/avatar.js +8 -8
- package/lib/avatar/avatar.js.map +1 -1
- package/lib/avatar/types.js +1 -0
- package/lib/back-top/types.js +1 -0
- package/lib/badge/index.js +4 -4
- package/lib/badge/index.js.map +1 -1
- package/lib/badge/types.js +1 -0
- package/lib/breadcrumb/breadcrumb-item.js +1 -1
- package/lib/breadcrumb/breadcrumb-item.js.map +1 -1
- package/lib/breadcrumb/breadcrumb.js +1 -1
- package/lib/breadcrumb/breadcrumb.js.map +1 -1
- package/lib/breadcrumb/types.js +1 -0
- package/lib/button/button-group.d.ts +1 -1
- package/lib/button/button-group.js +4 -4
- package/lib/button/button-group.js.map +1 -1
- package/lib/button/button.d.ts +1 -1
- package/lib/button/button.js +10 -10
- package/lib/button/button.js.map +1 -1
- package/lib/button/style/_mixin.scss +1 -0
- package/lib/button/types.d.ts +1 -1
- package/lib/button/types.js +1 -0
- package/lib/calendar/index.js +4 -4
- package/lib/calendar/index.js.map +1 -1
- package/lib/card/card-content.js +1 -1
- package/lib/card/card-content.js.map +1 -1
- package/lib/card/card.js +5 -5
- package/lib/card/card.js.map +1 -1
- package/lib/card/types.js +1 -0
- package/lib/carousel/arrow-group.js +3 -3
- package/lib/carousel/arrow-group.js.map +1 -1
- package/lib/carousel/carousel.js +3 -3
- package/lib/carousel/carousel.js.map +1 -1
- package/lib/carousel/dot-group.js +3 -3
- package/lib/carousel/dot-group.js.map +1 -1
- package/lib/checkbox/checkbox-group.d.ts +1 -1
- package/lib/checkbox/checkbox-group.js +3 -3
- package/lib/checkbox/checkbox-group.js.map +1 -1
- package/lib/checkbox/checkbox.d.ts +1 -1
- package/lib/checkbox/checkbox.js +8 -8
- package/lib/checkbox/checkbox.js.map +1 -1
- package/lib/checkbox/types.js +1 -0
- package/lib/collapse/collapse-panel.js +8 -8
- package/lib/collapse/collapse-panel.js.map +1 -1
- package/lib/collapse/collapse.d.ts +1 -1
- package/lib/collapse/collapse.js +4 -4
- package/lib/collapse/collapse.js.map +1 -1
- package/lib/collapse/types.js +1 -0
- package/lib/config-provider/types.js +1 -0
- package/lib/copy-to-clipboard/types.js +1 -0
- package/lib/countdown/types.js +1 -0
- package/lib/date-picker/picker-day.js +9 -9
- package/lib/date-picker/picker-day.js.map +1 -1
- package/lib/date-picker/picker-header.js +7 -7
- package/lib/date-picker/picker-header.js.map +1 -1
- package/lib/descriptions/col.js +7 -7
- package/lib/descriptions/col.js.map +1 -1
- package/lib/descriptions/descriptions.js +4 -4
- package/lib/descriptions/descriptions.js.map +1 -1
- package/lib/descriptions/row.js +3 -3
- package/lib/descriptions/row.js.map +1 -1
- package/lib/descriptions/types.js +1 -0
- package/lib/divider/index.js +4 -4
- package/lib/divider/index.js.map +1 -1
- package/lib/divider/types.js +1 -0
- package/lib/drawer/index.js +7 -7
- package/lib/drawer/index.js.map +1 -1
- package/lib/drawer/types.js +1 -0
- package/lib/dropdown/style/_index.scss +4 -0
- package/lib/dropdown/types.js +1 -0
- package/lib/empty/index.js +4 -4
- package/lib/empty/index.js.map +1 -1
- package/lib/empty/types.js +1 -0
- package/lib/flip/flip.js +11 -11
- package/lib/flip/flip.js.map +1 -1
- package/lib/flip/types.js +1 -0
- package/lib/form/form-helper.js +1 -1
- package/lib/form/form-helper.js.map +1 -1
- package/lib/form/form-item.js +11 -11
- package/lib/form/form-item.js.map +1 -1
- package/lib/form/form.js +1 -1
- package/lib/form/form.js.map +1 -1
- package/lib/form/types.js +1 -0
- package/lib/grid/col.js +4 -4
- package/lib/grid/col.js.map +1 -1
- package/lib/grid/row.js +2 -2
- package/lib/grid/row.js.map +1 -1
- package/lib/grid/style/_index.scss +2 -2
- package/lib/grid/types.js +1 -0
- package/lib/icon/index.js +2 -2
- package/lib/icon/index.js.map +1 -1
- package/lib/icon/types.js +1 -0
- package/lib/image/index.js +1 -1
- package/lib/image/index.js.map +1 -1
- package/lib/image/types.js +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/input/input-group-addon.js +2 -2
- package/lib/input/input-group-addon.js.map +1 -1
- package/lib/input/input.d.ts +1 -1
- package/lib/input/input.js +7 -7
- package/lib/input/input.js.map +1 -1
- package/lib/input/types.js +1 -0
- package/lib/input-number/index.js +9 -9
- package/lib/input-number/index.js.map +1 -1
- package/lib/input-number/types.js +1 -0
- package/lib/input-password/index.js +2 -2
- package/lib/input-password/index.js.map +1 -1
- package/lib/input-password/types.js +1 -0
- package/lib/keyboard/index.d.ts +1 -1
- package/lib/keyboard/types.js +1 -0
- package/lib/layout/layout.d.ts +4 -4
- package/lib/layout/layout.js +1 -1
- package/lib/layout/layout.js.map +1 -1
- package/lib/layout/sidebar.d.ts +1 -1
- package/lib/layout/sidebar.js +4 -4
- package/lib/layout/sidebar.js.map +1 -1
- package/lib/layout/types.js +1 -0
- package/lib/link/index.js +2 -2
- package/lib/link/index.js.map +1 -1
- package/lib/link/types.js +1 -0
- package/lib/loader/index.js +9 -9
- package/lib/loader/index.js.map +1 -1
- package/lib/loader/indicator.js +5 -5
- package/lib/loader/indicator.js.map +1 -1
- package/lib/loader/types.js +1 -0
- package/lib/loading-bar/index.js +1 -1
- package/lib/loading-bar/index.js.map +1 -1
- package/lib/loading-bar/loading-bar.js +1 -1
- package/lib/loading-bar/loading-bar.js.map +1 -1
- package/lib/loading-bar/types.js +1 -0
- package/lib/menu/menu-item-group.js +3 -3
- package/lib/menu/menu-item-group.js.map +1 -1
- package/lib/menu/menu-item.js +2 -2
- package/lib/menu/menu-item.js.map +1 -1
- package/lib/menu/menu.js +2 -2
- package/lib/menu/menu.js.map +1 -1
- package/lib/menu/sub-menu.js +11 -11
- package/lib/menu/sub-menu.js.map +1 -1
- package/lib/menu/types.js +1 -0
- package/lib/message/index.js +2 -2
- package/lib/message/index.js.map +1 -1
- package/lib/message/message.js +9 -9
- package/lib/message/message.js.map +1 -1
- package/lib/message/types.js +1 -0
- package/lib/modal/index.js +10 -10
- package/lib/modal/index.js.map +1 -1
- package/lib/modal/types.js +1 -0
- package/lib/native-select/native-opt-group.d.ts +3 -3
- package/lib/native-select/native-option.d.ts +3 -3
- package/lib/native-select/native-select.d.ts +1 -1
- package/lib/native-select/native-select.js +2 -2
- package/lib/native-select/native-select.js.map +1 -1
- package/lib/native-select/types.js +1 -0
- package/lib/notification/index.js +6 -6
- package/lib/notification/index.js.map +1 -1
- package/lib/notification/notification.js +6 -6
- package/lib/notification/notification.js.map +1 -1
- package/lib/notification/types.js +1 -0
- package/lib/overlay/index.js +2 -2
- package/lib/overlay/index.js.map +1 -1
- package/lib/overlay/types.js +1 -0
- package/lib/pagination/index.js +11 -11
- package/lib/pagination/index.js.map +1 -1
- package/lib/pagination/types.js +1 -0
- package/lib/pop-confirm/index.js +4 -4
- package/lib/pop-confirm/index.js.map +1 -1
- package/lib/pop-confirm/types.js +1 -0
- package/lib/popover/index.js +4 -4
- package/lib/popover/index.js.map +1 -1
- package/lib/popover/types.js +1 -0
- package/lib/popup/index.js +6 -6
- package/lib/popup/index.js.map +1 -1
- package/lib/popup/style/_index.scss +5 -4
- package/lib/popup/types.js +1 -0
- package/lib/progress/bar.js +10 -10
- package/lib/progress/bar.js.map +1 -1
- package/lib/progress/circle.js +6 -6
- package/lib/progress/circle.js.map +1 -1
- package/lib/progress/index.d.ts +2 -2
- package/lib/radio/radio-group.d.ts +1 -1
- package/lib/radio/radio.d.ts +1 -1
- package/lib/radio/radio.js +5 -5
- package/lib/radio/radio.js.map +1 -1
- package/lib/radio/types.js +1 -0
- package/lib/rate/index.d.ts +1 -1
- package/lib/rate/rate-item.js +3 -3
- package/lib/rate/rate-item.js.map +1 -1
- package/lib/rate/types.js +1 -0
- package/lib/result/index.d.ts +1 -1
- package/lib/result/index.js +7 -7
- package/lib/result/index.js.map +1 -1
- package/lib/result/types.js +1 -0
- package/lib/scroll-indicator/index.js +2 -2
- package/lib/scroll-indicator/index.js.map +1 -1
- package/lib/scroll-indicator/types.js +1 -0
- package/lib/select/opt-group.js +2 -2
- package/lib/select/opt-group.js.map +1 -1
- package/lib/select/option.js +3 -3
- package/lib/select/option.js.map +1 -1
- package/lib/select/select.js +3 -3
- package/lib/select/select.js.map +1 -1
- package/lib/select/types.js +1 -0
- package/lib/skeleton/index.d.ts +1 -1
- package/lib/skeleton/index.js +2 -2
- package/lib/skeleton/index.js.map +1 -1
- package/lib/skeleton/types.js +1 -0
- package/lib/slider/index.d.ts +1 -1
- package/lib/slider/index.js +23 -23
- package/lib/slider/index.js.map +1 -1
- package/lib/slider/types.js +1 -0
- package/lib/space/index.d.ts +1 -1
- package/lib/space/index.js +2 -2
- package/lib/space/index.js.map +1 -1
- package/lib/space/types.js +1 -0
- package/lib/split/resizer.d.ts +1 -1
- package/lib/split/resizer.js +7 -3
- package/lib/split/resizer.js.map +1 -1
- package/lib/split/split-pane.d.ts +1 -1
- package/lib/split/split.js +4 -4
- package/lib/split/split.js.map +1 -1
- package/lib/split/types.d.ts +2 -1
- package/lib/split/types.js +1 -0
- package/lib/split-button/index.d.ts +7 -0
- package/lib/split-button/index.js +23 -0
- package/lib/split-button/index.js.map +1 -0
- package/lib/split-button/style/_index.scss +9 -0
- package/lib/split-button/style/css.js +4 -0
- package/lib/split-button/style/index.d.ts +3 -0
- package/lib/split-button/style/index.js +4 -0
- package/lib/split-button/style/index.js.map +1 -0
- package/lib/split-button/types.d.ts +15 -0
- package/lib/split-button/types.js +2 -0
- package/lib/split-button/types.js.map +1 -0
- package/lib/steps/steps-item.d.ts +1 -1
- package/lib/steps/steps-item.js +8 -8
- package/lib/steps/steps-item.js.map +1 -1
- package/lib/steps/steps.d.ts +1 -1
- package/lib/steps/steps.js +1 -1
- package/lib/steps/steps.js.map +1 -1
- package/lib/steps/types.js +1 -0
- package/lib/sticky/style/_index.scss +4 -1
- package/lib/sticky/types.js +1 -0
- package/lib/strength-indicator/index.d.ts +1 -1
- package/lib/strength-indicator/index.js +4 -4
- package/lib/strength-indicator/index.js.map +1 -1
- package/lib/strength-indicator/types.js +1 -0
- package/lib/style/_animation.scss +3 -0
- package/lib/style/_component.scss +1 -1
- package/lib/style/_font.scss +247 -246
- package/lib/style/_mixins.scss +1 -1
- package/lib/style/_normalise.scss +7 -0
- package/lib/style/_variables.scss +183 -183
- package/lib/style/index.css +7144 -5421
- package/lib/switch/index.d.ts +1 -1
- package/lib/switch/index.js +8 -8
- package/lib/switch/index.js.map +1 -1
- package/lib/switch/style/_mixin.scss +2 -2
- package/lib/switch/types.js +1 -0
- package/lib/tabs/style/index.css +64 -52
- package/lib/tabs/tab-panel.d.ts +1 -1
- package/lib/tabs/tab-panel.js +1 -1
- package/lib/tabs/tab-panel.js.map +1 -1
- package/lib/tabs/tabs.d.ts +1 -1
- package/lib/tabs/tabs.js +20 -20
- package/lib/tabs/tabs.js.map +1 -1
- package/lib/tag/checkable-tag.js +1 -1
- package/lib/tag/checkable-tag.js.map +1 -1
- package/lib/tag/tag.js +4 -4
- package/lib/tag/tag.js.map +1 -1
- package/lib/textarea/index.js +3 -3
- package/lib/textarea/index.js.map +1 -1
- package/lib/textarea/types.js +1 -0
- package/lib/time-picker/time-panel.js +5 -5
- package/lib/time-picker/time-panel.js.map +1 -1
- package/lib/timeline/timeline-item.js +3 -3
- package/lib/timeline/timeline-item.js.map +1 -1
- package/lib/timeline/timeline.js +3 -3
- package/lib/timeline/timeline.js.map +1 -1
- package/lib/timeline/types.js +1 -0
- package/lib/tooltip/index.js +1 -1
- package/lib/tooltip/index.js.map +1 -1
- package/lib/tooltip/style/_index.scss +5 -4
- package/lib/tooltip/types.js +1 -0
- package/lib/transfer/transfer-panel.d.ts +1 -1
- package/lib/transfer/transfer-panel.js +9 -9
- package/lib/transfer/transfer-panel.js.map +1 -1
- package/lib/transfer/transfer.d.ts +1 -1
- package/lib/transfer/transfer.js +8 -8
- package/lib/transfer/transfer.js.map +1 -1
- package/lib/transfer/types.js +1 -0
- package/lib/transition/index.js +1 -1
- package/lib/transition/index.js.map +1 -1
- package/lib/tree/tree-instance.js +2 -3
- package/lib/tree/tree-instance.js.map +1 -1
- package/lib/tree/tree-node.js +7 -7
- package/lib/tree/tree-node.js.map +1 -1
- package/lib/tree/tree.d.ts +1 -1
- package/lib/tree/tree.js +3 -3
- package/lib/tree/tree.js.map +1 -1
- package/lib/tree/types.js +1 -0
- package/lib/typography/heading.js +1 -1
- package/lib/typography/heading.js.map +1 -1
- package/lib/typography/paragraph.d.ts +1 -1
- package/lib/typography/types.js +1 -0
- package/lib/typography/typography.d.ts +1 -1
- package/lib/upload/dragger-cover.js +3 -3
- package/lib/upload/dragger-cover.js.map +1 -1
- package/lib/upload/types.js +1 -0
- package/lib/upload/upload-list.js +6 -6
- package/lib/upload/upload-list.js.map +1 -1
- package/lib/upload/upload.js +4 -4
- package/lib/upload/upload.js.map +1 -1
- package/package.json +94 -74
- package/components/waterfall/index.tsx +0 -78
- package/components/waterfall/style/_index.scss +0 -10
- package/components/waterfall/style/index.tsx +0 -1
- package/lib/waterfall/index.d.ts +0 -9
- package/lib/waterfall/index.js +0 -54
- package/lib/waterfall/index.js.map +0 -1
- package/lib/waterfall/style/_index.scss +0 -10
- package/lib/waterfall/style/css.js +0 -2
- package/lib/waterfall/style/index.d.ts +0 -1
- package/lib/waterfall/style/index.js +0 -2
- package/lib/waterfall/style/index.js.map +0 -1
package/.stylelintrc
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,21 @@ Tiny UI strictly follows [Semantic Versioning 2.0.0](https://semver.org/).
|
|
|
8
8
|
- **z version**: patch version at the end of every week for routine bugfix (anytime for urgent bugfix).
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
### [0.0.94](https://github.com/wangdicoder/tiny-ui/compare/v0.0.93...v0.0.94) (2020-10-25)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* `<Button />` danger type ([c280e07](https://github.com/wangdicoder/tiny-ui/commit/c280e0703614acd33670879af14b1b0817320093))
|
|
17
|
+
* `<Split />` - resizer `onMouseDown` event ([73d74eb](https://github.com/wangdicoder/tiny-ui/commit/73d74eb09bafc2e925144e266716d2a708bb0262))
|
|
18
|
+
|
|
19
|
+
### [0.0.93](https://github.com/wangdicoder/tiny-ui/compare/v0.0.92...v0.0.93) (2020-08-09)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* `<Button />` - fix ButtonGroup style in focus state ([#9](https://github.com/wangdicoder/tiny-ui/issues/9)) ([29e88ac](https://github.com/wangdicoder/tiny-ui/commit/29e88ac4fff455ffdb4240f368e394bbcfc71bfb))
|
|
25
|
+
|
|
11
26
|
### [0.0.92](https://github.com/wangdicoder/tiny-ui/compare/v0.0.91...v0.0.92) (2020-07-25)
|
|
12
27
|
|
|
13
28
|
|
package/babel.config.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
2
|
+
const plugins = [
|
|
3
|
+
'@babel/plugin-transform-runtime',
|
|
4
|
+
'@babel/plugin-syntax-dynamic-import',
|
|
5
|
+
'@babel/plugin-transform-async-to-generator',
|
|
6
|
+
'transform-class-properties',
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
module.exports = (api) => {
|
|
10
|
+
api.cache(true);
|
|
11
|
+
return {
|
|
12
|
+
presets: [
|
|
13
|
+
[
|
|
14
|
+
'@babel/preset-env',
|
|
15
|
+
{
|
|
16
|
+
corejs: 3.9,
|
|
17
|
+
useBuiltIns: 'usage',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
'@babel/preset-react',
|
|
22
|
+
{
|
|
23
|
+
runtime: 'automatic',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
'@babel/preset-typescript',
|
|
27
|
+
],
|
|
28
|
+
plugins: isDev ? [...plugins, 'react-refresh/babel'] : [...plugins],
|
|
29
|
+
};
|
|
30
|
+
};
|
package/components/_utils/dom.ts
CHANGED
|
@@ -9,7 +9,7 @@ export const getScroll = (node: Target, isVertical = true): number => {
|
|
|
9
9
|
return node === window ? (node as Window)[windowProp] : (node as HTMLElement)[elementProp];
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
export const getRect = (node: Target = window)
|
|
12
|
+
export const getRect = (node: Target = window) => {
|
|
13
13
|
return node !== window
|
|
14
14
|
? (node as HTMLElement).getBoundingClientRect()
|
|
15
15
|
: {
|
|
@@ -8,58 +8,56 @@ describe('<Alert />', () => {
|
|
|
8
8
|
expect(asFragment()).toMatchSnapshot();
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
it('should render
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
expect(element).toBeInTheDocument();
|
|
15
|
-
expect(element).toHaveClass('ty-alert');
|
|
11
|
+
it('should render correctly', () => {
|
|
12
|
+
const { container } = render(<Alert>Alert</Alert>);
|
|
13
|
+
expect(container.firstChild).toHaveClass('ty-alert');
|
|
16
14
|
});
|
|
17
15
|
|
|
18
16
|
it('should render correct types', () => {
|
|
19
|
-
expect(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
).toHaveClass('ty-alert_warning');
|
|
40
|
-
expect(
|
|
41
|
-
render(
|
|
42
|
-
<Alert type="error" data-testid="error">
|
|
43
|
-
Alert
|
|
44
|
-
</Alert>
|
|
45
|
-
).getByTestId('error')
|
|
46
|
-
).toHaveClass('ty-alert_error');
|
|
17
|
+
expect(render(<Alert type="success">Alert</Alert>).container.firstChild).toHaveClass(
|
|
18
|
+
'ty-alert_success'
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
expect(render(<Alert type="info">Alert</Alert>).container.firstChild).toHaveClass(
|
|
22
|
+
'ty-alert_info'
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
expect(render(<Alert type="warning">Alert</Alert>).container.firstChild).toHaveClass(
|
|
26
|
+
'ty-alert_warning'
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect(render(<Alert type="error">Alert</Alert>).container.firstChild).toHaveClass(
|
|
30
|
+
'ty-alert_error'
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should render title', () => {
|
|
35
|
+
const { container } = render(<Alert title="This is a title">Alert Component</Alert>);
|
|
36
|
+
expect(container.querySelector('.ty-alert__title')).toBeTruthy();
|
|
47
37
|
});
|
|
48
38
|
|
|
49
39
|
it('should render cross icon', () => {
|
|
50
|
-
const
|
|
51
|
-
expect(
|
|
40
|
+
const { container } = render(<Alert closable>This is closable.</Alert>);
|
|
41
|
+
expect(container.querySelector('.ty-alert__close-btn')).toBeTruthy();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should render custom close text', () => {
|
|
45
|
+
const { container } = render(<Alert closeText="close now">This is closable.</Alert>);
|
|
46
|
+
expect(container.querySelector('.ty-alert__close-btn')).toBeTruthy();
|
|
47
|
+
expect(container.querySelector('.ty-alert__close-btn')?.innerHTML).toBe('close now');
|
|
52
48
|
});
|
|
53
49
|
|
|
54
50
|
it('should trigger onClose event', () => {
|
|
55
|
-
const
|
|
51
|
+
const fn = jest.fn();
|
|
56
52
|
const wrapper = render(
|
|
57
|
-
<Alert closable onClose={
|
|
53
|
+
<Alert closable onClose={fn}>
|
|
58
54
|
This is a alert
|
|
59
55
|
</Alert>
|
|
60
56
|
);
|
|
61
57
|
const closeBtn = wrapper.getByText('✕');
|
|
58
|
+
|
|
62
59
|
fireEvent.click(closeBtn);
|
|
63
|
-
|
|
60
|
+
|
|
61
|
+
expect(fn).toHaveBeenCalledTimes(1);
|
|
64
62
|
});
|
|
65
63
|
});
|
|
@@ -44,7 +44,7 @@ const Anchor = (props: AnchorProps): JSX.Element => {
|
|
|
44
44
|
const handleLinkClick = (e: React.MouseEvent<HTMLAnchorElement>, anchorName: string) => {
|
|
45
45
|
const { location } = window;
|
|
46
46
|
let url;
|
|
47
|
-
// if it is a HashRouter mode, prevent the default event
|
|
47
|
+
// if it is a HashRouter mode, prevent the default event and update the query.
|
|
48
48
|
if (location.pathname.includes('/#/')) {
|
|
49
49
|
url = location.protocol + '//' + location.host + location.pathname + `?anchor=${anchorName}`;
|
|
50
50
|
} else {
|
|
@@ -9,15 +9,18 @@ describe('<AspectRatio />', () => {
|
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
it('should render children', () => {
|
|
12
|
-
const
|
|
13
|
-
expect(
|
|
12
|
+
const { container } = render(<AspectRatio>children</AspectRatio>);
|
|
13
|
+
expect(container.firstChild).toHaveStyle({ width: '100%' });
|
|
14
|
+
expect(container).toContainHTML('children');
|
|
14
15
|
});
|
|
15
16
|
|
|
16
17
|
it('should render correct ratio container', () => {
|
|
17
|
-
|
|
18
|
+
const { container } = render(<AspectRatio ratio={4 / 3} />);
|
|
19
|
+
expect(container.querySelector('.ty-aspect-ratio__padding')).toHaveStyle({ paddingTop: '75%' });
|
|
18
20
|
});
|
|
19
21
|
|
|
20
22
|
it('should render correct width', () => {
|
|
21
|
-
|
|
23
|
+
const { container } = render(<AspectRatio width={20} />);
|
|
24
|
+
expect(container.firstChild).toHaveStyle({ width: '20px' });
|
|
22
25
|
});
|
|
23
26
|
});
|
|
@@ -13,12 +13,53 @@ describe('<ButtonGroup />', () => {
|
|
|
13
13
|
expect(asFragment()).toMatchSnapshot();
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
it('should render two buttons', () => {
|
|
17
|
+
const { container } = render(
|
|
18
|
+
<ButtonGroup>
|
|
19
|
+
<Button>Default</Button>
|
|
20
|
+
<Button>Default</Button>
|
|
21
|
+
</ButtonGroup>
|
|
22
|
+
);
|
|
23
|
+
expect(container.querySelectorAll('.ty-btn_default').length).toBe(2);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should render correct type of buttons', () => {
|
|
27
|
+
const { container } = render(
|
|
28
|
+
<ButtonGroup btnType="primary">
|
|
29
|
+
<Button>Default</Button>
|
|
30
|
+
<Button>Default</Button>
|
|
31
|
+
</ButtonGroup>
|
|
32
|
+
);
|
|
33
|
+
expect(container.querySelectorAll('.ty-btn_primary').length).toBe(2);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should render correct size of buttons', () => {
|
|
37
|
+
const { container } = render(
|
|
38
|
+
<ButtonGroup size="lg">
|
|
39
|
+
<Button>Default</Button>
|
|
40
|
+
<Button>Default</Button>
|
|
41
|
+
</ButtonGroup>
|
|
42
|
+
);
|
|
43
|
+
expect(container.querySelectorAll('.ty-btn_lg').length).toBe(2);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should render correct disabled of buttons', () => {
|
|
47
|
+
const { container } = render(
|
|
48
|
+
<ButtonGroup disabled>
|
|
49
|
+
<Button>Default</Button>
|
|
50
|
+
<Button>Default</Button>
|
|
51
|
+
</ButtonGroup>
|
|
52
|
+
);
|
|
53
|
+
expect(container.querySelectorAll('.ty-btn_disabled').length).toBe(2);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should only disable one button', () => {
|
|
57
|
+
const { container } = render(
|
|
58
|
+
<ButtonGroup>
|
|
59
|
+
<Button disabled>Default</Button>
|
|
60
|
+
<Button>Default</Button>
|
|
61
|
+
</ButtonGroup>
|
|
62
|
+
);
|
|
63
|
+
expect(container.querySelectorAll('.ty-btn_disabled').length).toBe(1);
|
|
64
|
+
});
|
|
24
65
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
3
|
import Button from '../button';
|
|
4
|
+
import Icon from '../../icon';
|
|
4
5
|
|
|
5
6
|
describe('<Button />', () => {
|
|
6
7
|
it('should match the snapshot', () => {
|
|
@@ -8,13 +9,100 @@ describe('<Button />', () => {
|
|
|
8
9
|
expect(asFragment()).toMatchSnapshot();
|
|
9
10
|
});
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
describe('button type', () => {
|
|
13
|
+
it('should render default button by default', () => {
|
|
14
|
+
const { container } = render(<Button>Default Button</Button>);
|
|
15
|
+
expect(container.firstChild).toHaveClass('ty-btn');
|
|
16
|
+
expect(container.firstChild).toHaveClass('ty-btn_default');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should render primary button', () => {
|
|
20
|
+
const { container } = render(<Button btnType="primary">Primary Button</Button>);
|
|
21
|
+
expect(container.firstChild).toHaveClass('ty-btn_primary');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should render outline button', () => {
|
|
25
|
+
const { container } = render(<Button btnType="outline">Outline Button</Button>);
|
|
26
|
+
expect(container.firstChild).toHaveClass('ty-btn_outline');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should render ghost button', () => {
|
|
30
|
+
const { container } = render(<Button btnType="ghost">Ghost Button</Button>);
|
|
31
|
+
expect(container.firstChild).toHaveClass('ty-btn_ghost');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should render link button', () => {
|
|
35
|
+
const { container } = render(<Button btnType="link">Link Button</Button>);
|
|
36
|
+
expect(container.firstChild).toHaveClass('ty-btn_link');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should render success button', () => {
|
|
40
|
+
const { container } = render(<Button btnType="success">Success Button</Button>);
|
|
41
|
+
expect(container.firstChild).toHaveClass('ty-btn_success');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should render info button', () => {
|
|
45
|
+
const { container } = render(<Button btnType="info">Info Button</Button>);
|
|
46
|
+
expect(container.firstChild).toHaveClass('ty-btn_info');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should render warning button', () => {
|
|
50
|
+
const { container } = render(<Button btnType="warning">Warning Button</Button>);
|
|
51
|
+
expect(container.firstChild).toHaveClass('ty-btn_warning');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should render danger button', () => {
|
|
55
|
+
const { container } = render(<Button btnType="danger">Danger Button</Button>);
|
|
56
|
+
expect(container.firstChild).toHaveClass('ty-btn_danger');
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('button size', () => {
|
|
61
|
+
it('should render medium size by default', () => {
|
|
62
|
+
const { container } = render(<Button>Medium Button</Button>);
|
|
63
|
+
expect(container.firstChild).toHaveClass('ty-btn_md');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should render small size', () => {
|
|
67
|
+
const { container } = render(<Button size="sm">Small Button</Button>);
|
|
68
|
+
expect(container.firstChild).toHaveClass('ty-btn_sm');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should render large size', () => {
|
|
72
|
+
const { container } = render(<Button size="lg">Large Button</Button>);
|
|
73
|
+
expect(container.firstChild).toHaveClass('ty-btn_lg');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should have loading icon', () => {
|
|
78
|
+
const { container } = render(<Button loading>Loading</Button>);
|
|
79
|
+
expect(container.firstChild).toHaveClass('ty-btn_loading');
|
|
80
|
+
expect(container.querySelector('.ty-btn__loader')).toBeTruthy();
|
|
14
81
|
});
|
|
15
82
|
|
|
16
|
-
it('should
|
|
17
|
-
const
|
|
18
|
-
expect(
|
|
83
|
+
it('should have icon placement', () => {
|
|
84
|
+
const { container } = render(<Button icon={<Icon name="wifi" />}>Icon</Button>);
|
|
85
|
+
expect(container.querySelector('.ty-btn__icon-container')).toBeTruthy();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('should be disabled', () => {
|
|
89
|
+
const { container } = render(<Button disabled>Disabled</Button>);
|
|
90
|
+
expect(container.firstChild).toHaveClass('ty-btn_disabled');
|
|
91
|
+
expect(container.firstChild).toBeDisabled();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should be a block style', () => {
|
|
95
|
+
const { container } = render(<Button block>Block</Button>);
|
|
96
|
+
expect(container.firstChild).toHaveClass('ty-btn_block');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should fire event when clicking the button', () => {
|
|
100
|
+
const fn = jest.fn();
|
|
101
|
+
const { container } = render(<Button onClick={fn}>Button</Button>);
|
|
102
|
+
|
|
103
|
+
const btn = container.firstChild;
|
|
104
|
+
btn && fireEvent.click(btn);
|
|
105
|
+
|
|
106
|
+
expect(fn).toHaveBeenCalledTimes(1);
|
|
19
107
|
});
|
|
20
108
|
});
|
|
@@ -20,10 +20,14 @@ const ButtonGroup = React.forwardRef<HTMLDivElement, ButtonGroupProps>(
|
|
|
20
20
|
const configContext = useContext(ConfigContext);
|
|
21
21
|
const prefixCls = getPrefixCls('btn-group', configContext.prefixCls, customisedCls);
|
|
22
22
|
const btnSize = props.size || configContext.componentSize || size;
|
|
23
|
-
const cls = classNames(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const cls = classNames(
|
|
24
|
+
prefixCls,
|
|
25
|
+
{
|
|
26
|
+
[`${prefixCls}_round`]: round,
|
|
27
|
+
[`${prefixCls}_${btnType}`]: btnType,
|
|
28
|
+
},
|
|
29
|
+
className
|
|
30
|
+
);
|
|
27
31
|
return (
|
|
28
32
|
<div {...otherProps} className={cls} ref={ref}>
|
|
29
33
|
{React.Children.map(children, (child) => {
|
|
@@ -23,13 +23,18 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>((props: ButtonPr
|
|
|
23
23
|
const configContext = useContext(ConfigContext);
|
|
24
24
|
const prefixCls = getPrefixCls('btn', configContext.prefixCls, customisedCls);
|
|
25
25
|
const btnSize = props.size || configContext.componentSize || size;
|
|
26
|
-
const cls = classNames(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
const cls = classNames(
|
|
27
|
+
prefixCls,
|
|
28
|
+
`${prefixCls}_${btnSize}`,
|
|
29
|
+
{
|
|
30
|
+
[`${prefixCls}_${btnType}`]: btnType,
|
|
31
|
+
[`${prefixCls}_block`]: block,
|
|
32
|
+
[`${prefixCls}_round`]: round,
|
|
33
|
+
[`${prefixCls}_disabled`]: disabled,
|
|
34
|
+
[`${prefixCls}_loading`]: loading,
|
|
35
|
+
},
|
|
36
|
+
className
|
|
37
|
+
);
|
|
33
38
|
|
|
34
39
|
const btnOnClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
35
40
|
if (disabled || loading) {
|
|
@@ -46,10 +46,10 @@ const Checkbox = React.forwardRef<HTMLLabelElement, CheckboxProps>(
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
useEffect(() => {
|
|
49
|
-
if ('value' in checkboxGroupContext && 'value' in props) {
|
|
50
|
-
setChecked((checkboxGroupContext.value
|
|
49
|
+
if ('value' in checkboxGroupContext && typeof checkboxGroupContext.value !== 'undefined' && 'value' in props ) {
|
|
50
|
+
setChecked((checkboxGroupContext.value).includes(value as string));
|
|
51
51
|
}
|
|
52
|
-
'checked' in props && setChecked(props.checked
|
|
52
|
+
'checked' in props && typeof props.checked !== 'undefined' && setChecked(props.checked);
|
|
53
53
|
}, [props, checkboxGroupContext, value]);
|
|
54
54
|
|
|
55
55
|
return (
|
|
@@ -19,17 +19,6 @@ class PlacementExample extends React.PureComponent {
|
|
|
19
19
|
render() {
|
|
20
20
|
return (
|
|
21
21
|
<div>
|
|
22
|
-
<Dropdown overlay={this.renderOverlay()} placement="bottom-start">
|
|
23
|
-
<Button>bottomLeft</Button>
|
|
24
|
-
</Dropdown>
|
|
25
|
-
<Dropdown overlay={this.renderOverlay()} placement="bottom">
|
|
26
|
-
<Button>bottomCenter</Button>
|
|
27
|
-
</Dropdown>
|
|
28
|
-
<Dropdown overlay={this.renderOverlay()} placement="bottom-end">
|
|
29
|
-
<Button>bottomRight</Button>
|
|
30
|
-
</Dropdown>
|
|
31
|
-
<br />
|
|
32
|
-
<br />
|
|
33
22
|
<Dropdown overlay={this.renderOverlay()} placement="top-start">
|
|
34
23
|
<Button>topLeft</Button>
|
|
35
24
|
</Dropdown>
|
|
@@ -38,6 +27,19 @@ class PlacementExample extends React.PureComponent {
|
|
|
38
27
|
</Dropdown>
|
|
39
28
|
<Dropdown overlay={this.renderOverlay()} placement="top-end">
|
|
40
29
|
<Button>topRight</Button>
|
|
30
|
+
</Dropdown>
|
|
31
|
+
|
|
32
|
+
<br />
|
|
33
|
+
<br />
|
|
34
|
+
|
|
35
|
+
<Dropdown overlay={this.renderOverlay()} placement="bottom-start">
|
|
36
|
+
<Button>bottomLeft</Button>
|
|
37
|
+
</Dropdown>
|
|
38
|
+
<Dropdown overlay={this.renderOverlay()} placement="bottom">
|
|
39
|
+
<Button>bottomCenter</Button>
|
|
40
|
+
</Dropdown>
|
|
41
|
+
<Dropdown overlay={this.renderOverlay()} placement="bottom-end">
|
|
42
|
+
<Button>bottomRight</Button>
|
|
41
43
|
</Dropdown>
|
|
42
44
|
</div>
|
|
43
45
|
);
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
@mixin grid($size: '') {
|
|
55
55
|
@for $i from 1 through 24 {
|
|
56
56
|
&#{$size}-#{$i} {
|
|
57
|
-
width: 100% / (24 / $i);
|
|
57
|
+
width: calc(100% / (24 / $i));
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
&#{$size}-offset-#{$i} {
|
|
61
|
-
margin-left: 100% / (24 / $i);
|
|
61
|
+
margin-left: calc(100% / (24 / $i));
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
&#{$size}-order-#{$i} {
|
package/components/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import 'intersection-observer';
|
|
2
|
+
|
|
1
3
|
export { default as Alert } from './alert';
|
|
2
4
|
export { default as Anchor } from './anchor';
|
|
3
5
|
export { default as AspectRatio } from './aspect-ratio';
|
|
@@ -8,7 +10,7 @@ export { default as Badge } from './badge';
|
|
|
8
10
|
export { default as Breadcrumb } from './breadcrumb';
|
|
9
11
|
export { default as Button } from './button';
|
|
10
12
|
export { default as Card } from './card';
|
|
11
|
-
export { default as Carousel } from './carousel';
|
|
13
|
+
// export { default as Carousel } from './carousel';
|
|
12
14
|
export { default as Checkbox } from './checkbox';
|
|
13
15
|
export { default as ConfigProvider } from './config-provider';
|
|
14
16
|
export { default as CopyToClipboard } from './copy-to-clipboard';
|
|
@@ -53,12 +55,13 @@ export { default as Select } from './select';
|
|
|
53
55
|
export { default as Skeleton } from './skeleton';
|
|
54
56
|
export { default as Slider } from './slider';
|
|
55
57
|
export { default as Split } from './split';
|
|
58
|
+
export { default as SplitButton } from './split-button';
|
|
56
59
|
export { default as Space } from './space';
|
|
57
60
|
export { default as Steps } from './steps';
|
|
58
61
|
export { default as Sticky } from './sticky';
|
|
59
62
|
export { default as StrengthIndicator } from './strength-indicator';
|
|
60
63
|
export { default as Switch } from './switch';
|
|
61
|
-
export { default as Tabs } from './tabs';
|
|
64
|
+
// export { default as Tabs } from './tabs';
|
|
62
65
|
export { default as Tag } from './tag';
|
|
63
66
|
export { default as Textarea } from './textarea';
|
|
64
67
|
export { default as Timeline } from './timeline';
|
|
@@ -69,5 +72,5 @@ export { default as Transition } from './transition';
|
|
|
69
72
|
export { default as Tree } from './tree';
|
|
70
73
|
export { default as Typography } from './typography';
|
|
71
74
|
export { default as Upload } from './upload';
|
|
72
|
-
|
|
75
|
+
|
|
73
76
|
export { withLocale } from './intl-provider/with-locale';
|
|
@@ -92,7 +92,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
92
92
|
}, [inputPadding]);
|
|
93
93
|
|
|
94
94
|
useEffect(() => {
|
|
95
|
-
'value' in props && setValue(props.value
|
|
95
|
+
'value' in props && typeof props.value !== 'undefined' && setValue(props.value);
|
|
96
96
|
}, [props]);
|
|
97
97
|
|
|
98
98
|
return (
|
|
@@ -8,7 +8,7 @@ import { LayoutProps } from './types';
|
|
|
8
8
|
/**
|
|
9
9
|
* Layout component
|
|
10
10
|
*/
|
|
11
|
-
const Layout = React.forwardRef<
|
|
11
|
+
const Layout = React.forwardRef<HTMLElement, LayoutProps>(
|
|
12
12
|
(props: LayoutProps, ref): JSX.Element => {
|
|
13
13
|
const { className, children, prefixCls: customisedCls, ...otherProps } = props;
|
|
14
14
|
const [hasSidebar, setHasSidebar] = useState(false);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<Link /> should match the snapshot 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<a
|
|
6
|
+
aria-disabled="false"
|
|
7
|
+
class="ty-link"
|
|
8
|
+
href="#"
|
|
9
|
+
role="link"
|
|
10
|
+
target="_blank"
|
|
11
|
+
>
|
|
12
|
+
<span>
|
|
13
|
+
Link
|
|
14
|
+
</span>
|
|
15
|
+
</a>
|
|
16
|
+
</DocumentFragment>
|
|
17
|
+
`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import Link from '../index';
|
|
4
|
+
|
|
5
|
+
describe('<Link />', () => {
|
|
6
|
+
it('should match the snapshot', () => {
|
|
7
|
+
const { asFragment } = render(<Link href="#">Link</Link>);
|
|
8
|
+
expect(asFragment()).toMatchSnapshot();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
describe('external', () => {
|
|
12
|
+
it('should set _blank to target attribute by default', () => {
|
|
13
|
+
const { container } = render(<Link>Link</Link>);
|
|
14
|
+
expect(container.firstChild).toHaveAttribute('target', '_blank');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should set _self to target attribute by default', () => {
|
|
18
|
+
const { container } = render(<Link external={false}>Link</Link>);
|
|
19
|
+
expect(container.firstChild).toHaveAttribute('target', '_self');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should be disabled', () => {
|
|
24
|
+
const { container } = render(<Link disabled>Link</Link>);
|
|
25
|
+
expect(container.firstChild).toHaveClass('ty-link_disabled');
|
|
26
|
+
});
|
|
27
|
+
});
|