@digigov/react-core 2.0.0-e7d30530 → 2.0.0-eaf330f5

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 (84) hide show
  1. package/Accordion/index.native.d.ts +5 -1
  2. package/AccordionSection/index.native.d.ts +3 -1
  3. package/AutoCompleteInputTypeahead/index.d.ts +11 -0
  4. package/AutoCompleteInputTypeahead/index.js +25 -0
  5. package/AutoCompleteInputTypeahead/index.js.map +7 -0
  6. package/AutoCompleteInputTypeahead/package.json +6 -0
  7. package/Base/compat/Input/CheckboxInput.native.js.map +2 -2
  8. package/Base/compat/Input/RadioInput.native.js.map +2 -2
  9. package/Base/index.native.js.map +2 -2
  10. package/Base/index.web.js.map +1 -1
  11. package/Base/mapping.native.d.ts +1 -1
  12. package/Base/mapping.native.js.map +2 -2
  13. package/{CircularProgressBase → CircularProgress}/index.d.ts +5 -5
  14. package/{CircularProgressBase → CircularProgress}/index.js +4 -4
  15. package/CircularProgress/index.js.map +7 -0
  16. package/CircularProgress/index.test.d.ts +1 -0
  17. package/{CircularProgressBase → CircularProgress}/package.json +1 -1
  18. package/CopyToClipboardMessage/index.native.d.ts +3 -1
  19. package/DateInputItem/index.native.d.ts +3 -1
  20. package/Details/index.native.d.ts +3 -1
  21. package/LinkBase/index.js +1 -1
  22. package/LinkBase/index.js.map +2 -2
  23. package/NavListItemActionContainer/index.native.d.ts +2 -0
  24. package/NotificationBannerLink/index.native.d.ts +3 -1
  25. package/TextArea/index.native.d.ts +3 -1
  26. package/TextInput/index.native.d.ts +3 -1
  27. package/Typography/index.d.ts +1 -1
  28. package/Typography/index.js +17 -15
  29. package/Typography/index.js.map +2 -2
  30. package/cjs/AutoCompleteInputTypeahead/index.js +58 -0
  31. package/cjs/AutoCompleteInputTypeahead/index.js.map +7 -0
  32. package/cjs/Base/compat/Input/CheckboxInput.native.js.map +2 -2
  33. package/cjs/Base/compat/Input/RadioInput.native.js.map +2 -2
  34. package/cjs/Base/index.native.js.map +2 -2
  35. package/cjs/Base/index.web.js.map +1 -1
  36. package/cjs/Base/mapping.native.js.map +2 -2
  37. package/cjs/{CircularProgressBase → CircularProgress}/index.js +8 -8
  38. package/cjs/CircularProgress/index.js.map +7 -0
  39. package/cjs/LinkBase/index.js +1 -1
  40. package/cjs/LinkBase/index.js.map +2 -2
  41. package/cjs/Typography/index.js +17 -15
  42. package/cjs/Typography/index.js.map +2 -2
  43. package/cjs/index.js +4 -2
  44. package/cjs/index.js.map +2 -2
  45. package/cjs/lazy/index.js +2 -1
  46. package/cjs/lazy.js.map +2 -2
  47. package/cjs/registry/index.js +8 -6
  48. package/cjs/registry.js.map +2 -2
  49. package/cjs/utils/index.native/index.js +34 -32
  50. package/cjs/utils/index.native.js.map +2 -2
  51. package/index.d.ts +2 -1
  52. package/index.js +3 -2
  53. package/index.js.map +2 -2
  54. package/lazy/index.js +2 -1
  55. package/package.json +5 -5
  56. package/registry/index.js +8 -6
  57. package/src/AutoCompleteInputTypeahead/__snapshots__/index.test.tsx.snap +16 -0
  58. package/src/AutoCompleteInputTypeahead/index.test.tsx +8 -0
  59. package/src/AutoCompleteInputTypeahead/index.tsx +32 -0
  60. package/src/Base/compat/Input/CheckboxInput.native.tsx +6 -2
  61. package/src/Base/compat/Input/RadioInput.native.tsx +6 -2
  62. package/src/Base/index.native.tsx +2 -2
  63. package/src/Base/index.web.tsx +1 -1
  64. package/src/Base/mapping.native.tsx +1 -1
  65. package/src/Checkbox/__snapshots__/index.test.tsx.snap +5 -0
  66. package/src/CheckboxItem/__snapshots__/index.test.tsx.snap +4 -0
  67. package/src/{CircularProgressBase → CircularProgress}/__snapshots__/index.test.tsx.snap +6 -6
  68. package/src/CircularProgress/index.test.tsx +34 -0
  69. package/src/{CircularProgressBase → CircularProgress}/index.tsx +7 -7
  70. package/src/LinkBase/index.tsx +1 -1
  71. package/src/RadioItem/__snapshots__/index.test.tsx.snap +4 -0
  72. package/src/TableDataCell/__snapshots__/index.test.tsx.snap +2 -2
  73. package/src/Typography/index.tsx +20 -21
  74. package/src/index.ts +2 -1
  75. package/src/lazy.js +2 -1
  76. package/src/registry.js +8 -6
  77. package/src/utils/index.native.tsx +54 -56
  78. package/utils/index.native/index.js +34 -32
  79. package/utils/index.native.d.ts +6 -3
  80. package/utils/index.native.js.map +2 -2
  81. package/CircularProgressBase/index.js.map +0 -7
  82. package/cjs/CircularProgressBase/index.js.map +0 -7
  83. package/src/CircularProgressBase/index.test.tsx +0 -38
  84. /package/{CircularProgressBase → AutoCompleteInputTypeahead}/index.test.d.ts +0 -0
