@spaced-out/ui-design-system 0.4.0 → 0.4.2
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/.cspell/custom-words.txt +2 -0
- package/.github/workflows/publish_to_npm.yml +1 -1
- package/CHANGELOG.md +20 -0
- package/lib/components/Accordion/Accordion.js +70 -0
- package/lib/components/Accordion/Accordion.js.flow +116 -0
- package/lib/components/Accordion/Accordion.module.css +71 -0
- package/lib/components/Accordion/AccordionGroup.js +56 -0
- package/lib/components/Accordion/AccordionGroup.js.flow +75 -0
- package/lib/components/Accordion/AccordionGroup.module.css +29 -0
- package/lib/components/Accordion/index.js +27 -0
- package/lib/components/Accordion/index.js.flow +4 -0
- package/lib/components/Pagination/Pagination.js +2 -1
- package/lib/components/Pagination/Pagination.js.flow +5 -1
- package/lib/components/index.js +11 -0
- package/lib/components/index.js.flow +1 -0
- package/lib/hooks/useWindowSize/useWindowSize.js +22 -14
- package/lib/hooks/useWindowSize/useWindowSize.js.flow +17 -13
- package/package.json +2 -2
package/.cspell/custom-words.txt
CHANGED
|
@@ -22,7 +22,7 @@ jobs:
|
|
|
22
22
|
- name: Check Permissions
|
|
23
23
|
id: check-permissions
|
|
24
24
|
env:
|
|
25
|
-
ALLOWED_USERS: superrover, Anant-Raj, diwakersurya, ashwini-sensehq, vish-sah, VishalBarnawal, sanskar-s, VivekJangid, sharad-kushwah, Swatantramishra1, bhatiarush27, darsh-mecwan-sense, keshavsensehq
|
|
25
|
+
ALLOWED_USERS: superrover, Anant-Raj, diwakersurya, ashwini-sensehq, vish-sah, VishalBarnawal, sanskar-s, VivekJangid, sharad-kushwah, Swatantramishra1, bhatiarush27, darsh-mecwan-sense, keshavsensehq, SahilShrivastava1, aditya-kaushal
|
|
26
26
|
if: ${{ !contains(env.ALLOWED_USERS, github.actor) }}
|
|
27
27
|
run: |
|
|
28
28
|
echo "You don't have correct permissions to do this release"
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.4.2](https://github.com/spaced-out/ui-design-system/compare/v0.4.1...v0.4.2) (2025-07-18)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* added language support labels in pagination ([#368](https://github.com/spaced-out/ui-design-system/issues/368)) ([9d37138](https://github.com/spaced-out/ui-design-system/commit/9d37138315427b41a28820a92ee466ea544d9ded))
|
|
11
|
+
* pagination static labels ([#370](https://github.com/spaced-out/ui-design-system/issues/370)) ([241bb9d](https://github.com/spaced-out/ui-design-system/commit/241bb9d56dc016f97971e0f2a060a40d6d8d918a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* fixes the depth issue while using useWindowSize ([#369](https://github.com/spaced-out/ui-design-system/issues/369)) ([cc27012](https://github.com/spaced-out/ui-design-system/commit/cc27012f1075e8f435c8d045dd221f66bcc88f2a))
|
|
17
|
+
|
|
18
|
+
### [0.4.1](https://github.com/spaced-out/ui-design-system/compare/v0.4.0...v0.4.1) (2025-07-15)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* **GDS-518:** accordian component ([#359](https://github.com/spaced-out/ui-design-system/issues/359)) ([c48b2c9](https://github.com/spaced-out/ui-design-system/commit/c48b2c985538e56cc359bbabc1fee25605220c0c))
|
|
24
|
+
|
|
5
25
|
## [0.4.0](https://github.com/spaced-out/ui-design-system/compare/v0.3.51-beta.0...v0.4.0) (2025-07-14)
|
|
6
26
|
|
|
7
27
|
### [0.3.51-beta.0](https://github.com/spaced-out/ui-design-system/compare/v0.3.50...v0.3.51-beta.0) (2025-07-09)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Accordion = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
9
|
+
var _Button = require("../Button");
|
|
10
|
+
var _Toggle = require("../Toggle");
|
|
11
|
+
var _AccordionModule = _interopRequireDefault(require("./Accordion.module.css"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
const Accordion = exports.Accordion = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
15
|
+
let {
|
|
16
|
+
id,
|
|
17
|
+
header,
|
|
18
|
+
onChange,
|
|
19
|
+
onToggle,
|
|
20
|
+
disabled = false,
|
|
21
|
+
classNames,
|
|
22
|
+
isOpen = false,
|
|
23
|
+
showToggle = false,
|
|
24
|
+
children
|
|
25
|
+
} = _ref;
|
|
26
|
+
const [accordionIsOpen, setAccordionIsOpen] = React.useState(isOpen);
|
|
27
|
+
const [checked, setChecked] = React.useState(false);
|
|
28
|
+
const handleToggle = () => {
|
|
29
|
+
setChecked(!checked);
|
|
30
|
+
onToggle?.(id, !checked);
|
|
31
|
+
};
|
|
32
|
+
const handleAccordionClick = () => {
|
|
33
|
+
if (!disabled) {
|
|
34
|
+
onChange?.(id, !accordionIsOpen);
|
|
35
|
+
setAccordionIsOpen(prev => !prev);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
setAccordionIsOpen(isOpen);
|
|
40
|
+
}, [isOpen]);
|
|
41
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
ref: ref,
|
|
43
|
+
"data-testid": "Accordion",
|
|
44
|
+
className: (0, _classify.default)(_AccordionModule.default.wrapper, classNames?.wrapper)
|
|
45
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: (0, _classify.default)(_AccordionModule.default.headerWrapper, classNames?.headerWrapper),
|
|
47
|
+
onClick: handleAccordionClick
|
|
48
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
className: (0, _classify.default)(_AccordionModule.default.header, classNames?.header)
|
|
50
|
+
}, showToggle && /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
onClick: e => {
|
|
52
|
+
e.stopPropagation(); // prevent toggle click from triggering accordion toggle
|
|
53
|
+
}
|
|
54
|
+
}, /*#__PURE__*/React.createElement(_Toggle.Toggle, {
|
|
55
|
+
checked: checked,
|
|
56
|
+
onChange: handleToggle,
|
|
57
|
+
ariaLabel: 'toggle'
|
|
58
|
+
})), header), /*#__PURE__*/React.createElement(_Button.Button, {
|
|
59
|
+
iconLeftName: accordionIsOpen ? 'chevron-up' : 'chevron-down',
|
|
60
|
+
disabled: disabled,
|
|
61
|
+
size: "small",
|
|
62
|
+
type: "ghost",
|
|
63
|
+
className: _AccordionModule.default.icon,
|
|
64
|
+
ariaLabel: 'Collapse button'
|
|
65
|
+
// we are not defining onClick here as we are using onClick of the parent here.
|
|
66
|
+
})), accordionIsOpen && /*#__PURE__*/React.createElement("div", {
|
|
67
|
+
className: (0, _classify.default)(_AccordionModule.default.content, classNames?.content)
|
|
68
|
+
}, children));
|
|
69
|
+
});
|
|
70
|
+
Accordion.displayName = 'Accordion';
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import classify from '../../utils/classify';
|
|
6
|
+
import {Button} from '../Button';
|
|
7
|
+
import {Toggle} from '../Toggle';
|
|
8
|
+
|
|
9
|
+
import css from './Accordion.module.css';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export type AccordionClassNames = $ReadOnly<{
|
|
13
|
+
wrapper?: string,
|
|
14
|
+
headerWrapper?: string,
|
|
15
|
+
header?: string,
|
|
16
|
+
content?: string,
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
export type AccordionPropsType = {
|
|
20
|
+
id: string,
|
|
21
|
+
header: React.Node,
|
|
22
|
+
children: React.Node,
|
|
23
|
+
classNames?: AccordionClassNames,
|
|
24
|
+
isOpen?: boolean,
|
|
25
|
+
disabled?: boolean,
|
|
26
|
+
showToggle?: boolean,
|
|
27
|
+
onChange?: ?(id?: string, isOpen: boolean) => mixed,
|
|
28
|
+
onToggle?: ?(id?: string, checked?: boolean) => mixed,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const Accordion: React$AbstractComponent<
|
|
32
|
+
AccordionPropsType,
|
|
33
|
+
HTMLDivElement,
|
|
34
|
+
> = React.forwardRef<AccordionPropsType, HTMLDivElement>(
|
|
35
|
+
(
|
|
36
|
+
{
|
|
37
|
+
id,
|
|
38
|
+
header,
|
|
39
|
+
onChange,
|
|
40
|
+
onToggle,
|
|
41
|
+
disabled = false,
|
|
42
|
+
classNames,
|
|
43
|
+
isOpen = false,
|
|
44
|
+
showToggle = false,
|
|
45
|
+
children,
|
|
46
|
+
}: AccordionPropsType,
|
|
47
|
+
ref,
|
|
48
|
+
) => {
|
|
49
|
+
const [accordionIsOpen, setAccordionIsOpen] = React.useState(isOpen);
|
|
50
|
+
|
|
51
|
+
const [checked, setChecked] = React.useState<boolean>(false);
|
|
52
|
+
|
|
53
|
+
const handleToggle = () => {
|
|
54
|
+
setChecked(!checked);
|
|
55
|
+
onToggle?.(id, !checked);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const handleAccordionClick = () => {
|
|
59
|
+
if (!disabled) {
|
|
60
|
+
onChange?.(id, !accordionIsOpen);
|
|
61
|
+
setAccordionIsOpen((prev) => !prev);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
setAccordionIsOpen(isOpen);
|
|
67
|
+
}, [isOpen]);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div
|
|
71
|
+
ref={ref}
|
|
72
|
+
data-testid="Accordion"
|
|
73
|
+
className={classify(css.wrapper, classNames?.wrapper)}
|
|
74
|
+
>
|
|
75
|
+
<div
|
|
76
|
+
className={classify(css.headerWrapper, classNames?.headerWrapper)}
|
|
77
|
+
onClick={handleAccordionClick}
|
|
78
|
+
>
|
|
79
|
+
<div className={classify(css.header, classNames?.header)}>
|
|
80
|
+
{showToggle && (
|
|
81
|
+
<div
|
|
82
|
+
onClick={(e) => {
|
|
83
|
+
e.stopPropagation(); // prevent toggle click from triggering accordion toggle
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
<Toggle
|
|
87
|
+
checked={checked}
|
|
88
|
+
onChange={handleToggle}
|
|
89
|
+
ariaLabel={'toggle'}
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
)}
|
|
93
|
+
{header}
|
|
94
|
+
</div>
|
|
95
|
+
<Button
|
|
96
|
+
iconLeftName={accordionIsOpen ? 'chevron-up' : 'chevron-down'}
|
|
97
|
+
disabled={disabled}
|
|
98
|
+
size="small"
|
|
99
|
+
type="ghost"
|
|
100
|
+
className={css.icon}
|
|
101
|
+
ariaLabel={'Collapse button'}
|
|
102
|
+
// we are not defining onClick here as we are using onClick of the parent here.
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
{accordionIsOpen && (
|
|
107
|
+
<div className={classify(css.content, classNames?.content)}>
|
|
108
|
+
{children}
|
|
109
|
+
</div>
|
|
110
|
+
)}
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
},
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
Accordion.displayName = 'Accordion';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
@value (
|
|
2
|
+
colorBorderPrimary,
|
|
3
|
+
colorBackgroundTertiary,
|
|
4
|
+
colorTextSecondary
|
|
5
|
+
) from '../../styles/variables/_color.css';
|
|
6
|
+
@value (
|
|
7
|
+
sizeFluid,
|
|
8
|
+
size58
|
|
9
|
+
) from '../../styles/variables/_size.css';
|
|
10
|
+
@value (
|
|
11
|
+
spaceNone,
|
|
12
|
+
spaceSmall,
|
|
13
|
+
spaceMedium,
|
|
14
|
+
spaceXSmall,
|
|
15
|
+
spaceXXSmall
|
|
16
|
+
) from '../../styles/variables/_space.css';
|
|
17
|
+
@value (
|
|
18
|
+
elevationCard
|
|
19
|
+
) from '../../styles/variables/_elevation.css';
|
|
20
|
+
@value (
|
|
21
|
+
borderWidthNone,
|
|
22
|
+
borderWidthPrimary,
|
|
23
|
+
borderRadiusSmall,
|
|
24
|
+
borderRadiusMedium,
|
|
25
|
+
borderRadiusNone,
|
|
26
|
+
borderWidthTertiary
|
|
27
|
+
) from '../../styles/variables/_border.css';
|
|
28
|
+
|
|
29
|
+
.wrapper {
|
|
30
|
+
composes: borderPrimary from '../../styles/border.module.css';
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-flow: column;
|
|
33
|
+
width: sizeFluid;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.headerWrapper {
|
|
37
|
+
composes: subTitleSmall from '../../styles/typography.module.css';
|
|
38
|
+
display: flex;
|
|
39
|
+
min-height: size58;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
align-items: center;
|
|
42
|
+
width: sizeFluid;
|
|
43
|
+
justify-content: space-between;
|
|
44
|
+
gap: spaceXSmall;
|
|
45
|
+
padding-left: spaceMedium;
|
|
46
|
+
padding-right: spaceMedium;
|
|
47
|
+
padding-top: spaceSmall;
|
|
48
|
+
padding-bottom: spaceSmall;
|
|
49
|
+
background-color: colorBackgroundTertiary;
|
|
50
|
+
z-index: elevationCard;
|
|
51
|
+
color: colorTextSecondary;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.icon {
|
|
55
|
+
padding-right: spaceMedium;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.header {
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
gap: spaceXSmall;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.content {
|
|
65
|
+
composes: borderTopPrimary from '../../styles/border.module.css';
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-flow: column;
|
|
68
|
+
background-color: colorBackgroundTertiary;
|
|
69
|
+
padding: spaceSmall;
|
|
70
|
+
gap: spaceXXSmall;
|
|
71
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AccordionGroup = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
9
|
+
var _AccordionGroupModule = _interopRequireDefault(require("./AccordionGroup.module.css"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
const AccordionGroup = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
children,
|
|
15
|
+
onAccordionClick,
|
|
16
|
+
onToggle,
|
|
17
|
+
enabledToggleIds = [],
|
|
18
|
+
initialOpenId = '',
|
|
19
|
+
classNames
|
|
20
|
+
} = _ref;
|
|
21
|
+
const [openId, setOpenedId] = React.useState(initialOpenId);
|
|
22
|
+
const [checks, setChecks] = React.useState(enabledToggleIds);
|
|
23
|
+
const handleAccordionChange = (id, isOpen) => {
|
|
24
|
+
setOpenedId(isOpen ? id : '');
|
|
25
|
+
onAccordionClick?.(id, isOpen);
|
|
26
|
+
};
|
|
27
|
+
const handleToggle = (id, checked) => {
|
|
28
|
+
setChecks(prev => checked ? [...prev, id] : prev.filter(x => x !== id));
|
|
29
|
+
setOpenedId(prev => checked ? id : prev === id ? '' : prev);
|
|
30
|
+
onToggle?.(id, checked);
|
|
31
|
+
};
|
|
32
|
+
const enhancedChildren = React.Children.map(children, child => {
|
|
33
|
+
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const childId = child.props.id;
|
|
37
|
+
const isDisabled = !checks.includes(childId);
|
|
38
|
+
const isOpen = openId === childId;
|
|
39
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
40
|
+
classNames: {
|
|
41
|
+
headerWrapper: _AccordionGroupModule.default.accordionHeaderWrapper,
|
|
42
|
+
wrapper: _AccordionGroupModule.default.accordionWrapper
|
|
43
|
+
},
|
|
44
|
+
onChange: handleAccordionChange,
|
|
45
|
+
onToggle: handleToggle,
|
|
46
|
+
showToggle: true,
|
|
47
|
+
disabled: isDisabled,
|
|
48
|
+
isOpen
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
className: (0, _classify.default)(_AccordionGroupModule.default.wrapper, classNames?.wrapper)
|
|
53
|
+
}, enhancedChildren);
|
|
54
|
+
};
|
|
55
|
+
exports.AccordionGroup = AccordionGroup;
|
|
56
|
+
AccordionGroup.displayName = 'AccordionGroup';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import classify from '../../utils/classify';
|
|
6
|
+
|
|
7
|
+
import css from './AccordionGroup.module.css';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export type AccordionGroupClassNames = $ReadOnly<{
|
|
11
|
+
wrapper?: string,
|
|
12
|
+
}>;
|
|
13
|
+
|
|
14
|
+
export type AccordionGroupPropsType = {
|
|
15
|
+
children: React.Node,
|
|
16
|
+
onAccordionClick?: (id: string, isOpen: boolean) => mixed,
|
|
17
|
+
onToggle?: (id: string, checked?: boolean) => mixed,
|
|
18
|
+
enabledToggleIds?: Array<string>,
|
|
19
|
+
initialOpenId?: string,
|
|
20
|
+
classNames?: AccordionGroupClassNames,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const AccordionGroup = ({
|
|
24
|
+
children,
|
|
25
|
+
onAccordionClick,
|
|
26
|
+
onToggle,
|
|
27
|
+
enabledToggleIds = [],
|
|
28
|
+
initialOpenId = '',
|
|
29
|
+
classNames,
|
|
30
|
+
}: AccordionGroupPropsType): React.Node => {
|
|
31
|
+
const [openId, setOpenedId] = React.useState(initialOpenId);
|
|
32
|
+
const [checks, setChecks] = React.useState(enabledToggleIds);
|
|
33
|
+
const handleAccordionChange = (id, isOpen) => {
|
|
34
|
+
setOpenedId(isOpen ? id : '');
|
|
35
|
+
onAccordionClick?.(id, isOpen);
|
|
36
|
+
};
|
|
37
|
+
const handleToggle = (id, checked) => {
|
|
38
|
+
setChecks((prev) =>
|
|
39
|
+
checked ? [...prev, id] : prev.filter((x) => x !== id),
|
|
40
|
+
);
|
|
41
|
+
setOpenedId((prev) => (checked ? id : prev === id ? '' : prev));
|
|
42
|
+
onToggle?.(id, checked);
|
|
43
|
+
};
|
|
44
|
+
const enhancedChildren = React.Children.map(children, (child) => {
|
|
45
|
+
if (!React.isValidElement(child)) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const childId = child.props.id;
|
|
50
|
+
|
|
51
|
+
const isDisabled = !checks.includes(childId);
|
|
52
|
+
|
|
53
|
+
const isOpen = openId === childId;
|
|
54
|
+
|
|
55
|
+
return React.cloneElement(child, {
|
|
56
|
+
classNames: {
|
|
57
|
+
headerWrapper: css.accordionHeaderWrapper,
|
|
58
|
+
wrapper: css.accordionWrapper,
|
|
59
|
+
},
|
|
60
|
+
onChange: handleAccordionChange,
|
|
61
|
+
onToggle: handleToggle,
|
|
62
|
+
showToggle: true,
|
|
63
|
+
disabled: isDisabled,
|
|
64
|
+
isOpen,
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div className={classify(css.wrapper, classNames?.wrapper)}>
|
|
70
|
+
{enhancedChildren}
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
AccordionGroup.displayName = 'AccordionGroup';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@value (
|
|
2
|
+
sizeFluid
|
|
3
|
+
) from '../../styles/variables/_size.css';
|
|
4
|
+
|
|
5
|
+
@value (
|
|
6
|
+
borderWidthNone,
|
|
7
|
+
borderWidthPrimary
|
|
8
|
+
) from '../../styles/variables/_border.css';
|
|
9
|
+
@value (
|
|
10
|
+
colorBorderPrimary
|
|
11
|
+
) from '../../styles/variables/_color.css';
|
|
12
|
+
|
|
13
|
+
.wrapper {
|
|
14
|
+
composes: borderPrimary from '../../styles/border.module.css';
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-flow: column;
|
|
17
|
+
width: sizeFluid;
|
|
18
|
+
overflow: auto;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.accordionWrapper {
|
|
22
|
+
border-top: borderWidthNone;
|
|
23
|
+
border-left: borderWidthNone;
|
|
24
|
+
border-right: borderWidthNone;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.accordionWrapper:last-child {
|
|
28
|
+
border-bottom: borderWidthNone;
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Accordion = require("./Accordion");
|
|
7
|
+
Object.keys(_Accordion).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _Accordion[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _Accordion[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _AccordionGroup = require("./AccordionGroup");
|
|
18
|
+
Object.keys(_AccordionGroup).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _AccordionGroup[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _AccordionGroup[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -32,6 +32,7 @@ const Pagination = exports.Pagination = /*#__PURE__*/React.forwardRef((props, re
|
|
|
32
32
|
onChange,
|
|
33
33
|
showFirstButton = style !== 'primary' && showExtraSecPaginationButtons,
|
|
34
34
|
showLastButton = style !== 'primary' && showExtraSecPaginationButtons,
|
|
35
|
+
staticPaginationLabel,
|
|
35
36
|
...restPaginationProps
|
|
36
37
|
} = props;
|
|
37
38
|
const showPageSelectionDropDown = style !== 'primary' && showExtraSecPaginationButtons;
|
|
@@ -81,7 +82,7 @@ const Pagination = exports.Pagination = /*#__PURE__*/React.forwardRef((props, re
|
|
|
81
82
|
}), !!totalPages && !!currentPage && /*#__PURE__*/React.createElement(_Text.SubTitleExtraSmall, {
|
|
82
83
|
color: "tertiary",
|
|
83
84
|
className: _PaginationModule.default.secondaryLabel
|
|
84
|
-
},
|
|
85
|
+
}, staticPaginationLabel ? staticPaginationLabel : `of ${totalPages} ${totalPages > 1 ? 'Pages' : 'Page'}`)), /*#__PURE__*/React.createElement("div", {
|
|
85
86
|
className: (0, _classify.default)(_PaginationModule.default.paginatorSlot, classNames?.paginator)
|
|
86
87
|
}, items?.map(item => /*#__PURE__*/React.createElement(_PaginationItem.PaginationItem, _extends({
|
|
87
88
|
key: item.id
|
|
@@ -41,6 +41,7 @@ export type PaginationBaseProps = {
|
|
|
41
41
|
boundaryCount?: number,
|
|
42
42
|
siblingCount?: number,
|
|
43
43
|
style?: 'primary' | 'secondary',
|
|
44
|
+
staticPaginationLabel?: string,
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
export type PaginationProps = {
|
|
@@ -78,6 +79,7 @@ export const Pagination: React$AbstractComponent<
|
|
|
78
79
|
onChange,
|
|
79
80
|
showFirstButton = style !== 'primary' && showExtraSecPaginationButtons,
|
|
80
81
|
showLastButton = style !== 'primary' && showExtraSecPaginationButtons,
|
|
82
|
+
staticPaginationLabel,
|
|
81
83
|
...restPaginationProps
|
|
82
84
|
} = props;
|
|
83
85
|
const showPageSelectionDropDown =
|
|
@@ -136,7 +138,9 @@ export const Pagination: React$AbstractComponent<
|
|
|
136
138
|
color="tertiary"
|
|
137
139
|
className={css.secondaryLabel}
|
|
138
140
|
>
|
|
139
|
-
|
|
141
|
+
{staticPaginationLabel
|
|
142
|
+
? staticPaginationLabel
|
|
143
|
+
: `of ${totalPages} ${totalPages > 1 ? 'Pages' : 'Page'}`}
|
|
140
144
|
</SubTitleExtraSmall>
|
|
141
145
|
)}
|
|
142
146
|
</>
|
package/lib/components/index.js
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _Accordion = require("./Accordion");
|
|
7
|
+
Object.keys(_Accordion).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _Accordion[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _Accordion[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
6
17
|
var _Avatar = require("./Avatar");
|
|
7
18
|
Object.keys(_Avatar).forEach(function (key) {
|
|
8
19
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -5,26 +5,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useWindowSize = useWindowSize;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
var _lodash = require("lodash");
|
|
9
|
+
const THROTTLE_DURATION = 200;
|
|
8
10
|
function useWindowSize() {
|
|
9
11
|
const [windowSize, setWindowSize] = (0, _react.useState)({
|
|
10
|
-
width: 0,
|
|
11
|
-
height: 0
|
|
12
|
+
width: typeof window !== 'undefined' ? window.innerWidth : 0,
|
|
13
|
+
height: typeof window !== 'undefined' ? window.innerHeight : 0
|
|
12
14
|
});
|
|
13
15
|
(0, _react.useEffect)(() => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const updateSize = (0, _lodash.throttle)(() => {
|
|
17
|
+
const {
|
|
18
|
+
innerWidth,
|
|
19
|
+
innerHeight
|
|
20
|
+
} = window;
|
|
21
|
+
setWindowSize(prevSize => {
|
|
22
|
+
if (prevSize.width !== innerWidth || prevSize.height !== innerHeight) {
|
|
23
|
+
return {
|
|
24
|
+
width: innerWidth,
|
|
25
|
+
height: innerHeight
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return prevSize;
|
|
18
29
|
});
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
handler();
|
|
23
|
-
window.addEventListener('resize', handler);
|
|
24
|
-
|
|
25
|
-
// Remove event listener on cleanup
|
|
30
|
+
}, THROTTLE_DURATION);
|
|
31
|
+
window.addEventListener('resize', updateSize);
|
|
32
|
+
updateSize();
|
|
26
33
|
return () => {
|
|
27
|
-
window.removeEventListener('resize',
|
|
34
|
+
window.removeEventListener('resize', updateSize);
|
|
35
|
+
updateSize.cancel();
|
|
28
36
|
};
|
|
29
37
|
}, []);
|
|
30
38
|
return windowSize;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @flow strict
|
|
2
2
|
|
|
3
3
|
import {useEffect, useState} from 'react';
|
|
4
|
+
import {throttle} from 'lodash';
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
type WindowSize = {
|
|
@@ -8,28 +9,31 @@ type WindowSize = {
|
|
|
8
9
|
height: number,
|
|
9
10
|
};
|
|
10
11
|
|
|
12
|
+
const THROTTLE_DURATION = 200;
|
|
13
|
+
|
|
11
14
|
export function useWindowSize(): WindowSize {
|
|
12
15
|
const [windowSize, setWindowSize] = useState<WindowSize>({
|
|
13
|
-
width: 0,
|
|
14
|
-
height: 0,
|
|
16
|
+
width: typeof window !== 'undefined' ? window.innerWidth : 0,
|
|
17
|
+
height: typeof window !== 'undefined' ? window.innerHeight : 0,
|
|
15
18
|
});
|
|
16
19
|
|
|
17
20
|
useEffect(() => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
height
|
|
21
|
+
const updateSize = throttle(() => {
|
|
22
|
+
const {innerWidth, innerHeight} = window;
|
|
23
|
+
setWindowSize((prevSize) => {
|
|
24
|
+
if (prevSize.width !== innerWidth || prevSize.height !== innerHeight) {
|
|
25
|
+
return {width: innerWidth, height: innerHeight};
|
|
26
|
+
}
|
|
27
|
+
return prevSize;
|
|
22
28
|
});
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// Set size at the first client-side load
|
|
26
|
-
handler();
|
|
29
|
+
}, THROTTLE_DURATION);
|
|
27
30
|
|
|
28
|
-
window.addEventListener('resize',
|
|
31
|
+
window.addEventListener('resize', updateSize);
|
|
32
|
+
updateSize();
|
|
29
33
|
|
|
30
|
-
// Remove event listener on cleanup
|
|
31
34
|
return () => {
|
|
32
|
-
window.removeEventListener('resize',
|
|
35
|
+
window.removeEventListener('resize', updateSize);
|
|
36
|
+
updateSize.cancel();
|
|
33
37
|
};
|
|
34
38
|
}, []);
|
|
35
39
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spaced-out/ui-design-system",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"description": "Sense UI components library",
|
|
6
6
|
"author": {
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"babel-preset-react-app": "^10.0.0",
|
|
79
79
|
"chalk": "^5.0.1",
|
|
80
80
|
"chromatic": "^6.11.4",
|
|
81
|
-
"cspell": "^
|
|
81
|
+
"cspell": "^9.1.2",
|
|
82
82
|
"eslint": "^8.22.0",
|
|
83
83
|
"eslint-plugin-flowtype": "^8.0.3",
|
|
84
84
|
"eslint-plugin-import": "^2.26.0",
|