@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.
Files changed (122) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/components/alert/alert.component.js +2 -1
  3. package/dist/components/alert/alert.styles.js +2 -2
  4. package/dist/components/compacta/compacta.component.js +4 -3
  5. package/dist/components/flexi-cell/flexi-cell.component.js +2 -2
  6. package/dist/components/flexi-cell/flexi-cell.styles.js +1 -1
  7. package/dist/components/flexi-cell/flexi-cell.types.d.ts +4 -0
  8. package/dist/components/flexi-cell/index.d.ts +1 -0
  9. package/dist/components/flexi-cell/index.js +1 -0
  10. package/dist/components/icon/index.d.ts +1 -0
  11. package/dist/components/icon/index.js +1 -0
  12. package/dist/components/index.d.ts +3 -1
  13. package/dist/components/index.js +3 -1
  14. package/dist/components/list/components/item/item.styles.js +1 -1
  15. package/dist/components/list/list.styles.js +1 -1
  16. package/dist/components/repeater/index.d.ts +2 -0
  17. package/dist/components/repeater/index.js +1 -0
  18. package/dist/components/repeater/repeater.component.d.ts +3 -0
  19. package/dist/components/repeater/repeater.component.js +141 -0
  20. package/dist/components/repeater/repeater.stories.d.ts +13 -0
  21. package/dist/components/repeater/repeater.stories.js +34 -0
  22. package/dist/components/repeater/repeater.styles.d.ts +39 -0
  23. package/dist/components/repeater/repeater.styles.js +31 -0
  24. package/dist/components/repeater/repeater.types.d.ts +19 -0
  25. package/dist/components/repeater/repeater.types.js +1 -0
  26. package/dist/components/repeater/repeater.utils.d.ts +2 -0
  27. package/dist/components/repeater/repeater.utils.js +2 -0
  28. package/dist/components/selector/components/index.d.ts +2 -0
  29. package/dist/components/selector/components/index.js +2 -0
  30. package/dist/components/selector/components/selector-checkbox-group/components/index.d.ts +1 -0
  31. package/dist/components/selector/components/selector-checkbox-group/components/index.js +1 -0
  32. package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/index.d.ts +2 -0
  33. package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/index.js +1 -0
  34. package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.component.d.ts +12 -0
  35. package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.component.js +67 -0
  36. package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.styles.d.ts +59 -0
  37. package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.styles.js +57 -0
  38. package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.types.d.ts +10 -0
  39. package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.types.js +1 -0
  40. package/dist/components/selector/components/selector-checkbox-group/index.d.ts +2 -0
  41. package/dist/components/selector/components/selector-checkbox-group/index.js +1 -0
  42. package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.d.ts +15 -0
  43. package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.js +49 -0
  44. package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.styles.d.ts +3 -0
  45. package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.styles.js +13 -0
  46. package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.types.d.ts +20 -0
  47. package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.types.js +1 -0
  48. package/dist/components/selector/components/selector-radio-group/components/index.d.ts +1 -0
  49. package/dist/components/selector/components/selector-radio-group/components/index.js +1 -0
  50. package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/index.d.ts +2 -0
  51. package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/index.js +1 -0
  52. package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.d.ts +12 -0
  53. package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.js +67 -0
  54. package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.styles.d.ts +59 -0
  55. package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.styles.js +57 -0
  56. package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.types.d.ts +15 -0
  57. package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.types.js +1 -0
  58. package/dist/components/selector/components/selector-radio-group/index.d.ts +2 -0
  59. package/dist/components/selector/components/selector-radio-group/index.js +1 -0
  60. package/dist/components/selector/components/selector-radio-group/selector-radio-group.component.d.ts +15 -0
  61. package/dist/components/selector/components/selector-radio-group/selector-radio-group.component.js +58 -0
  62. package/dist/components/selector/components/selector-radio-group/selector-radio-group.styles.d.ts +13 -0
  63. package/dist/components/selector/components/selector-radio-group/selector-radio-group.styles.js +18 -0
  64. package/dist/components/selector/components/selector-radio-group/selector-radio-group.types.d.ts +17 -0
  65. package/dist/components/selector/components/selector-radio-group/selector-radio-group.types.js +1 -0
  66. package/dist/components/selector/index.d.ts +2 -0
  67. package/dist/components/selector/index.js +1 -0
  68. package/dist/components/selector/selector.component.d.ts +30 -0
  69. package/dist/components/selector/selector.component.js +34 -0
  70. package/dist/components/selector/selector.stories.d.ts +57 -0
  71. package/dist/components/selector/selector.stories.js +515 -0
  72. package/dist/components/selector/selector.types.d.ts +20 -0
  73. package/dist/components/selector/selector.types.js +1 -0
  74. package/dist/css/westpac-ui.css +150 -0
  75. package/dist/css/westpac-ui.min.css +150 -0
  76. package/dist/utils/generateId.d.ts +1 -0
  77. package/dist/utils/generateId.js +6 -0
  78. package/dist/utils/index.d.ts +1 -0
  79. package/dist/utils/index.js +1 -0
  80. package/package.json +7 -1
  81. package/src/components/alert/alert.component.tsx +1 -1
  82. package/src/components/alert/alert.styles.ts +2 -2
  83. package/src/components/compacta/compacta.component.tsx +4 -3
  84. package/src/components/flexi-cell/flexi-cell.component.tsx +2 -1
  85. package/src/components/flexi-cell/flexi-cell.styles.ts +1 -1
  86. package/src/components/flexi-cell/flexi-cell.types.ts +4 -0
  87. package/src/components/flexi-cell/index.ts +1 -0
  88. package/src/components/icon/index.ts +1 -0
  89. package/src/components/index.ts +3 -1
  90. package/src/components/list/components/item/item.styles.ts +1 -1
  91. package/src/components/list/list.styles.ts +1 -1
  92. package/src/components/repeater/index.ts +2 -0
  93. package/src/components/repeater/repeater.component.tsx +121 -0
  94. package/src/components/repeater/repeater.stories.tsx +49 -0
  95. package/src/components/repeater/repeater.styles.ts +27 -0
  96. package/src/components/repeater/repeater.types.ts +20 -0
  97. package/src/components/repeater/repeater.utils.tsx +3 -0
  98. package/src/components/selector/components/index.ts +2 -0
  99. package/src/components/selector/components/selector-checkbox-group/components/index.ts +1 -0
  100. package/src/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/index.ts +2 -0
  101. package/src/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.component.tsx +96 -0
  102. package/src/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.styles.ts +53 -0
  103. package/src/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.types.ts +15 -0
  104. package/src/components/selector/components/selector-checkbox-group/index.ts +2 -0
  105. package/src/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.tsx +46 -0
  106. package/src/components/selector/components/selector-checkbox-group/selector-checkbox-group.styles.ts +9 -0
  107. package/src/components/selector/components/selector-checkbox-group/selector-checkbox-group.types.ts +25 -0
  108. package/src/components/selector/components/selector-radio-group/components/index.ts +1 -0
  109. package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/index.ts +2 -0
  110. package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.tsx +90 -0
  111. package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.styles.ts +53 -0
  112. package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.types.ts +21 -0
  113. package/src/components/selector/components/selector-radio-group/index.ts +2 -0
  114. package/src/components/selector/components/selector-radio-group/selector-radio-group.component.tsx +48 -0
  115. package/src/components/selector/components/selector-radio-group/selector-radio-group.styles.ts +14 -0
  116. package/src/components/selector/components/selector-radio-group/selector-radio-group.types.ts +22 -0
  117. package/src/components/selector/index.ts +2 -0
  118. package/src/components/selector/selector.component.tsx +34 -0
  119. package/src/components/selector/selector.stories.tsx +621 -0
  120. package/src/components/selector/selector.types.ts +24 -0
  121. package/src/utils/generateId.ts +6 -0
  122. package/src/utils/index.ts +1 -0
