@westpac/ui 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/components/alert/alert.component.js +2 -1
- package/dist/components/alert/alert.styles.js +2 -2
- package/dist/components/compacta/compacta.component.js +4 -3
- package/dist/components/flexi-cell/flexi-cell.component.js +2 -2
- package/dist/components/flexi-cell/flexi-cell.styles.js +1 -1
- package/dist/components/flexi-cell/flexi-cell.types.d.ts +4 -0
- package/dist/components/flexi-cell/index.d.ts +1 -0
- package/dist/components/flexi-cell/index.js +1 -0
- package/dist/components/icon/index.d.ts +1 -0
- package/dist/components/icon/index.js +1 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +3 -1
- package/dist/components/list/components/item/item.styles.js +1 -1
- package/dist/components/list/list.styles.js +1 -1
- package/dist/components/repeater/index.d.ts +2 -0
- package/dist/components/repeater/index.js +1 -0
- package/dist/components/repeater/repeater.component.d.ts +3 -0
- package/dist/components/repeater/repeater.component.js +141 -0
- package/dist/components/repeater/repeater.stories.d.ts +13 -0
- package/dist/components/repeater/repeater.stories.js +34 -0
- package/dist/components/repeater/repeater.styles.d.ts +39 -0
- package/dist/components/repeater/repeater.styles.js +31 -0
- package/dist/components/repeater/repeater.types.d.ts +19 -0
- package/dist/components/repeater/repeater.types.js +1 -0
- package/dist/components/repeater/repeater.utils.d.ts +2 -0
- package/dist/components/repeater/repeater.utils.js +2 -0
- package/dist/components/selector/components/index.d.ts +2 -0
- package/dist/components/selector/components/index.js +2 -0
- package/dist/components/selector/components/selector-checkbox-group/components/index.d.ts +1 -0
- package/dist/components/selector/components/selector-checkbox-group/components/index.js +1 -0
- package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/index.d.ts +2 -0
- package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/index.js +1 -0
- package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.component.d.ts +12 -0
- package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.component.js +67 -0
- package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.styles.d.ts +59 -0
- package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.styles.js +57 -0
- package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.types.d.ts +10 -0
- package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.types.js +1 -0
- package/dist/components/selector/components/selector-checkbox-group/index.d.ts +2 -0
- package/dist/components/selector/components/selector-checkbox-group/index.js +1 -0
- package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.d.ts +15 -0
- package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.js +49 -0
- package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.styles.d.ts +3 -0
- package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.styles.js +13 -0
- package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.types.d.ts +20 -0
- package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.types.js +1 -0
- package/dist/components/selector/components/selector-radio-group/components/index.d.ts +1 -0
- package/dist/components/selector/components/selector-radio-group/components/index.js +1 -0
- package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/index.d.ts +2 -0
- package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/index.js +1 -0
- package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.d.ts +12 -0
- package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.js +67 -0
- package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.styles.d.ts +59 -0
- package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.styles.js +57 -0
- package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.types.d.ts +15 -0
- package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.types.js +1 -0
- package/dist/components/selector/components/selector-radio-group/index.d.ts +2 -0
- package/dist/components/selector/components/selector-radio-group/index.js +1 -0
- package/dist/components/selector/components/selector-radio-group/selector-radio-group.component.d.ts +15 -0
- package/dist/components/selector/components/selector-radio-group/selector-radio-group.component.js +58 -0
- package/dist/components/selector/components/selector-radio-group/selector-radio-group.styles.d.ts +13 -0
- package/dist/components/selector/components/selector-radio-group/selector-radio-group.styles.js +18 -0
- package/dist/components/selector/components/selector-radio-group/selector-radio-group.types.d.ts +17 -0
- package/dist/components/selector/components/selector-radio-group/selector-radio-group.types.js +1 -0
- package/dist/components/selector/index.d.ts +2 -0
- package/dist/components/selector/index.js +1 -0
- package/dist/components/selector/selector.component.d.ts +30 -0
- package/dist/components/selector/selector.component.js +34 -0
- package/dist/components/selector/selector.stories.d.ts +57 -0
- package/dist/components/selector/selector.stories.js +515 -0
- package/dist/components/selector/selector.types.d.ts +20 -0
- package/dist/components/selector/selector.types.js +1 -0
- package/dist/css/westpac-ui.css +150 -0
- package/dist/css/westpac-ui.min.css +150 -0
- package/dist/utils/generateId.d.ts +1 -0
- package/dist/utils/generateId.js +6 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +7 -1
- package/src/components/alert/alert.component.tsx +1 -1
- package/src/components/alert/alert.styles.ts +2 -2
- package/src/components/compacta/compacta.component.tsx +4 -3
- package/src/components/flexi-cell/flexi-cell.component.tsx +2 -1
- package/src/components/flexi-cell/flexi-cell.styles.ts +1 -1
- package/src/components/flexi-cell/flexi-cell.types.ts +4 -0
- package/src/components/flexi-cell/index.ts +1 -0
- package/src/components/icon/index.ts +1 -0
- package/src/components/index.ts +3 -1
- package/src/components/list/components/item/item.styles.ts +1 -1
- package/src/components/list/list.styles.ts +1 -1
- package/src/components/repeater/index.ts +2 -0
- package/src/components/repeater/repeater.component.tsx +121 -0
- package/src/components/repeater/repeater.stories.tsx +49 -0
- package/src/components/repeater/repeater.styles.ts +27 -0
- package/src/components/repeater/repeater.types.ts +20 -0
- package/src/components/repeater/repeater.utils.tsx +3 -0
- package/src/components/selector/components/index.ts +2 -0
- package/src/components/selector/components/selector-checkbox-group/components/index.ts +1 -0
- package/src/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/index.ts +2 -0
- package/src/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.component.tsx +96 -0
- package/src/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.styles.ts +53 -0
- package/src/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.types.ts +15 -0
- package/src/components/selector/components/selector-checkbox-group/index.ts +2 -0
- package/src/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.tsx +46 -0
- package/src/components/selector/components/selector-checkbox-group/selector-checkbox-group.styles.ts +9 -0
- package/src/components/selector/components/selector-checkbox-group/selector-checkbox-group.types.ts +25 -0
- package/src/components/selector/components/selector-radio-group/components/index.ts +1 -0
- package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/index.ts +2 -0
- package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.tsx +90 -0
- package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.styles.ts +53 -0
- package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.types.ts +21 -0
- package/src/components/selector/components/selector-radio-group/index.ts +2 -0
- package/src/components/selector/components/selector-radio-group/selector-radio-group.component.tsx +48 -0
- package/src/components/selector/components/selector-radio-group/selector-radio-group.styles.ts +14 -0
- package/src/components/selector/components/selector-radio-group/selector-radio-group.types.ts +22 -0
- package/src/components/selector/index.ts +2 -0
- package/src/components/selector/selector.component.tsx +34 -0
- package/src/components/selector/selector.stories.tsx +621 -0
- package/src/components/selector/selector.types.ts +24 -0
- package/src/utils/generateId.ts +6 -0
- package/src/utils/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -71,7 +71,8 @@ export function Alert({ look ='info' , mode ='box' , heading , headingTag: Headi
|
|
|
71
71
|
size: {
|
|
72
72
|
initial: 'small',
|
|
73
73
|
xsl: 'medium'
|
|
74
|
-
}
|
|
74
|
+
},
|
|
75
|
+
look: "outlined"
|
|
75
76
|
})), React.createElement("div", {
|
|
76
77
|
className: styles.body()
|
|
77
78
|
}, !!heading && React.createElement(HeadingTag, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { tv } from 'tailwind-variants';
|
|
2
2
|
export const styles = tv({
|
|
3
3
|
slots: {
|
|
4
|
-
base: 'typography-body-10 relative mb-4
|
|
4
|
+
base: 'typography-body-10 relative mb-4 xsl:flex',
|
|
5
5
|
icon: 'float-left mr-1 flex-none xsl:mr-2',
|
|
6
6
|
body: 'relative flex-1 xsl:top-[0.125rem] [&_a]:underline',
|
|
7
7
|
heading: 'typography-body-9 mb-2 font-bold',
|
|
@@ -27,7 +27,7 @@ export const styles = tv({
|
|
|
27
27
|
},
|
|
28
28
|
mode: {
|
|
29
29
|
box: {
|
|
30
|
-
base: 'border-y'
|
|
30
|
+
base: 'border-y p-3'
|
|
31
31
|
},
|
|
32
32
|
text: {
|
|
33
33
|
base: 'bg-[transparent]'
|
|
@@ -14,10 +14,11 @@ function _extends() {
|
|
|
14
14
|
}
|
|
15
15
|
import { AnimatePresence, LazyMotion, m } from 'framer-motion';
|
|
16
16
|
import React, { useCallback, useEffect, useId, useRef, useState } from 'react';
|
|
17
|
+
import { generateID } from '../../utils/index.js';
|
|
18
|
+
import { Button } from '../button/index.js';
|
|
17
19
|
import { AddCircleIcon, ExpandLessIcon, ExpandMoreIcon, RemoveCircleIcon } from '../icon/index.js';
|
|
18
|
-
import {
|
|
20
|
+
import { VisuallyHidden } from '../index.js';
|
|
19
21
|
import { styles as compactaStyles } from './compacta.styles.js';
|
|
20
|
-
import { generateID } from './compacta.utils.js';
|
|
21
22
|
const loadAnimations = ()=>import('./compacta.utils.js').then((res)=>res.default);
|
|
22
23
|
export function Compacta({ className , children , titleTag: Tag = 'h3' , addText ='Add another' , ...props }) {
|
|
23
24
|
const [initial, setInitial] = useState(true);
|
|
@@ -121,7 +122,7 @@ export function Compacta({ className , children , titleTag: Tag = 'h3' , addText
|
|
|
121
122
|
var _headingRefs_current_action_index;
|
|
122
123
|
(_headingRefs_current_action_index = headingRefs === null || headingRefs === void 0 ? void 0 : headingRefs.current[action.index]) === null || _headingRefs_current_action_index === void 0 ? void 0 : _headingRefs_current_action_index.focus();
|
|
123
124
|
}, 1);
|
|
124
|
-
setStatus(`Item
|
|
125
|
+
setStatus(`Item added`);
|
|
125
126
|
}
|
|
126
127
|
if (action.type === 'remove') {
|
|
127
128
|
headingRefs.current.splice(action.index, 1);
|
|
@@ -16,11 +16,11 @@ import React, { forwardRef } from 'react';
|
|
|
16
16
|
import { ArrowRightIcon } from '../icon/index.js';
|
|
17
17
|
import { FlexiCellAdornment, FlexiCellBody, FlexiCellButton, FlexiCellCircle, FlexiCellFooter, FlexiCellHint, FlexiCellLabel } from './components/index.js';
|
|
18
18
|
import { styles as flexiCellStyles } from './flexi-cell.styles.js';
|
|
19
|
-
function FlexiCellBase({ className , tag: Tag = 'div' , children , badge , before , body , after , withArrow , withBorder =false , href , ...props }, ref) {
|
|
19
|
+
function FlexiCellBase({ className , tag: Tag = 'div' , children , badge , before , body , after , withArrow , withBorder =false , href , withHoverEffect =false , ...props }, ref) {
|
|
20
20
|
const styles = flexiCellStyles({
|
|
21
21
|
className,
|
|
22
22
|
withBorder,
|
|
23
|
-
isLink: !!href
|
|
23
|
+
isLink: !!href || withHoverEffect
|
|
24
24
|
});
|
|
25
25
|
return React.createElement(Tag, _extends({}, {
|
|
26
26
|
ref
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { tv } from 'tailwind-variants';
|
|
2
2
|
export const styles = tv({
|
|
3
3
|
slots: {
|
|
4
|
-
base: 'relative flex gap-2 bg-white
|
|
4
|
+
base: 'relative flex gap-2 bg-white p-2 transition-colors focus:focus-outline md:p-3',
|
|
5
5
|
bodyWrapper: 'flex flex-1 flex-col',
|
|
6
6
|
badge: 'absolute right-0 top-0'
|
|
7
7
|
},
|
|
@@ -232,4 +232,5 @@ export { RAMSLogoIcon } from './components/rams-logo-icon.js';
|
|
|
232
232
|
export { STGLogoIcon } from './components/stg-logo-icon.js';
|
|
233
233
|
export { WBCLogoIcon } from './components/wbc-logo-icon.js';
|
|
234
234
|
export { WBGLogoIcon } from './components/wbg-logo-icon.js';
|
|
235
|
+
export { Icon } from './icon.component.js';
|
|
235
236
|
export { type IconProps } from './icon.types.js';
|
|
@@ -232,3 +232,4 @@ export { RAMSLogoIcon } from './components/rams-logo-icon.js';
|
|
|
232
232
|
export { STGLogoIcon } from './components/stg-logo-icon.js';
|
|
233
233
|
export { WBCLogoIcon } from './components/wbc-logo-icon.js';
|
|
234
234
|
export { WBGLogoIcon } from './components/wbg-logo-icon.js';
|
|
235
|
+
export { Icon } from './icon.component.js';
|
|
@@ -23,7 +23,7 @@ export * from './panel/index.js';
|
|
|
23
23
|
export * from './collapsible/index.js';
|
|
24
24
|
export * from './list/index.js';
|
|
25
25
|
export * from './circle/index.js';
|
|
26
|
-
export
|
|
26
|
+
export { FlexiCell, type FlexiCellProps } from './flexi-cell/index.js';
|
|
27
27
|
export * from './autocomplete/index.js';
|
|
28
28
|
export * from './button-dropdown/index.js';
|
|
29
29
|
export * from './form/index.js';
|
|
@@ -32,4 +32,6 @@ export * from './modal/index.js';
|
|
|
32
32
|
export * from './pagination/index.js';
|
|
33
33
|
export * from './popover/index.js';
|
|
34
34
|
export * from './progress-rope/index.js';
|
|
35
|
+
export * from './selector/index.js';
|
|
35
36
|
export * from './compacta/index.js';
|
|
37
|
+
export * from './repeater/index.js';
|
package/dist/components/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export * from './panel/index.js';
|
|
|
23
23
|
export * from './collapsible/index.js';
|
|
24
24
|
export * from './list/index.js';
|
|
25
25
|
export * from './circle/index.js';
|
|
26
|
-
export
|
|
26
|
+
export { FlexiCell } from './flexi-cell/index.js';
|
|
27
27
|
export * from './autocomplete/index.js';
|
|
28
28
|
export * from './button-dropdown/index.js';
|
|
29
29
|
export * from './form/index.js';
|
|
@@ -32,4 +32,6 @@ export * from './modal/index.js';
|
|
|
32
32
|
export * from './pagination/index.js';
|
|
33
33
|
export * from './popover/index.js';
|
|
34
34
|
export * from './progress-rope/index.js';
|
|
35
|
+
export * from './selector/index.js';
|
|
35
36
|
export * from './compacta/index.js';
|
|
37
|
+
export * from './repeater/index.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { tv } from 'tailwind-variants';
|
|
2
2
|
export const styles = tv({
|
|
3
3
|
slots: {
|
|
4
|
-
base: '
|
|
4
|
+
base: 'pl-[1.1875rem]',
|
|
5
5
|
bullet: 'absolute block border',
|
|
6
6
|
link: 'text-text hover:cursor-pointer hover:underline focus:focus-outline',
|
|
7
7
|
wrapper: 'relative'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Repeater } from './repeater.component.js';
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
function _extends() {
|
|
2
|
+
_extends = Object.assign || function(target) {
|
|
3
|
+
for(var i = 1; i < arguments.length; i++){
|
|
4
|
+
var source = arguments[i];
|
|
5
|
+
for(var key in source){
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
+
target[key] = source[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
return _extends.apply(this, arguments);
|
|
14
|
+
}
|
|
15
|
+
import { AnimatePresence, LazyMotion, m } from 'framer-motion';
|
|
16
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
17
|
+
import { generateID } from '../../utils/index.js';
|
|
18
|
+
import { Button } from '../button/index.js';
|
|
19
|
+
import { AddCircleIcon, RemoveCircleIcon } from '../icon/index.js';
|
|
20
|
+
import { VisuallyHidden } from '../index.js';
|
|
21
|
+
import { styles as repeaterStyles } from './repeater.styles.js';
|
|
22
|
+
const loadAnimations = ()=>import('./repeater.utils.js').then((res)=>res.default);
|
|
23
|
+
export function Repeater({ addText ='Add another item' , indexTag: ItemIndex = 'h3' , children , separator =false , className }) {
|
|
24
|
+
const [items, setItems] = useState([
|
|
25
|
+
{
|
|
26
|
+
id: generateID()
|
|
27
|
+
}
|
|
28
|
+
]);
|
|
29
|
+
const [action, setAction] = useState({
|
|
30
|
+
type: '',
|
|
31
|
+
index: 0
|
|
32
|
+
});
|
|
33
|
+
const [status, setStatus] = useState('');
|
|
34
|
+
const refArr = useRef([]);
|
|
35
|
+
const handleAdd = useCallback(()=>{
|
|
36
|
+
setItems([
|
|
37
|
+
...items,
|
|
38
|
+
{
|
|
39
|
+
id: generateID()
|
|
40
|
+
}
|
|
41
|
+
]);
|
|
42
|
+
setAction({
|
|
43
|
+
type: 'add',
|
|
44
|
+
index: items.length
|
|
45
|
+
});
|
|
46
|
+
}, [
|
|
47
|
+
items
|
|
48
|
+
]);
|
|
49
|
+
const handleRemove = useCallback((id, index)=>{
|
|
50
|
+
const newItems = items.filter((item)=>item.id !== id);
|
|
51
|
+
setItems(newItems);
|
|
52
|
+
setAction({
|
|
53
|
+
type: 'remove',
|
|
54
|
+
index,
|
|
55
|
+
id
|
|
56
|
+
});
|
|
57
|
+
}, [
|
|
58
|
+
items
|
|
59
|
+
]);
|
|
60
|
+
useEffect(()=>{
|
|
61
|
+
if (action.type === 'add') {
|
|
62
|
+
var _refArr_current_;
|
|
63
|
+
(_refArr_current_ = refArr.current[items.length - 1]) === null || _refArr_current_ === void 0 ? void 0 : _refArr_current_.focus();
|
|
64
|
+
setStatus(`Item added`);
|
|
65
|
+
}
|
|
66
|
+
if (action.type === 'remove') {
|
|
67
|
+
var _refArr_current_focusIndex;
|
|
68
|
+
refArr.current.splice(action.index, 1);
|
|
69
|
+
const focusIndex = action.index === 0 ? 0 : action.index - 1;
|
|
70
|
+
(_refArr_current_focusIndex = refArr.current[focusIndex]) === null || _refArr_current_focusIndex === void 0 ? void 0 : _refArr_current_focusIndex.focus();
|
|
71
|
+
setStatus(`Item ${action.index + 1} removed`);
|
|
72
|
+
}
|
|
73
|
+
}, [
|
|
74
|
+
items.length,
|
|
75
|
+
action
|
|
76
|
+
]);
|
|
77
|
+
const Tag = separator ? 'ol' : 'ul';
|
|
78
|
+
const styles = repeaterStyles({
|
|
79
|
+
separator
|
|
80
|
+
});
|
|
81
|
+
return React.createElement("div", {
|
|
82
|
+
className: styles.base({
|
|
83
|
+
className
|
|
84
|
+
})
|
|
85
|
+
}, React.createElement(Tag, {
|
|
86
|
+
className: styles.list()
|
|
87
|
+
}, React.createElement(LazyMotion, {
|
|
88
|
+
features: loadAnimations
|
|
89
|
+
}, React.createElement(AnimatePresence, null, items.map((item, index)=>{
|
|
90
|
+
return React.createElement(m.li, {
|
|
91
|
+
initial: {
|
|
92
|
+
opacity: 1
|
|
93
|
+
},
|
|
94
|
+
animate: {
|
|
95
|
+
opacity: 1
|
|
96
|
+
},
|
|
97
|
+
exit: {
|
|
98
|
+
opacity: 0
|
|
99
|
+
},
|
|
100
|
+
transition: {
|
|
101
|
+
duration: 0.15
|
|
102
|
+
},
|
|
103
|
+
key: index
|
|
104
|
+
}, React.createElement("div", {
|
|
105
|
+
ref: (el)=>{
|
|
106
|
+
refArr.current[index] = el;
|
|
107
|
+
},
|
|
108
|
+
tabIndex: -1,
|
|
109
|
+
className: styles.item()
|
|
110
|
+
}, separator && React.createElement(ItemIndex, {
|
|
111
|
+
className: styles.itemIndex()
|
|
112
|
+
}, index + 1, "."), React.createElement("div", {
|
|
113
|
+
className: styles.content()
|
|
114
|
+
}, children), items.length > 1 && React.createElement(Button, {
|
|
115
|
+
className: styles.removeBtn(),
|
|
116
|
+
"aria-label": `remove item ${index + 1}`,
|
|
117
|
+
iconBefore: (props)=>React.createElement(RemoveCircleIcon, _extends({}, props, {
|
|
118
|
+
"aria-hidden": true,
|
|
119
|
+
size: "xsmall"
|
|
120
|
+
})),
|
|
121
|
+
look: "link",
|
|
122
|
+
size: "small",
|
|
123
|
+
soft: true,
|
|
124
|
+
onClick: ()=>handleRemove(item.id, index)
|
|
125
|
+
}, "Remove")));
|
|
126
|
+
})))), React.createElement("div", {
|
|
127
|
+
className: styles.footer()
|
|
128
|
+
}, React.createElement(Button, {
|
|
129
|
+
className: styles.addBtn(),
|
|
130
|
+
iconBefore: (props)=>React.createElement(AddCircleIcon, _extends({}, props, {
|
|
131
|
+
"aria-hidden": true,
|
|
132
|
+
look: "outlined"
|
|
133
|
+
})),
|
|
134
|
+
look: "link",
|
|
135
|
+
size: "small",
|
|
136
|
+
soft: true,
|
|
137
|
+
onClick: ()=>handleAdd()
|
|
138
|
+
}, addText)), React.createElement(VisuallyHidden, {
|
|
139
|
+
role: "status"
|
|
140
|
+
}, status));
|
|
141
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Meta, type StoryObj } from '@storybook/react';
|
|
2
|
+
import { Repeater } from './repeater.component.js';
|
|
3
|
+
declare const meta: Meta<typeof Repeater>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
/**
|
|
7
|
+
* > Default usage example
|
|
8
|
+
*/
|
|
9
|
+
export declare const DefaultStory: Story;
|
|
10
|
+
/**
|
|
11
|
+
* > Example using the separator prop
|
|
12
|
+
*/
|
|
13
|
+
export declare const SeparatedRepeater: Story;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Form, Input } from '../index.js';
|
|
2
|
+
import { Repeater } from './repeater.component.js';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Example/Repeater',
|
|
5
|
+
component: Repeater,
|
|
6
|
+
tags: [
|
|
7
|
+
'autodocs'
|
|
8
|
+
],
|
|
9
|
+
decorators: [
|
|
10
|
+
(Story)=>React.createElement("div", {
|
|
11
|
+
className: "p-5"
|
|
12
|
+
}, React.createElement(Story, null))
|
|
13
|
+
],
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: 'fullscreen'
|
|
16
|
+
},
|
|
17
|
+
args: {
|
|
18
|
+
children: React.createElement(Form, null, React.createElement(Form.Group, null, React.createElement(Form.Label, {
|
|
19
|
+
htmlFor: `test`
|
|
20
|
+
}, "Primary"), React.createElement(Form.Hint, null, "Primary title text"), React.createElement(Input, {
|
|
21
|
+
name: `test`,
|
|
22
|
+
onChange: (e)=>console.log(e)
|
|
23
|
+
})))
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export default meta;
|
|
27
|
+
export const DefaultStory = {
|
|
28
|
+
args: {}
|
|
29
|
+
};
|
|
30
|
+
export const SeparatedRepeater = {
|
|
31
|
+
args: {
|
|
32
|
+
separator: true
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
separator: {
|
|
3
|
+
true: {
|
|
4
|
+
item: string;
|
|
5
|
+
content: string;
|
|
6
|
+
removeBtn: string;
|
|
7
|
+
footer: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}, {
|
|
11
|
+
base: string;
|
|
12
|
+
list: string;
|
|
13
|
+
item: string;
|
|
14
|
+
itemIndex: string;
|
|
15
|
+
content: string;
|
|
16
|
+
removeBtn: string;
|
|
17
|
+
footer: string;
|
|
18
|
+
addBtn: string;
|
|
19
|
+
}, undefined, {
|
|
20
|
+
responsiveVariants: string[];
|
|
21
|
+
}, {
|
|
22
|
+
separator: {
|
|
23
|
+
true: {
|
|
24
|
+
item: string;
|
|
25
|
+
content: string;
|
|
26
|
+
removeBtn: string;
|
|
27
|
+
footer: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}, {
|
|
31
|
+
base: string;
|
|
32
|
+
list: string;
|
|
33
|
+
item: string;
|
|
34
|
+
itemIndex: string;
|
|
35
|
+
content: string;
|
|
36
|
+
removeBtn: string;
|
|
37
|
+
footer: string;
|
|
38
|
+
addBtn: string;
|
|
39
|
+
}>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const styles = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
base: '',
|
|
5
|
+
list: 'm-0 list-none pl-0',
|
|
6
|
+
item: 'relative focus:outline-none',
|
|
7
|
+
itemIndex: 'mb-[1.125rem] font-bold',
|
|
8
|
+
content: '',
|
|
9
|
+
removeBtn: 'absolute right-0 top-0 h-auto p-0 no-underline hover:underline',
|
|
10
|
+
footer: 'flex justify-between',
|
|
11
|
+
addBtn: 'height-auto p-0 no-underline hover:underline'
|
|
12
|
+
},
|
|
13
|
+
variants: {
|
|
14
|
+
separator: {
|
|
15
|
+
true: {
|
|
16
|
+
item: 'border-neutral border-t-2 pt-[0.625rem]',
|
|
17
|
+
content: 'p-[0_1.125rem_2.625rem]',
|
|
18
|
+
removeBtn: 'relative m-[0_0_1.875rem_1.125rem]',
|
|
19
|
+
footer: 'border-neutral border-t-2 pt-[0.875rem]'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}, {
|
|
24
|
+
responsiveVariants: [
|
|
25
|
+
'xsl',
|
|
26
|
+
'sm',
|
|
27
|
+
'md',
|
|
28
|
+
'lg',
|
|
29
|
+
'xl'
|
|
30
|
+
]
|
|
31
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export type RepeaterProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Text for add button
|
|
5
|
+
*/
|
|
6
|
+
addText?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Component to repeat
|
|
9
|
+
*/
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Index heading tag to use for index on separator version
|
|
13
|
+
*/
|
|
14
|
+
indexTag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
15
|
+
/**
|
|
16
|
+
* Enable separator version
|
|
17
|
+
*/
|
|
18
|
+
separator?: boolean;
|
|
19
|
+
} & HTMLAttributes<Element>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './selector-checkbox-group-option/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './selector-checkbox-group-option/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectorCheckboxGroupOption } from './selector-checkbox-group-option.component.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlexiCell } from '../../../../../../components/index.js';
|
|
3
|
+
import { type SelectorCheckboxGroupOptionProps } from './selector-checkbox-group-option.types.js';
|
|
4
|
+
export declare const SelectorCheckboxGroupOption: React.ForwardRefExoticComponent<SelectorCheckboxGroupOptionProps & React.RefAttributes<unknown>> & {
|
|
5
|
+
Adornment: typeof FlexiCell.Adornment;
|
|
6
|
+
Body: typeof FlexiCell.Body;
|
|
7
|
+
Button: typeof FlexiCell.Button;
|
|
8
|
+
Circle: typeof FlexiCell.Circle;
|
|
9
|
+
Footer: typeof FlexiCell.Footer;
|
|
10
|
+
Hint: typeof FlexiCell.Hint;
|
|
11
|
+
Label: typeof FlexiCell.Label;
|
|
12
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
function _extends() {
|
|
2
|
+
_extends = Object.assign || function(target) {
|
|
3
|
+
for(var i = 1; i < arguments.length; i++){
|
|
4
|
+
var source = arguments[i];
|
|
5
|
+
for(var key in source){
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
+
target[key] = source[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
return _extends.apply(this, arguments);
|
|
14
|
+
}
|
|
15
|
+
import React, { forwardRef, useContext, useRef } from 'react';
|
|
16
|
+
import { VisuallyHidden, useCheckboxGroupItem, useFocusRing } from 'react-aria';
|
|
17
|
+
import { FlexiCellAdornment, FlexiCellBody, FlexiCellButton, FlexiCellCircle, FlexiCellFooter, FlexiCellHint, FlexiCellLabel } from '../../../../../../components/flexi-cell/index.js';
|
|
18
|
+
import { ArrowRightIcon, TickIcon } from '../../../../../../components/icon/index.js';
|
|
19
|
+
import { FlexiCell } from '../../../../../../components/index.js';
|
|
20
|
+
import { SelectorCheckboxGroupContext } from '../../selector-checkbox-group.component.js';
|
|
21
|
+
import { styles as selectorCheckboxGroupOptionStyles } from './selector-checkbox-group-option.styles.js';
|
|
22
|
+
function BaseSelectorCheckboxGroupOption({ className , children , value , withBorder =true , withArrow , after , badge , badgeZIndex , before , body =true , checkIcon ='checkbox' , ...props }, ref) {
|
|
23
|
+
const state = useContext(SelectorCheckboxGroupContext);
|
|
24
|
+
const localRef = useRef(null);
|
|
25
|
+
const { inputProps , isDisabled , isSelected } = useCheckboxGroupItem({
|
|
26
|
+
...props,
|
|
27
|
+
value,
|
|
28
|
+
children
|
|
29
|
+
}, state, localRef);
|
|
30
|
+
const { isFocusVisible , focusProps } = useFocusRing();
|
|
31
|
+
const styles = selectorCheckboxGroupOptionStyles({
|
|
32
|
+
className,
|
|
33
|
+
isSelected,
|
|
34
|
+
isFocusVisible,
|
|
35
|
+
isDisabled,
|
|
36
|
+
checkIcon
|
|
37
|
+
});
|
|
38
|
+
const FinalIcon = checkIcon === 'checkbox' ? TickIcon : ArrowRightIcon;
|
|
39
|
+
return React.createElement(FlexiCell, {
|
|
40
|
+
after: React.createElement("div", {
|
|
41
|
+
className: "flex gap-2"
|
|
42
|
+
}, after, React.createElement(FinalIcon, {
|
|
43
|
+
"aria-hidden": "true",
|
|
44
|
+
className: styles.icon({})
|
|
45
|
+
})),
|
|
46
|
+
badge: badge,
|
|
47
|
+
badgeZIndex: badgeZIndex,
|
|
48
|
+
before: before,
|
|
49
|
+
body: body,
|
|
50
|
+
withBorder: withBorder,
|
|
51
|
+
withArrow: withArrow,
|
|
52
|
+
tag: "label",
|
|
53
|
+
ref: ref,
|
|
54
|
+
withHoverEffect: true,
|
|
55
|
+
className: styles.base({})
|
|
56
|
+
}, React.createElement(VisuallyHidden, null, React.createElement("input", _extends({}, inputProps, focusProps, {
|
|
57
|
+
ref: localRef
|
|
58
|
+
}))), children);
|
|
59
|
+
}
|
|
60
|
+
export const SelectorCheckboxGroupOption = forwardRef(BaseSelectorCheckboxGroupOption);
|
|
61
|
+
SelectorCheckboxGroupOption.Body = FlexiCellBody;
|
|
62
|
+
SelectorCheckboxGroupOption.Footer = FlexiCellFooter;
|
|
63
|
+
SelectorCheckboxGroupOption.Adornment = FlexiCellAdornment;
|
|
64
|
+
SelectorCheckboxGroupOption.Hint = FlexiCellHint;
|
|
65
|
+
SelectorCheckboxGroupOption.Label = FlexiCellLabel;
|
|
66
|
+
SelectorCheckboxGroupOption.Button = FlexiCellButton;
|
|
67
|
+
SelectorCheckboxGroupOption.Circle = FlexiCellCircle;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
checkIcon: {
|
|
3
|
+
arrow: {
|
|
4
|
+
icon: string;
|
|
5
|
+
};
|
|
6
|
+
checkbox: {};
|
|
7
|
+
};
|
|
8
|
+
isSelected: {
|
|
9
|
+
true: {
|
|
10
|
+
base: string;
|
|
11
|
+
};
|
|
12
|
+
false: {};
|
|
13
|
+
};
|
|
14
|
+
isFocusVisible: {
|
|
15
|
+
true: {
|
|
16
|
+
base: string;
|
|
17
|
+
};
|
|
18
|
+
false: {};
|
|
19
|
+
};
|
|
20
|
+
isDisabled: {
|
|
21
|
+
true: {
|
|
22
|
+
base: string;
|
|
23
|
+
};
|
|
24
|
+
false: {};
|
|
25
|
+
};
|
|
26
|
+
}, {
|
|
27
|
+
base: string;
|
|
28
|
+
icon: string;
|
|
29
|
+
}, undefined, {
|
|
30
|
+
responsiveVariants: string[];
|
|
31
|
+
}, {
|
|
32
|
+
checkIcon: {
|
|
33
|
+
arrow: {
|
|
34
|
+
icon: string;
|
|
35
|
+
};
|
|
36
|
+
checkbox: {};
|
|
37
|
+
};
|
|
38
|
+
isSelected: {
|
|
39
|
+
true: {
|
|
40
|
+
base: string;
|
|
41
|
+
};
|
|
42
|
+
false: {};
|
|
43
|
+
};
|
|
44
|
+
isFocusVisible: {
|
|
45
|
+
true: {
|
|
46
|
+
base: string;
|
|
47
|
+
};
|
|
48
|
+
false: {};
|
|
49
|
+
};
|
|
50
|
+
isDisabled: {
|
|
51
|
+
true: {
|
|
52
|
+
base: string;
|
|
53
|
+
};
|
|
54
|
+
false: {};
|
|
55
|
+
};
|
|
56
|
+
}, {
|
|
57
|
+
base: string;
|
|
58
|
+
icon: string;
|
|
59
|
+
}>;
|