package/src/registry.js CHANGED
@@ -2,14 +2,14 @@
2
2
  import * as _digigov_react_core from "@digigov/react-core";
3
3
  import * as _digigov_react_core_Accordion from "@digigov/react-core/Accordion";
4
4
  import * as _digigov_react_core_Accordion_index_web from "@digigov/react-core/Accordion/index.web";
5
+ import * as _digigov_react_core_AccordionControls from "@digigov/react-core/AccordionControls";
5
6
  import * as _digigov_react_core_AccordionSection from "@digigov/react-core/AccordionSection";
6
7
  import * as _digigov_react_core_AccordionSection_index_web from "@digigov/react-core/AccordionSection/index.web";
7
- import * as _digigov_react_core_AccordionControls from "@digigov/react-core/AccordionControls";
8
8
  import * as _digigov_react_core_AccordionSectionContent from "@digigov/react-core/AccordionSectionContent";
9
9
  import * as _digigov_react_core_AccordionSectionSummary from "@digigov/react-core/AccordionSectionSummary";
10
10
  import * as _digigov_react_core_AccordionSectionSummaryHeading from "@digigov/react-core/AccordionSectionSummaryHeading";
11
- import * as _digigov_react_core_AdminAside from "@digigov/react-core/AdminAside";
12
11
  import * as _digigov_react_core_AdminContainer from "@digigov/react-core/AdminContainer";
12
+ import * as _digigov_react_core_AdminAside from "@digigov/react-core/AdminAside";
13
13
  import * as _digigov_react_core_AdminHeader from "@digigov/react-core/AdminHeader";
14
14
  import * as _digigov_react_core_AdminHeaderContent from "@digigov/react-core/AdminHeaderContent";
15
15
  import * as _digigov_react_core_AdminLayout from "@digigov/react-core/AdminLayout";
@@ -19,6 +19,7 @@ import * as _digigov_react_core_Aside from "@digigov/react-core/Aside";
19
19
  import * as _digigov_react_core_AutoCompleteAssistiveHint from "@digigov/react-core/AutoCompleteAssistiveHint";
20
20
  import * as _digigov_react_core_AutoCompleteContainer from "@digigov/react-core/AutoCompleteContainer";
21
21
  import * as _digigov_react_core_AutoCompleteInputBase from "@digigov/react-core/AutoCompleteInputBase";
22
+ import * as _digigov_react_core_AutoCompleteInputTypeahead from "@digigov/react-core/AutoCompleteInputTypeahead";
22
23
  import * as _digigov_react_core_AutoCompleteMultipleInput from "@digigov/react-core/AutoCompleteMultipleInput";
23
24
  import * as _digigov_react_core_AutoCompleteMultipleInputContainer from "@digigov/react-core/AutoCompleteMultipleInputContainer";
24
25
  import * as _digigov_react_core_AutoCompleteResultList from "@digigov/react-core/AutoCompleteResultList";
@@ -60,7 +61,7 @@ import * as _digigov_react_core_ChipContainer from "@digigov/react-core/ChipCont
60
61
  import * as _digigov_react_core_ChipHeading from "@digigov/react-core/ChipHeading";
61
62
  import * as _digigov_react_core_ChipKeyValue from "@digigov/react-core/ChipKeyValue";
62
63
  import * as _digigov_react_core_ChoiceDividerText from "@digigov/react-core/ChoiceDividerText";
63
- import * as _digigov_react_core_CircularProgressBase from "@digigov/react-core/CircularProgressBase";
64
+ import * as _digigov_react_core_CircularProgress from "@digigov/react-core/CircularProgress";
64
65
  import * as _digigov_react_core_CloseButton from "@digigov/react-core/CloseButton";
65
66
  import * as _digigov_react_core_Code from "@digigov/react-core/Code";
66
67
  import * as _digigov_react_core_CodeBlockContainer from "@digigov/react-core/CodeBlockContainer";