@@ -0,0 +1,57 @@
1
+ import { tv } from 'tailwind-variants';
2
+ export const styles = tv({
3
+ slots: {
4
+ base: 'group/checkbox-option cursor-pointer',
5
+ icon: 'transition-transform'
6
+ },
7
+ variants: {
8
+ checkIcon: {
9
+ arrow: {
10
+ icon: 'text-primary group-hover/checkbox-option:translate-x-1'
11
+ },
12
+ checkbox: {}
13
+ },
14
+ isSelected: {
15
+ true: {
16
+ base: 'border-hero shadow-[0_0_0_2px_inset]'
17
+ },
18
+ false: {}
19
+ },
20
+ isFocusVisible: {
21
+ true: {
22
+ base: 'focus-outline'
23
+ },
24
+ false: {}
25
+ },
26
+ isDisabled: {
27
+ true: {
28
+ base: 'opacity-50'
29
+ },
30
+ false: {}
31
+ }
32
+ },
33
+ compoundVariants: [
34
+ {
35
+ checkIcon: 'checkbox',
36
+ isSelected: false,
37
+ className: {
38
+ icon: 'opacity-0'
39
+ }
40
+ },
41
+ {
42
+ checkIcon: 'checkbox',
43
+ isSelected: true,
44
+ className: {
45
+ icon: 'opacity-100'
46
+ }
47
+ }
48
+ ]
49
+ }, {
50
+ responsiveVariants: [
51
+ 'xsl',
52
+ 'sm',
53
+ 'md',
54
+ 'lg',
55
+ 'xl'
56
+ ]
57
+ });
@@ -0,0 +1,10 @@
1
+ import { type AriaCheckboxGroupItemProps } from 'react-aria';
2
+ import { type VariantProps } from 'tailwind-variants';
3
+ import { FlexiCellProps } from '../../../../../index.js';
4
+ import { styles } from './selector-checkbox-group-option.styles.js';
5
+ export type SelectorCheckboxGroupOptionProps = {
6
+ /**
7
+ * Check icon to render
8
+ */
9
+ checkIcon?: 'checkbox' | 'arrow';
10
+ } & FlexiCellProps & VariantProps<typeof styles> & Omit<AriaCheckboxGroupItemProps, 'isIndeterminate'>;
@@ -0,0 +1,2 @@
1
+ export { SelectorCheckboxGroup } from './selector-checkbox-group.component.js';
2
+ export { type SelectorCheckboxGroupProps } from './selector-checkbox-group.types.js';
@@ -0,0 +1 @@
1
+ export { SelectorCheckboxGroup } from './selector-checkbox-group.component.js';
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { type SelectorCheckboxGroupProps } from './selector-checkbox-group.types.js';
3
+ export declare const SelectorCheckboxGroupContext: React.Context<import("react-stately").CheckboxGroupState>;
4
+ export declare function SelectorCheckboxGroup(props: SelectorCheckboxGroupProps): JSX.Element;
5
+ export declare namespace SelectorCheckboxGroup {
6
+ var Option: React.ForwardRefExoticComponent<import("./components/index.js").SelectorCheckboxGroupOptionProps & React.RefAttributes<unknown>> & {
7
+ Adornment: ({ children, tag: Tag, align, className, ...props }: import("../../../flexi-cell/index.js").FlexiCellAdornmentProps) => JSX.Element;
8
+ Body: ({ children, tag: Tag, className, ...props }: import("../../../flexi-cell/index.js").FlexiCellBodyProps) => JSX.Element;
9
+ Button: ({ className, ...props }: import("../../../index.js").ButtonProps) => JSX.Element;
10
+ Circle: ({ className, ...props }: import("../../../index.js").CircleProps) => JSX.Element;
11
+ Footer: ({ children, className, tag: Tag, ...props }: import("../../../flexi-cell/index.js").FlexiCellFooterProps) => JSX.Element;
12
+ Hint: ({ children, tag: Tag, className, truncateText, ...props }: import("../../../flexi-cell/index.js").FlexiCellHintProps) => JSX.Element;
13
+ Label: ({ children, tag: Tag, truncateText, className, ...props }: import("../../../flexi-cell/index.js").FlexiCellLabelProps) => JSX.Element;
14
+ };
15
+ }
@@ -0,0 +1,49 @@
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, { createContext } from 'react';
16
+ import { useCheckboxGroup } from 'react-aria';
17
+ import { useCheckboxGroupState } from 'react-stately';
18
+ import { SelectorCheckboxGroupOption } from './components/index.js';
19
+ import { styles } from './selector-checkbox-group.styles.js';
20
+ export const SelectorCheckboxGroupContext = createContext({
21
+ value: [],
22
+ isDisabled: false,
23
+ isReadOnly: false,
24
+ isSelected: ()=>false,
25
+ setValue: ()=>null,
26
+ addValue: ()=>null,
27
+ removeValue: ()=>null,
28
+ toggleValue: ()=>null,
29
+ validationState: 'valid'
30
+ });
31
+ export function SelectorCheckboxGroup(props) {
32
+ const { children , label , description , errorMessage } = props;
33
+ const state = useCheckboxGroupState(props);
34
+ const { groupProps , labelProps , descriptionProps , errorMessageProps } = useCheckboxGroup(props, state);
35
+ return React.createElement("div", _extends({}, groupProps, {
36
+ className: styles({
37
+ className: groupProps.className
38
+ })
39
+ }), React.createElement("span", _extends({}, labelProps), label), React.createElement(SelectorCheckboxGroupContext.Provider, {
40
+ value: state
41
+ }, children), description && React.createElement("div", _extends({}, descriptionProps, {
42
+ style: {
43
+ fontSize: 12
44
+ }
45
+ }), description), errorMessage && state.validationState === 'invalid' && React.createElement("div", _extends({}, errorMessageProps, {
46
+ className: "typography-body-10 text-danger"
47
+ }), errorMessage));
48
+ }
49
+ SelectorCheckboxGroup.Option = SelectorCheckboxGroupOption;
@@ -0,0 +1,3 @@
1
+ export declare const styles: import("tailwind-variants").TVReturnType<{}, undefined, "flex flex-col gap-2 md:gap-3", {
2
+ responsiveVariants: string[];
3
+ }, {}, undefined>;
@@ -0,0 +1,13 @@
1
+ import { tv } from 'tailwind-variants';
2
+ export const styles = tv({
3
+ base: 'flex flex-col gap-2 md:gap-3',
4
+ variants: {}
5
+ }, {
6
+ responsiveVariants: [
7
+ 'xsl',
8
+ 'sm',
9
+ 'md',
10
+ 'lg',
11
+ 'xl'
12
+ ]
13
+ });
@@ -0,0 +1,20 @@
1
+ import { HTMLAttributes } from 'react';
2
+ import { AriaCheckboxGroupProps } from 'react-aria';
3
+ import { CheckboxGroupState } from 'react-stately';
4
+ import { type VariantProps } from 'tailwind-variants';
5
+ import { styles } from './selector-checkbox-group.styles.js';
6
+ export type SelectorCheckboxGroupContextState = CheckboxGroupState;
7
+ export type SelectorCheckboxGroupProps = {
8
+ /**
9
+ * String to override base style
10
+ */
11
+ className?: string;
12
+ /**
13
+ * Orientation of checkbox items
14
+ */
15
+ orientation?: 'horizontal' | 'vertical';
16
+ /**
17
+ * Controls size of `CheckboxItem` components, can't be applied directly to `CheckboxItem`
18
+ */
19
+ size?: 'medium' | 'large';
20
+ } & AriaCheckboxGroupProps & VariantProps<typeof styles> & Omit<HTMLAttributes<Element>, 'onChange'>;
@@ -0,0 +1 @@
1
+ export * from './selector-radio-group-option/index.js';
@@ -0,0 +1 @@
1
+ export * from './selector-radio-group-option/index.js';
@@ -0,0 +1,2 @@
1
+ export { SelectorRadioGroupOption } from './selector-radio-group-option.component.js';
2
+ export { type SelectorRadioGroupOptionProps } from './selector-radio-group-option.types.js';
@@ -0,0 +1 @@
1
+ export { SelectorRadioGroupOption } from './selector-radio-group-option.component.js';
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { FlexiCell } from '../../../../../index.js';
3
+ import { type SelectorRadioGroupOptionProps } from './selector-radio-group-option.types.js';
4
+ export declare const SelectorRadioGroupOption: React.ForwardRefExoticComponent<SelectorRadioGroupOptionProps & 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, useFocusRing, useRadio } 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 '../../../../../index.js';
20
+ import { SelectorRadioGroupContext } from '../../selector-radio-group.component.js';
21
+ import { styles as selectorRadioGroupOptionStyles } from './selector-radio-group-option.styles.js';
22
+ function BaseSelectorRadioGroupOption({ className , children , value , withBorder =true , withArrow , after , badge , badgeZIndex , before , body =true , checkIcon ='checkbox' , ...props }, ref) {
23
+ const state = useContext(SelectorRadioGroupContext);
24
+ const localRef = useRef(null);
25
+ const { inputProps , isSelected , isDisabled } = useRadio({
26
+ ...props,
27
+ value,
28
+ children
29
+ }, state, localRef);
30
+ const { isFocusVisible , focusProps } = useFocusRing();
31
+ const styles = selectorRadioGroupOptionStyles({
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
+ className: styles.base({}),
55
+ withHoverEffect: true
56
+ }, React.createElement(VisuallyHidden, null, React.createElement("input", _extends({}, inputProps, focusProps, {
57
+ ref: localRef
58
+ }))), children);
59
+ }
60
+ export const SelectorRadioGroupOption = forwardRef(BaseSelectorRadioGroupOption);
61
+ SelectorRadioGroupOption.Body = FlexiCellBody;
62
+ SelectorRadioGroupOption.Footer = FlexiCellFooter;
63
+ SelectorRadioGroupOption.Adornment = FlexiCellAdornment;
64
+ SelectorRadioGroupOption.Hint = FlexiCellHint;
65
+ SelectorRadioGroupOption.Label = FlexiCellLabel;
66
+ SelectorRadioGroupOption.Button = FlexiCellButton;
67
+ SelectorRadioGroupOption.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
+ }>;
@@ -0,0 +1,57 @@
1
+ import { tv } from 'tailwind-variants';
2
+ export const styles = tv({
3
+ slots: {
4
+ base: 'group/radio-option cursor-pointer',
5
+ icon: 'transition-transform'
6
+ },
7
+ variants: {
8
+ checkIcon: {
9
+ arrow: {
10
+ icon: 'text-primary group-hover/radio-option:translate-x-1'
11
+ },
12
+ checkbox: {}
13
+ },
14
+ isSelected: {
15
+ true: {
16
+ base: 'border-hero shadow-[0_0_0_2px_inset] shadow-hero'
17
+ },
18
+ false: {}
19
+ },
20
+ isFocusVisible: {
21
+ true: {
22
+ base: 'focus-outline'
23
+ },
24
+ false: {}
25
+ },
26
+ isDisabled: {
27
+ true: {
28
+ base: 'opacity-50'
29
+ },
30
+ false: {}
31
+ }
32
+ },
33
+ compoundVariants: [
34
+ {
35
+ checkIcon: 'checkbox',
36
+ isSelected: false,
37
+ className: {
38
+ icon: 'opacity-0'
39
+ }
40
+ },
41
+ {
42
+ checkIcon: 'checkbox',
43
+ isSelected: true,
44
+ className: {
45
+ icon: 'opacity-100'
46
+ }
47
+ }
48
+ ]
49
+ }, {
50
+ responsiveVariants: [
51
+ 'xsl',
52
+ 'sm',
53
+ 'md',
54
+ 'lg',
55
+ 'xl'
56
+ ]
57
+ });
@@ -0,0 +1,15 @@
1
+ import { type HTMLAttributes } from 'react';
2
+ import { type AriaRadioProps } from 'react-aria';
3
+ import { type VariantProps } from 'tailwind-variants';
4
+ import { type FlexiCellProps } from '../../../../../../index.js';
5
+ import { styles } from './selector-radio-group-option.styles.js';
6
+ export type SelectorRadioGroupOptionProps = {
7
+ /**
8
+ * Check icon to render
9
+ */
10
+ checkIcon?: 'checkbox' | 'arrow';
11
+ /**
12
+ * Tag to render
13
+ */
14
+ tag?: keyof JSX.IntrinsicElements;
15
+ } & FlexiCellProps & AriaRadioProps & VariantProps<typeof styles> & HTMLAttributes<Element>;
@@ -0,0 +1,2 @@
1
+ export { SelectorRadioGroup } from './selector-radio-group.component.js';
2
+ export { type SelectorRadioGroupProps } from './selector-radio-group.types.js';
@@ -0,0 +1 @@
1
+ export { SelectorRadioGroup } from './selector-radio-group.component.js';
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { type SelectorRadioGroupContextState, type SelectorRadioGroupProps } from './selector-radio-group.types.js';
3
+ export declare const SelectorRadioGroupContext: React.Context<SelectorRadioGroupContextState>;
4
+ export declare function SelectorRadioGroup({ className, children, label, orientation, errorMessage, ...props }: SelectorRadioGroupProps): JSX.Element;
5
+ export declare namespace SelectorRadioGroup {
6
+ var Option: React.ForwardRefExoticComponent<import("./components/index.js").SelectorRadioGroupOptionProps & React.RefAttributes<unknown>> & {
7
+ Adornment: ({ children, tag: Tag, align, className, ...props }: import("../../../flexi-cell/index.js").FlexiCellAdornmentProps) => JSX.Element;
8
+ Body: ({ children, tag: Tag, className, ...props }: import("../../../flexi-cell/index.js").FlexiCellBodyProps) => JSX.Element;
9
+ Button: ({ className, ...props }: import("../../../index.js").ButtonProps) => JSX.Element;
10
+ Circle: ({ className, ...props }: import("../../../index.js").CircleProps) => JSX.Element;
11
+ Footer: ({ children, className, tag: Tag, ...props }: import("../../../flexi-cell/index.js").FlexiCellFooterProps) => JSX.Element;
12
+ Hint: ({ children, tag: Tag, className, truncateText, ...props }: import("../../../flexi-cell/index.js").FlexiCellHintProps) => JSX.Element;
13
+ Label: ({ children, tag: Tag, truncateText, className, ...props }: import("../../../flexi-cell/index.js").FlexiCellLabelProps) => JSX.Element;
14
+ };
15
+ }
@@ -0,0 +1,58 @@
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, { createContext } from 'react';
16
+ import { useRadioGroup } from 'react-aria';
17
+ import { useRadioGroupState } from 'react-stately';
18
+ import { SelectorRadioGroupOption } from './components/index.js';
19
+ import { styles } from './selector-radio-group.styles.js';
20
+ export const SelectorRadioGroupContext = createContext({
21
+ name: '',
22
+ isDisabled: false,
23
+ isReadOnly: false,
24
+ isRequired: false,
25
+ validationState: null,
26
+ selectedValue: null,
27
+ setSelectedValue: ()=>null,
28
+ lastFocusedValue: null,
29
+ setLastFocusedValue: ()=>null,
30
+ orientation: 'vertical'
31
+ });
32
+ export function SelectorRadioGroup({ className , children , label , orientation ='vertical' , errorMessage , ...props }) {
33
+ const state = useRadioGroupState({
34
+ ...props,
35
+ errorMessage,
36
+ label,
37
+ orientation
38
+ });
39
+ const { radioGroupProps , labelProps , errorMessageProps } = useRadioGroup({
40
+ ...props,
41
+ label,
42
+ orientation
43
+ }, state);
44
+ return React.createElement("div", _extends({
45
+ className: styles({
46
+ className,
47
+ orientation
48
+ })
49
+ }, radioGroupProps), React.createElement("span", _extends({}, labelProps), label), React.createElement(SelectorRadioGroupContext.Provider, {
50
+ value: {
51
+ ...state,
52
+ orientation
53
+ }
54
+ }, children), errorMessage && state.validationState === 'invalid' && React.createElement("div", _extends({}, errorMessageProps, {
55
+ className: "typography-body-10 text-danger"
56
+ }), errorMessage));
57
+ }
58
+ SelectorRadioGroup.Option = SelectorRadioGroupOption;
@@ -0,0 +1,13 @@
1
+ export declare const styles: import("tailwind-variants").TVReturnType<{
2
+ orientation: {
3
+ vertical: string;
4
+ horizontal: string;
5
+ };
6
+ }, undefined, "flex gap-2 md:gap-3", {
7
+ responsiveVariants: string[];
8
+ }, {
9
+ orientation: {
10
+ vertical: string;
11
+ horizontal: string;
12
+ };
13
+ }, undefined>;
@@ -0,0 +1,18 @@
1
+ import { tv } from 'tailwind-variants';
2
+ export const styles = tv({
3
+ base: 'flex gap-2 md:gap-3',
4
+ variants: {
5
+ orientation: {
6
+ vertical: 'flex-col',
7
+ horizontal: 'flex-row'
8
+ }
9
+ }
10
+ }, {
11
+ responsiveVariants: [
12
+ 'xsl',
13
+ 'sm',
14
+ 'md',
15
+ 'lg',
16
+ 'xl'
17
+ ]
18
+ });
@@ -0,0 +1,17 @@
1
+ import { type HTMLAttributes } from 'react';
2
+ import { type AriaRadioGroupProps } from 'react-aria';
3
+ import { type RadioGroupState } from 'react-stately';
4
+ import { type VariantProps } from 'tailwind-variants';
5
+ import { styles } from './selector-radio-group.styles.js';
6
+ export type SelectorRadioGroupProps = {
7
+ /**
8
+ * Tag to render
9
+ */
10
+ tag?: keyof JSX.IntrinsicElements;
11
+ } & VariantProps<typeof styles> & AriaRadioGroupProps & Omit<HTMLAttributes<Element>, 'onChange'>;
12
+ export type SelectorRadioGroupContextState = {
13
+ /**
14
+ * Controls orientation of `Radio` components, can't be applied directly on `Radio`
15
+ */
16
+ orientation: 'vertical' | 'horizontal';
17
+ } & RadioGroupState;
@@ -0,0 +1,2 @@
1
+ export { Selector } from './selector.component.js';
2
+ export { type SelectorProps } from './selector.types.js';
@@ -0,0 +1 @@
1
+ export { Selector } from './selector.component.js';
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { type SelectorProps } from './selector.types.js';
3
+ export declare function Selector(props: SelectorProps): JSX.Element;
4
+ export declare namespace Selector {
5
+ var Radio: React.ForwardRefExoticComponent<import("./components/selector-radio-group/components/index.js").SelectorRadioGroupOptionProps & React.RefAttributes<unknown>> & {
6
+ Adornment: ({ children, tag: Tag, align, className, ...props }: import("../flexi-cell/components/index.js").FlexiCellAdornmentProps) => JSX.Element;
7
+ Body: ({ children, tag: Tag, className, ...props }: import("../flexi-cell/components/index.js").FlexiCellBodyProps) => JSX.Element;
8
+ Button: ({ className, ...props }: import("../index.js").ButtonProps) => JSX.Element;
9
+ Circle: ({ className, ...props }: import("../index.js").CircleProps) => JSX.Element;
10
+ Footer: ({ children, className, tag: Tag, ...props }: import("../flexi-cell/components/index.js").FlexiCellFooterProps) => JSX.Element;
11
+ Hint: ({ children, tag: Tag, className, truncateText, ...props }: import("../flexi-cell/components/index.js").FlexiCellHintProps) => JSX.Element;
12
+ Label: ({ children, tag: Tag, truncateText, className, ...props }: import("../flexi-cell/components/index.js").FlexiCellLabelProps) => JSX.Element;
13
+ };
14
+ var Checkbox: React.ForwardRefExoticComponent<import("./components/selector-checkbox-group/components/index.js").SelectorCheckboxGroupOptionProps & React.RefAttributes<unknown>> & {
15
+ Adornment: ({ children, tag: Tag, align, className, ...props }: import("../flexi-cell/components/index.js").FlexiCellAdornmentProps) => JSX.Element;
16
+ Body: ({ children, tag: Tag, className, ...props }: import("../flexi-cell/components/index.js").FlexiCellBodyProps) => JSX.Element;
17
+ Button: ({ className, ...props }: import("../index.js").ButtonProps) => JSX.Element;
18
+ Circle: ({ className, ...props }: import("../index.js").CircleProps) => JSX.Element;
19
+ Footer: ({ children, className, tag: Tag, ...props }: import("../flexi-cell/components/index.js").FlexiCellFooterProps) => JSX.Element;
20
+ Hint: ({ children, tag: Tag, className, truncateText, ...props }: import("../flexi-cell/components/index.js").FlexiCellHintProps) => JSX.Element;
21
+ Label: ({ children, tag: Tag, truncateText, className, ...props }: import("../flexi-cell/components/index.js").FlexiCellLabelProps) => JSX.Element;
22
+ };
23
+ var Body: ({ children, tag: Tag, className, ...props }: import("../flexi-cell/components/index.js").FlexiCellBodyProps) => JSX.Element;
24
+ var Footer: ({ children, className, tag: Tag, ...props }: import("../flexi-cell/components/index.js").FlexiCellFooterProps) => JSX.Element;
25
+ var Adornment: ({ children, tag: Tag, align, className, ...props }: import("../flexi-cell/components/index.js").FlexiCellAdornmentProps) => JSX.Element;
26
+ var Hint: ({ children, tag: Tag, className, truncateText, ...props }: import("../flexi-cell/components/index.js").FlexiCellHintProps) => JSX.Element;
27
+ var Label: ({ children, tag: Tag, truncateText, className, ...props }: import("../flexi-cell/components/index.js").FlexiCellLabelProps) => JSX.Element;
28
+ var Button: ({ className, ...props }: import("../index.js").ButtonProps) => JSX.Element;
29
+ var Circle: ({ className, ...props }: import("../index.js").CircleProps) => JSX.Element;
30
+ }
@@ -0,0 +1,34 @@
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 from 'react';
16
+ import { FlexiCellAdornment, FlexiCellBody, FlexiCellButton, FlexiCellCircle, FlexiCellFooter, FlexiCellHint, FlexiCellLabel } from '../flexi-cell/components/index.js';
17
+ import { SelectorCheckboxGroup, SelectorRadioGroup } from './components/index.js';
18
+ import { SelectorCheckboxGroupOption } from './components/selector-checkbox-group/components/index.js';
19
+ import { SelectorRadioGroupOption } from './components/selector-radio-group/components/index.js';
20
+ export function Selector(props) {
21
+ if (props.type === 'checkbox') {
22
+ return React.createElement(SelectorCheckboxGroup, _extends({}, props));
23
+ }
24
+ return React.createElement(SelectorRadioGroup, _extends({}, props));
25
+ }
26
+ Selector.Radio = SelectorRadioGroupOption;
27
+ Selector.Checkbox = SelectorCheckboxGroupOption;
28
+ Selector.Body = FlexiCellBody;
29
+ Selector.Footer = FlexiCellFooter;
30
+ Selector.Adornment = FlexiCellAdornment;
31
+ Selector.Hint = FlexiCellHint;
32
+ Selector.Label = FlexiCellLabel;
33
+ Selector.Button = FlexiCellButton;
34
+ Selector.Circle = FlexiCellCircle;