@@ -285,14 +286,14 @@ export default {
285
286
  '@digigov/react-core': lazyImport(_digigov_react_core),
286
287
  '@digigov/react-core/Accordion': lazyImport(_digigov_react_core_Accordion),
287
288
  '@digigov/react-core/Accordion/index.web': lazyImport(_digigov_react_core_Accordion_index_web),
289
+ '@digigov/react-core/AccordionControls': lazyImport(_digigov_react_core_AccordionControls),
288
290
  '@digigov/react-core/AccordionSection': lazyImport(_digigov_react_core_AccordionSection),
289
291
  '@digigov/react-core/AccordionSection/index.web': lazyImport(_digigov_react_core_AccordionSection_index_web),
290
- '@digigov/react-core/AccordionControls': lazyImport(_digigov_react_core_AccordionControls),
291
292
  '@digigov/react-core/AccordionSectionContent': lazyImport(_digigov_react_core_AccordionSectionContent),
292
293
  '@digigov/react-core/AccordionSectionSummary': lazyImport(_digigov_react_core_AccordionSectionSummary),
293
294
  '@digigov/react-core/AccordionSectionSummaryHeading': lazyImport(_digigov_react_core_AccordionSectionSummaryHeading),
294
- '@digigov/react-core/AdminAside': lazyImport(_digigov_react_core_AdminAside),
295
295
  '@digigov/react-core/AdminContainer': lazyImport(_digigov_react_core_AdminContainer),
296
+ '@digigov/react-core/AdminAside': lazyImport(_digigov_react_core_AdminAside),
296
297
  '@digigov/react-core/AdminHeader': lazyImport(_digigov_react_core_AdminHeader),
297
298
  '@digigov/react-core/AdminHeaderContent': lazyImport(_digigov_react_core_AdminHeaderContent),
298
299
  '@digigov/react-core/AdminLayout': lazyImport(_digigov_react_core_AdminLayout),
@@ -302,6 +303,7 @@ export default {
302
303
  '@digigov/react-core/AutoCompleteAssistiveHint': lazyImport(_digigov_react_core_AutoCompleteAssistiveHint),
303
304
  '@digigov/react-core/AutoCompleteContainer': lazyImport(_digigov_react_core_AutoCompleteContainer),
304
305
  '@digigov/react-core/AutoCompleteInputBase': lazyImport(_digigov_react_core_AutoCompleteInputBase),
306
+ '@digigov/react-core/AutoCompleteInputTypeahead': lazyImport(_digigov_react_core_AutoCompleteInputTypeahead),
305
307
  '@digigov/react-core/AutoCompleteMultipleInput': lazyImport(_digigov_react_core_AutoCompleteMultipleInput),
306
308
  '@digigov/react-core/AutoCompleteMultipleInputContainer': lazyImport(_digigov_react_core_AutoCompleteMultipleInputContainer),
307
309
  '@digigov/react-core/AutoCompleteResultList': lazyImport(_digigov_react_core_AutoCompleteResultList),
@@ -343,7 +345,7 @@ export default {
343
345
  '@digigov/react-core/ChipHeading': lazyImport(_digigov_react_core_ChipHeading),
344
346
  '@digigov/react-core/ChipKeyValue': lazyImport(_digigov_react_core_ChipKeyValue),
345
347
  '@digigov/react-core/ChoiceDividerText': lazyImport(_digigov_react_core_ChoiceDividerText),
346
- '@digigov/react-core/CircularProgressBase': lazyImport(_digigov_react_core_CircularProgressBase),
348
+ '@digigov/react-core/CircularProgress': lazyImport(_digigov_react_core_CircularProgress),
347
349
  '@digigov/react-core/CloseButton': lazyImport(_digigov_react_core_CloseButton),
348
350
  '@digigov/react-core/Code': lazyImport(_digigov_react_core_Code),
349
351
  '@digigov/react-core/CodeBlockContainer': lazyImport(_digigov_react_core_CodeBlockContainer),
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import clsx from 'clsx';
3
3
 
4
- type PropFactory<TProps> = (props: TProps) => any;
4
+ type WithClassName<TProps> = TProps & { className?: string };
5
+ type PropFactory<TProps> = (props: WithClassName<TProps>) => any;
5
6
 
6
7
  /**
7
8
  * A HOC that transforms the props of the wrapped component before passing them through
@@ -21,14 +22,12 @@ type PropFactory<TProps> = (props: TProps) => any;
21
22
  */
22
23
  export function extend<TProps, TAdditionalProps>(
23
24
  Component: React.ComponentType<TProps>,
24
- propFactory: PropFactory<React.PropsWithoutRef<TProps & TAdditionalProps>> = (
25
- props
26
- ) => props
25
+ propFactory: PropFactory<TProps & TAdditionalProps> = (props) => props
27
26
  ) {
28
- const ExtendedComponent = React.forwardRef<
29
- unknown,
30
- TProps & TAdditionalProps
31
- >(function ExtendedComponent(props, ref) {
27
+ const ExtendedComponent = React.forwardRef(function ExtendedComponent(
28
+ props: WithClassName<TProps & TAdditionalProps>,
29
+ ref
30
+ ) {
32
31
  const transformedProps = propFactory(props);
33
32
 
34
33
  return <Component ref={ref} {...transformedProps} />;
@@ -63,60 +62,59 @@ export function enablePseudoclass<T extends React.ElementType>(
63
62
  Component: T,
64
63
  { self = {}, children = {} }: PseudoclassOptions
65
64
  ) {
66
- return React.forwardRef<
67
- React.ComponentRef<T>,
68
- React.ComponentPropsWithRef<T>
69
- >(function enablePseudoclassComponent(
70
- { className, children: componentChildren, ...props },
71
- ref
72
- ) {
73
- // Handle if children is an array, add the corresponding classnames to the first and last child
74
- if (Array.isArray(componentChildren)) {
65
+ return React.forwardRef<React.ElementRef<T>, React.ComponentPropsWithRef<T>>(
66
+ function enablePseudoclassComponent(
67
+ { className, children: componentChildren, ...props },
68
+ ref
69
+ ) {
70
+ // Handle if children is an array, add the corresponding classnames to the first and last child
71
+ if (Array.isArray(componentChildren)) {
72
+ return (
73
+ <Component ref={ref} {...(props as any)} className={className}>
74
+ {componentChildren.map((child, index) => {
75
+ return React.cloneElement(child, {
76
+ key: index,
77
+ className: clsx(
78
+ child.props.className,
79
+ ...Object.entries(children).map(([key, classNames]) => {
80
+ if (index === 0 && key === 'first-child') return classNames;
81
+ if (
82
+ index === componentChildren.length - 1 &&
83
+ key === 'last-child'
84
+ )
85
+ return classNames;
86
+ return '';
87
+ })
88
+ ),
89
+ });
90
+ })}
91
+ </Component>
92
+ );
93
+ }
94
+ // Handle if children is a single element, add the corresponding classname for empty pseudoclass
95
+ if (componentChildren === undefined) {
96
+ const componentClassNames = Object.entries(self).map(([key, value]) => {
97
+ if (key === 'empty') return value.join(' ');
98
+ return '';
99
+ });
100
+ return (
101
+ <Component
102
+ ref={ref}
103
+ {...(props as any)}
104
+ className={clsx(className, ...componentClassNames)}
105
+ >
106
+ {componentChildren}
107
+ </Component>
108
+ );
109
+ }
110
+ // Else return the component as it is
75
111
  return (
76
112
  <Component ref={ref} {...(props as any)} className={className}>
77
- {componentChildren.map((child, index) => {
78
- return React.cloneElement(child, {
79
- key: index,
80
- className: clsx(
81
- child.props.className,
82
- ...Object.entries(children).map(([key, classNames]) => {
83
- if (index === 0 && key === 'first-child') return classNames;
84
- if (
85
- index === componentChildren.length - 1 &&
86
- key === 'last-child'
87
- )
88
- return classNames;
89
- return '';
90
- })
91
- ),
92
- });
93
- })}
94
- </Component>
95
- );
96
- }
97
- // Handle if children is a single element, add the corresponding classname for empty pseudoclass
98
- if (componentChildren === undefined) {
99
- const componentClassNames = Object.entries(self).map(([key, value]) => {
100
- if (key === 'empty') return value.join(' ');
101
- return '';
102
- });
103
- return (
104
- <Component
105
- ref={ref}
106
- {...(props as any)}
107
- className={clsx(className, ...componentClassNames)}
108
- >
109
113
  {componentChildren}
110
114
  </Component>
111
115
  );
112
116
  }
113
- // Else return the component as it is
114
- return (
115
- <Component ref={ref} {...(props as any)} className={className}>
116
- {componentChildren}
117
- </Component>
118
- );
119
- });
117
+ );
120
118
  }
121
119
 
122
120
  export default extend;
@@ -8,40 +8,42 @@ function extend(Component, propFactory = (props) => props) {
8
8
  return ExtendedComponent;
9
9
  }
10
10
  function enablePseudoclass(Component, { self = {}, children = {} }) {
11
- return React.forwardRef(function enablePseudoclassComponent({ className, children: componentChildren, ...props }, ref) {
12
- if (Array.isArray(componentChildren)) {
13
- return /* @__PURE__ */ React.createElement(Component, { ref, ...props, className }, componentChildren.map((child, index) => {
14
- return React.cloneElement(child, {
15
- key: index,
16
- className: clsx(
17
- child.props.className,
18
- ...Object.entries(children).map(([key, classNames]) => {
19
- if (index === 0 && key === "first-child") return classNames;
20
- if (index === componentChildren.length - 1 && key === "last-child")
21
- return classNames;
22
- return "";
23
- })
24
- )
11
+ return React.forwardRef(
12
+ function enablePseudoclassComponent({ className, children: componentChildren, ...props }, ref) {
13
+ if (Array.isArray(componentChildren)) {
14
+ return /* @__PURE__ */ React.createElement(Component, { ref, ...props, className }, componentChildren.map((child, index) => {
15
+ return React.cloneElement(child, {
16
+ key: index,
17
+ className: clsx(
18
+ child.props.className,
19
+ ...Object.entries(children).map(([key, classNames]) => {
20
+ if (index === 0 && key === "first-child") return classNames;
21
+ if (index === componentChildren.length - 1 && key === "last-child")
22
+ return classNames;
23
+ return "";
24
+ })
25
+ )
26
+ });
27
+ }));
28
+ }
29
+ if (componentChildren === void 0) {
30
+ const componentClassNames = Object.entries(self).map(([key, value]) => {
31
+ if (key === "empty") return value.join(" ");
32
+ return "";
25
33
  });
26
- }));
34
+ return /* @__PURE__ */ React.createElement(
35
+ Component,
36
+ {
37
+ ref,
38
+ ...props,
39
+ className: clsx(className, ...componentClassNames)
40
+ },
41
+ componentChildren
42
+ );
43
+ }
44
+ return /* @__PURE__ */ React.createElement(Component, { ref, ...props, className }, componentChildren);
27
45
  }
28
- if (componentChildren === void 0) {
29
- const componentClassNames = Object.entries(self).map(([key, value]) => {
30
- if (key === "empty") return value.join(" ");
31
- return "";
32
- });
33
- return /* @__PURE__ */ React.createElement(
34
- Component,
35
- {
36
- ref,
37
- ...props,
38
- className: clsx(className, ...componentClassNames)
39
- },
40
- componentChildren
41
- );
42
- }
43
- return /* @__PURE__ */ React.createElement(Component, { ref, ...props, className }, componentChildren);
44
- });
46
+ );
45
47
  }
46
48
  var index_native_default = extend;
47
49
  export {
@@ -1,5 +1,8 @@
1
1
  import React from 'react';
2
- type PropFactory<TProps> = (props: TProps) => any;
2
+ type WithClassName<TProps> = TProps & {
3
+ className?: string;
4
+ };
5
+ type PropFactory<TProps> = (props: WithClassName<TProps>) => any;
3
6
  /**
4
7
  * A HOC that transforms the props of the wrapped component before passing them through
5
8
  *
@@ -16,7 +19,7 @@ type PropFactory<TProps> = (props: TProps) => any;
16
19
  * type AdditionalProps = { lastName: string; };
17
20
  * const MyExpandedNativeComponent = extend<MyComponentProps, AdditionalProps>(MyNativeComponent, (props) => ({ name: `${props.name} ${props.lastName}`, ...props }));
18
21
  */
19
- export declare function extend<TProps, TAdditionalProps>(Component: React.ComponentType<TProps>, propFactory?: PropFactory<React.PropsWithoutRef<TProps & TAdditionalProps>>): React.ForwardRefExoticComponent<React.PropsWithoutRef<TProps & TAdditionalProps> & React.RefAttributes<unknown>>;
22
+ export declare function extend<TProps, TAdditionalProps>(Component: React.ComponentType<TProps>, propFactory?: PropFactory<TProps & TAdditionalProps>): React.ForwardRefExoticComponent<React.PropsWithoutRef<WithClassName<TProps & TAdditionalProps>> & React.RefAttributes<unknown>>;
20
23
  interface PseudoclassOptions {
21
24
  self?: Record<string, string[]>;
22
25
  children?: Record<string, string[]>;
@@ -39,5 +42,5 @@ interface PseudoclassOptions {
39
42
  * </MyComponentWithPseudoclass>
40
43
  *
41
44
  * */
42
- export declare function enablePseudoclass<T extends React.ElementType>(Component: T, { self, children }: PseudoclassOptions): React.ForwardRefExoticComponent<React.PropsWithoutRef<React.ComponentPropsWithRef<T>> & React.RefAttributes<React.ComponentRef<T>>>;
45
+ export declare function enablePseudoclass<T extends React.ElementType>(Component: T, { self, children }: PseudoclassOptions): React.ForwardRefExoticComponent<React.PropsWithoutRef<React.ComponentPropsWithRef<T>> & React.RefAttributes<React.ElementRef<T>>>;
43
46
  export default extend;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/index.native.tsx"],
4
- "sourcesContent": ["import React from 'react';\nimport clsx from 'clsx';\n\ntype PropFactory<TProps> = (props: TProps) => any;\n\n/**\n * A HOC that transforms the props of the wrapped component before passing them through\n *\n * @param Component The component to wrap\n * @param [propFactory=(props) => props] The function that transforms the props\n * @returns The wrapped component that accepts the transformed props\n *\n * @example\n * type MyComponentProps = { name: string; };\n * const MyComponent = (props: MyComponentProps) => <p>Hi {props.name}</p>;\n *\n * const MyNativeComponent = extend(MyComponent, (props) => ({ name: props.name.toUpperCase(), ...props }));\n *\n * type AdditionalProps = { lastName: string; };\n * const MyExpandedNativeComponent = extend<MyComponentProps, AdditionalProps>(MyNativeComponent, (props) => ({ name: `${props.name} ${props.lastName}`, ...props }));\n */\nexport function extend<TProps, TAdditionalProps>(\n Component: React.ComponentType<TProps>,\n propFactory: PropFactory<React.PropsWithoutRef<TProps & TAdditionalProps>> = (\n props\n ) => props\n) {\n const ExtendedComponent = React.forwardRef<\n unknown,\n TProps & TAdditionalProps\n >(function ExtendedComponent(props, ref) {\n const transformedProps = propFactory(props);\n\n return <Component ref={ref} {...transformedProps} />;\n });\n return ExtendedComponent;\n}\n\ninterface PseudoclassOptions {\n self?: Record<string, string[]>;\n children?: Record<string, string[]>;\n}\n\n/**\n * A HOC that adds pseudoclass support to the wrapped component\n *\n * @param Component The component to wrap\n * @param options The pseudoclass options\n * @returns The wrapped component that supports pseudoclasses\n *\n * @example\n * const MyComponent = (props) => <p {...props}>Hi</p>;\n * const MyComponentWithPseudoclass = enablePseudoclass(MyComponent\n * { self: { 'empty': ['ds-component__empty'] }, childrenClassNames: { 'first-child': ['ds-component__first-child'] } });\n *\n * <MyComponentWithPseudoclass className=\"my-class\" empty focus>\n * <p>First child</p>\n * <p>Second child</p>\n * </MyComponentWithPseudoclass>\n *\n * */\nexport function enablePseudoclass<T extends React.ElementType>(\n Component: T,\n { self = {}, children = {} }: PseudoclassOptions\n) {\n return React.forwardRef<\n React.ComponentRef<T>,\n React.ComponentPropsWithRef<T>\n >(function enablePseudoclassComponent(\n { className, children: componentChildren, ...props },\n ref\n ) {\n // Handle if children is an array, add the corresponding classnames to the first and last child\n if (Array.isArray(componentChildren)) {\n return (\n <Component ref={ref} {...(props as any)} className={className}>\n {componentChildren.map((child, index) => {\n return React.cloneElement(child, {\n key: index,\n className: clsx(\n child.props.className,\n ...Object.entries(children).map(([key, classNames]) => {\n if (index === 0 && key === 'first-child') return classNames;\n if (\n index === componentChildren.length - 1 &&\n key === 'last-child'\n )\n return classNames;\n return '';\n })\n ),\n });\n })}\n </Component>\n );\n }\n // Handle if children is a single element, add the corresponding classname for empty pseudoclass\n if (componentChildren === undefined) {\n const componentClassNames = Object.entries(self).map(([key, value]) => {\n if (key === 'empty') return value.join(' ');\n return '';\n });\n return (\n <Component\n ref={ref}\n {...(props as any)}\n className={clsx(className, ...componentClassNames)}\n >\n {componentChildren}\n </Component>\n );\n }\n // Else return the component as it is\n return (\n <Component ref={ref} {...(props as any)} className={className}>\n {componentChildren}\n </Component>\n );\n });\n}\n\nexport default extend;\n"],
5
- "mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,UAAU;AAoBV,SAAS,OACd,WACA,cAA6E,CAC3E,UACG,OACL;AACA,QAAM,oBAAoB,MAAM,WAG9B,SAASA,mBAAkB,OAAO,KAAK;AACvC,UAAM,mBAAmB,YAAY,KAAK;AAE1C,WAAO,oCAAC,aAAU,KAAW,GAAG,kBAAkB;AAAA,EACpD,CAAC;AACD,SAAO;AACT;AAyBO,SAAS,kBACd,WACA,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC,EAAE,GAC3B;AACA,SAAO,MAAM,WAGX,SAAS,2BACT,EAAE,WAAW,UAAU,mBAAmB,GAAG,MAAM,GACnD,KACA;AAEA,QAAI,MAAM,QAAQ,iBAAiB,GAAG;AACpC,aACE,oCAAC,aAAU,KAAW,GAAI,OAAe,aACtC,kBAAkB,IAAI,CAAC,OAAO,UAAU;AACvC,eAAO,MAAM,aAAa,OAAO;AAAA,UAC/B,KAAK;AAAA,UACL,WAAW;AAAA,YACT,MAAM,MAAM;AAAA,YACZ,GAAG,OAAO,QAAQ,QAAQ,EAAE,IAAI,CAAC,CAAC,KAAK,UAAU,MAAM;AACrD,kBAAI,UAAU,KAAK,QAAQ,cAAe,QAAO;AACjD,kBACE,UAAU,kBAAkB,SAAS,KACrC,QAAQ;AAER,uBAAO;AACT,qBAAO;AAAA,YACT,CAAC;AAAA,UACH;AAAA,QACF,CAAC;AAAA,MACH,CAAC,CACH;AAAA,IAEJ;AAEA,QAAI,sBAAsB,QAAW;AACnC,YAAM,sBAAsB,OAAO,QAAQ,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AACrE,YAAI,QAAQ,QAAS,QAAO,MAAM,KAAK,GAAG;AAC1C,eAAO;AAAA,MACT,CAAC;AACD,aACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACC,GAAI;AAAA,UACL,WAAW,KAAK,WAAW,GAAG,mBAAmB;AAAA;AAAA,QAEhD;AAAA,MACH;AAAA,IAEJ;AAEA,WACE,oCAAC,aAAU,KAAW,GAAI,OAAe,aACtC,iBACH;AAAA,EAEJ,CAAC;AACH;AAEA,IAAO,uBAAQ;",
4
+ "sourcesContent": ["import React from 'react';\nimport clsx from 'clsx';\n\ntype WithClassName<TProps> = TProps & { className?: string };\ntype PropFactory<TProps> = (props: WithClassName<TProps>) => any;\n\n/**\n * A HOC that transforms the props of the wrapped component before passing them through\n *\n * @param Component The component to wrap\n * @param [propFactory=(props) => props] The function that transforms the props\n * @returns The wrapped component that accepts the transformed props\n *\n * @example\n * type MyComponentProps = { name: string; };\n * const MyComponent = (props: MyComponentProps) => <p>Hi {props.name}</p>;\n *\n * const MyNativeComponent = extend(MyComponent, (props) => ({ name: props.name.toUpperCase(), ...props }));\n *\n * type AdditionalProps = { lastName: string; };\n * const MyExpandedNativeComponent = extend<MyComponentProps, AdditionalProps>(MyNativeComponent, (props) => ({ name: `${props.name} ${props.lastName}`, ...props }));\n */\nexport function extend<TProps, TAdditionalProps>(\n Component: React.ComponentType<TProps>,\n propFactory: PropFactory<TProps & TAdditionalProps> = (props) => props\n) {\n const ExtendedComponent = React.forwardRef(function ExtendedComponent(\n props: WithClassName<TProps & TAdditionalProps>,\n ref\n ) {\n const transformedProps = propFactory(props);\n\n return <Component ref={ref} {...transformedProps} />;\n });\n return ExtendedComponent;\n}\n\ninterface PseudoclassOptions {\n self?: Record<string, string[]>;\n children?: Record<string, string[]>;\n}\n\n/**\n * A HOC that adds pseudoclass support to the wrapped component\n *\n * @param Component The component to wrap\n * @param options The pseudoclass options\n * @returns The wrapped component that supports pseudoclasses\n *\n * @example\n * const MyComponent = (props) => <p {...props}>Hi</p>;\n * const MyComponentWithPseudoclass = enablePseudoclass(MyComponent\n * { self: { 'empty': ['ds-component__empty'] }, childrenClassNames: { 'first-child': ['ds-component__first-child'] } });\n *\n * <MyComponentWithPseudoclass className=\"my-class\" empty focus>\n * <p>First child</p>\n * <p>Second child</p>\n * </MyComponentWithPseudoclass>\n *\n * */\nexport function enablePseudoclass<T extends React.ElementType>(\n Component: T,\n { self = {}, children = {} }: PseudoclassOptions\n) {\n return React.forwardRef<React.ElementRef<T>, React.ComponentPropsWithRef<T>>(\n function enablePseudoclassComponent(\n { className, children: componentChildren, ...props },\n ref\n ) {\n // Handle if children is an array, add the corresponding classnames to the first and last child\n if (Array.isArray(componentChildren)) {\n return (\n <Component ref={ref} {...(props as any)} className={className}>\n {componentChildren.map((child, index) => {\n return React.cloneElement(child, {\n key: index,\n className: clsx(\n child.props.className,\n ...Object.entries(children).map(([key, classNames]) => {\n if (index === 0 && key === 'first-child') return classNames;\n if (\n index === componentChildren.length - 1 &&\n key === 'last-child'\n )\n return classNames;\n return '';\n })\n ),\n });\n })}\n </Component>\n );\n }\n // Handle if children is a single element, add the corresponding classname for empty pseudoclass\n if (componentChildren === undefined) {\n const componentClassNames = Object.entries(self).map(([key, value]) => {\n if (key === 'empty') return value.join(' ');\n return '';\n });\n return (\n <Component\n ref={ref}\n {...(props as any)}\n className={clsx(className, ...componentClassNames)}\n >\n {componentChildren}\n </Component>\n );\n }\n // Else return the component as it is\n return (\n <Component ref={ref} {...(props as any)} className={className}>\n {componentChildren}\n </Component>\n );\n }\n );\n}\n\nexport default extend;\n"],
5
+ "mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,UAAU;AAqBV,SAAS,OACd,WACA,cAAsD,CAAC,UAAU,OACjE;AACA,QAAM,oBAAoB,MAAM,WAAW,SAASA,mBAClD,OACA,KACA;AACA,UAAM,mBAAmB,YAAY,KAAK;AAE1C,WAAO,oCAAC,aAAU,KAAW,GAAG,kBAAkB;AAAA,EACpD,CAAC;AACD,SAAO;AACT;AAyBO,SAAS,kBACd,WACA,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC,EAAE,GAC3B;AACA,SAAO,MAAM;AAAA,IACX,SAAS,2BACP,EAAE,WAAW,UAAU,mBAAmB,GAAG,MAAM,GACnD,KACA;AAEA,UAAI,MAAM,QAAQ,iBAAiB,GAAG;AACpC,eACE,oCAAC,aAAU,KAAW,GAAI,OAAe,aACtC,kBAAkB,IAAI,CAAC,OAAO,UAAU;AACvC,iBAAO,MAAM,aAAa,OAAO;AAAA,YAC/B,KAAK;AAAA,YACL,WAAW;AAAA,cACT,MAAM,MAAM;AAAA,cACZ,GAAG,OAAO,QAAQ,QAAQ,EAAE,IAAI,CAAC,CAAC,KAAK,UAAU,MAAM;AACrD,oBAAI,UAAU,KAAK,QAAQ,cAAe,QAAO;AACjD,oBACE,UAAU,kBAAkB,SAAS,KACrC,QAAQ;AAER,yBAAO;AACT,uBAAO;AAAA,cACT,CAAC;AAAA,YACH;AAAA,UACF,CAAC;AAAA,QACH,CAAC,CACH;AAAA,MAEJ;AAEA,UAAI,sBAAsB,QAAW;AACnC,cAAM,sBAAsB,OAAO,QAAQ,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AACrE,cAAI,QAAQ,QAAS,QAAO,MAAM,KAAK,GAAG;AAC1C,iBAAO;AAAA,QACT,CAAC;AACD,eACE;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACC,GAAI;AAAA,YACL,WAAW,KAAK,WAAW,GAAG,mBAAmB;AAAA;AAAA,UAEhD;AAAA,QACH;AAAA,MAEJ;AAEA,aACE,oCAAC,aAAU,KAAW,GAAI,OAAe,aACtC,iBACH;AAAA,IAEJ;AAAA,EACF;AACF;AAEA,IAAO,uBAAQ;",
6
6
  "names": ["ExtendedComponent"]
7
7
  }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/CircularProgressBase/index.tsx"],
4
- "sourcesContent": ["import React from 'react';\nimport clsx from 'clsx';\nimport Base, { BaseProps } from '@digigov/react-core/Base';\n\nexport interface CircularProgressBaseProps extends BaseProps<'svg'> {\n /**\n * color prop is optional.\n * color prop is used to change the color of the loader.\n * @value 'primary' is the default color.\n * @value 'secondary' recommended for dark backgrounds.\n * @default 'primary'\n */\n color?: 'primary' | 'secondary';\n /**\n * size prop is optional.\n * size prop is used to change the size of the loader.\n * @value 'sm'\n * @value 'md'\n * @value 'lg'\n * @default 'md'\n */\n size?: 'sm' | 'md' | 'lg';\n}\n/**\n * Use CircularProgressBase component as an animated loader.\n * CircularProgressBase can be used inside LoaderContainer component.\n */\nexport const CircularProgressBase = React.forwardRef<\n SVGElement,\n CircularProgressBaseProps\n>(function CircularProgress(\n { color = 'primary', size = 'md', className, ...props },\n ref\n) {\n return (\n <Base\n as=\"svg\"\n ref={ref}\n className={clsx(className, {\n 'ds-circular-progress': true,\n 'ds-circular-progress--secondary': color === 'secondary',\n 'ds-circular-progress--sm': size === 'sm',\n 'ds-circular-progress--md': size === 'md',\n 'ds-circular-progress--lg': size === 'lg',\n })}\n focusable=\"false\"\n viewBox=\"0 0 200 200\"\n aria-hidden=\"true\"\n {...props}\n >\n <path\n className=\"ds-circular-progress__circle ds-circular-progress__circle--1\"\n d=\"M26,99.551C26,55.478,60.246,27.5,99.85,27.5S174,55.478,174,99.551,139.455,172.5,99.85,172.5C60.273,172.473,26,143.6,26,99.551Z\"\n />\n <path\n className=\"ds-circular-progress__circle ds-circular-progress__circle--2\"\n d=\"M26,99.551C26,55.478,60.246,27.5,99.85,27.5S174,55.478,174,99.551,139.455,172.5,99.85,172.5C60.273,172.473,26,143.6,26,99.551Z\"\n />\n </Base>\n );\n});\n\nexport default CircularProgressBase;\n"],
5
- "mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,OAAO,UAAyB;AAyBzB,MAAM,uBAAuB,MAAM,WAGxC,SAAS,iBACT,EAAE,QAAQ,WAAW,OAAO,MAAM,WAAW,GAAG,MAAM,GACtD,KACA;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAG;AAAA,MACH;AAAA,MACA,WAAW,KAAK,WAAW;AAAA,QACzB,wBAAwB;AAAA,QACxB,mCAAmC,UAAU;AAAA,QAC7C,4BAA4B,SAAS;AAAA,QACrC,4BAA4B,SAAS;AAAA,QACrC,4BAA4B,SAAS;AAAA,MACvC,CAAC;AAAA,MACD,WAAU;AAAA,MACV,SAAQ;AAAA,MACR,eAAY;AAAA,MACX,GAAG;AAAA;AAAA,IAEJ;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,GAAE;AAAA;AAAA,IACJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,GAAE;AAAA;AAAA,IACJ;AAAA,EACF;AAEJ,CAAC;AAED,IAAO,+BAAQ;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/CircularProgressBase/index.tsx"],
4
- "sourcesContent": ["import React from 'react';\nimport clsx from 'clsx';\nimport Base, { BaseProps } from '@digigov/react-core/Base';\n\nexport interface CircularProgressBaseProps extends BaseProps<'svg'> {\n /**\n * color prop is optional.\n * color prop is used to change the color of the loader.\n * @value 'primary' is the default color.\n * @value 'secondary' recommended for dark backgrounds.\n * @default 'primary'\n */\n color?: 'primary' | 'secondary';\n /**\n * size prop is optional.\n * size prop is used to change the size of the loader.\n * @value 'sm'\n * @value 'md'\n * @value 'lg'\n * @default 'md'\n */\n size?: 'sm' | 'md' | 'lg';\n}\n/**\n * Use CircularProgressBase component as an animated loader.\n * CircularProgressBase can be used inside LoaderContainer component.\n */\nexport const CircularProgressBase = React.forwardRef<\n SVGElement,\n CircularProgressBaseProps\n>(function CircularProgress(\n { color = 'primary', size = 'md', className, ...props },\n ref\n) {\n return (\n <Base\n as=\"svg\"\n ref={ref}\n className={clsx(className, {\n 'ds-circular-progress': true,\n 'ds-circular-progress--secondary': color === 'secondary',\n 'ds-circular-progress--sm': size === 'sm',\n 'ds-circular-progress--md': size === 'md',\n 'ds-circular-progress--lg': size === 'lg',\n })}\n focusable=\"false\"\n viewBox=\"0 0 200 200\"\n aria-hidden=\"true\"\n {...props}\n >\n <path\n className=\"ds-circular-progress__circle ds-circular-progress__circle--1\"\n d=\"M26,99.551C26,55.478,60.246,27.5,99.85,27.5S174,55.478,174,99.551,139.455,172.5,99.85,172.5C60.273,172.473,26,143.6,26,99.551Z\"\n />\n <path\n className=\"ds-circular-progress__circle ds-circular-progress__circle--2\"\n d=\"M26,99.551C26,55.478,60.246,27.5,99.85,27.5S174,55.478,174,99.551,139.455,172.5,99.85,172.5C60.273,172.473,26,143.6,26,99.551Z\"\n />\n </Base>\n );\n});\n\nexport default CircularProgressBase;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,kBAAiB;AACjB,kBAAgC;AAyBzB,MAAM,uBAAuB,aAAAA,QAAM,WAGxC,SAAS,iBACT,EAAE,QAAQ,WAAW,OAAO,MAAM,WAAW,GAAG,MAAM,GACtD,KACA;AACA,SACE,6BAAAA,QAAA;AAAA,IAAC,YAAAC;AAAA,IAAA;AAAA,MACC,IAAG;AAAA,MACH;AAAA,MACA,eAAW,YAAAC,SAAK,WAAW;AAAA,QACzB,wBAAwB;AAAA,QACxB,mCAAmC,UAAU;AAAA,QAC7C,4BAA4B,SAAS;AAAA,QACrC,4BAA4B,SAAS;AAAA,QACrC,4BAA4B,SAAS;AAAA,MACvC,CAAC;AAAA,MACD,WAAU;AAAA,MACV,SAAQ;AAAA,MACR,eAAY;AAAA,MACX,GAAG;AAAA;AAAA,IAEJ,6BAAAF,QAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,GAAE;AAAA;AAAA,IACJ;AAAA,IACA,6BAAAA,QAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,GAAE;AAAA;AAAA,IACJ;AAAA,EACF;AAEJ,CAAC;AAED,IAAO,+BAAQ;",
6
- "names": ["React", "Base", "clsx"]
7
- }
@@ -1,38 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
-
4
- import CircularProgressBase from '@digigov/react-core/CircularProgressBase';
5
-
6
- it('renders the CircularProgressBase', () => {
7
- expect(render(<CircularProgressBase />).baseElement).toMatchSnapshot();
8
- });
9
-
10
- it('renders the CircularProgressBase with size sm', () => {
11
- expect(
12
- render(<CircularProgressBase size="sm" />).baseElement
13
- ).toMatchSnapshot();
14
- });
15
-
16
- it('renders the CircularProgressBase with size lg', () => {
17
- expect(
18
- render(<CircularProgressBase size="lg" />).baseElement
19
- ).toMatchSnapshot();
20
- });
21
-
22
- it('renders the CircularProgressBase with color=secondary prop', () => {
23
- expect(
24
- render(<CircularProgressBase color={'secondary'} />).baseElement
25
- ).toMatchSnapshot();
26
- });
27
-
28
- it('renders the CircularProgressBase with color=secondary and size sm props', () => {
29
- expect(
30
- render(<CircularProgressBase color={'secondary'} size="sm" />).baseElement
31
- ).toMatchSnapshot();
32
- });
33
-
34
- it('renders the CircularProgressBase with color=secondary and size lg props', () => {
35
- expect(
36
- render(<CircularProgressBase color={'secondary'} size="lg" />).baseElement
37
- ).toMatchSnapshot();
38
- });