@descope/flow-components 2.0.428 → 2.0.430

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.
@@ -17,12 +17,13 @@ type ContainerAlignment = {
17
17
  type Props = {
18
18
  direction?: 'row' | 'column';
19
19
  shadow?: 'md' | 'lg' | 'xl' | '2xl';
20
- 'border-radius'?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl';
20
+ borderRadius?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl';
21
21
  paddingX?: string;
22
22
  paddingY?: string;
23
23
  background?: string;
24
24
  backgroundImageUrl?: string;
25
25
  width?: string;
26
+ variant?: string;
26
27
  } & ((Flex & Never<ContainerAlignment>) | (ContainerAlignment & Never<Flex>));
27
28
  declare global {
28
29
  namespace React.JSX {
@@ -1 +1,2 @@
1
1
  export declare function handleCustomValidationMessages(): void;
2
+ export declare const isNumeric: (value?: string) => boolean;
package/dist/index.cjs.js CHANGED
@@ -100,6 +100,8 @@ const Button = React__default.default.forwardRef(({ children, startIcon, startIc
100
100
 
101
101
  const Code = React__default.default.forwardRef((props, ref) => React__default.default.createElement("descope-passcode", { ref: ref, ...props }));
102
102
 
103
+ const isNumeric = (value) => /^\d*\.?\d+$/.test(value);
104
+
103
105
  const justifyContent = {
104
106
  start: 'flex-start',
105
107
  center: 'safe center',
@@ -115,21 +117,45 @@ const alignItems = {
115
117
  baseline: 'baseline',
116
118
  stretch: 'stretch'
117
119
  };
118
- const Container = React__default.default.forwardRef(({ background, justify, paddingX = '0', paddingY = '0', shadow, width, align, spaceBetween, backgroundImageUrl, direction = 'row', ...props }, ref) => {
120
+ const applyDefaults = ({ paddingX, paddingY, align, justify, background, spaceBetween }) => ({
121
+ 'st-horizontal-padding': !paddingX || isNumeric(paddingX)
122
+ ? `${Number.parseInt(paddingX || '0', 10) / 4}rem`
123
+ : paddingX,
124
+ 'st-vertical-padding': !paddingY || isNumeric(paddingY)
125
+ ? `${Number.parseInt(paddingY || '0', 10) / 4}rem`
126
+ : paddingY,
127
+ 'st-align-items': alignItems[align],
128
+ 'st-justify-content': justifyContent[justify],
129
+ 'st-background-color': background,
130
+ ...(spaceBetween
131
+ ? {
132
+ 'st-gap': isNumeric(spaceBetween)
133
+ ? `${Number.parseFloat(spaceBetween || '0') / 4}rem`
134
+ : spaceBetween
135
+ }
136
+ : {})
137
+ });
138
+ const Container = React__default.default.forwardRef(({ background, justify, paddingX, paddingY, shadow, width, align, spaceBetween, backgroundImageUrl, direction = 'row', variant, borderRadius, ...props }, ref) => {
119
139
  const mergedProps = {
120
140
  ...props,
121
141
  direction,
122
142
  shadow,
123
- 'st-horizontal-padding': `${Number.parseInt(paddingX, 10) / 4}rem`,
124
- 'st-vertical-padding': `${Number.parseInt(paddingY, 10) / 4}rem`,
125
- 'st-align-items': alignItems[align],
126
- 'st-justify-content': justifyContent[justify],
127
- 'st-background-color': background,
143
+ variant,
144
+ 'border-radius': borderRadius || props['border-radius'],
145
+ 'st-host-width': width || '100%',
128
146
  'st-background-image': backgroundImageUrl?.trim()
129
147
  ? `url('${backgroundImageUrl.trim()}')`
130
148
  : undefined,
131
- 'st-host-width': width,
132
- 'st-gap': spaceBetween && `${Number.parseFloat(spaceBetween) / 4}rem`
149
+ ...(variant
150
+ ? {}
151
+ : applyDefaults({
152
+ paddingX,
153
+ paddingY,
154
+ align,
155
+ justify,
156
+ background,
157
+ spaceBetween
158
+ }))
133
159
  };
134
160
  // eslint-disable-next-line react/jsx-props-no-spreading
135
161
  return React__default.default.createElement("descope-container", { ...mergedProps, ref: ref });
package/dist/index.d.ts CHANGED
@@ -105,12 +105,13 @@ type ContainerAlignment = {
105
105
  type Props$C = {
106
106
  direction?: 'row' | 'column';
107
107
  shadow?: 'md' | 'lg' | 'xl' | '2xl';
108
- 'border-radius'?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl';
108
+ borderRadius?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl';
109
109
  paddingX?: string;
110
110
  paddingY?: string;
111
111
  background?: string;
112
112
  backgroundImageUrl?: string;
113
113
  width?: string;
114
+ variant?: string;
114
115
  } & ((Flex & Never<ContainerAlignment>) | (ContainerAlignment & Never<Flex>));
115
116
  declare global {
116
117
  namespace React.JSX {
package/dist/index.esm.js CHANGED
@@ -95,6 +95,8 @@ const Button = React.forwardRef(({ children, startIcon, startIconColorText, colo
95
95
 
96
96
  const Code = React.forwardRef((props, ref) => React.createElement("descope-passcode", { ref: ref, ...props }));
97
97
 
98
+ const isNumeric = (value) => /^\d*\.?\d+$/.test(value);
99
+
98
100
  const justifyContent = {
99
101
  start: 'flex-start',
100
102
  center: 'safe center',
@@ -110,21 +112,45 @@ const alignItems = {
110
112
  baseline: 'baseline',
111
113
  stretch: 'stretch'
112
114
  };
113
- const Container = React.forwardRef(({ background, justify, paddingX = '0', paddingY = '0', shadow, width, align, spaceBetween, backgroundImageUrl, direction = 'row', ...props }, ref) => {
115
+ const applyDefaults = ({ paddingX, paddingY, align, justify, background, spaceBetween }) => ({
116
+ 'st-horizontal-padding': !paddingX || isNumeric(paddingX)
117
+ ? `${Number.parseInt(paddingX || '0', 10) / 4}rem`
118
+ : paddingX,
119
+ 'st-vertical-padding': !paddingY || isNumeric(paddingY)
120
+ ? `${Number.parseInt(paddingY || '0', 10) / 4}rem`
121
+ : paddingY,
122
+ 'st-align-items': alignItems[align],
123
+ 'st-justify-content': justifyContent[justify],
124
+ 'st-background-color': background,
125
+ ...(spaceBetween
126
+ ? {
127
+ 'st-gap': isNumeric(spaceBetween)
128
+ ? `${Number.parseFloat(spaceBetween || '0') / 4}rem`
129
+ : spaceBetween
130
+ }
131
+ : {})
132
+ });
133
+ const Container = React.forwardRef(({ background, justify, paddingX, paddingY, shadow, width, align, spaceBetween, backgroundImageUrl, direction = 'row', variant, borderRadius, ...props }, ref) => {
114
134
  const mergedProps = {
115
135
  ...props,
116
136
  direction,
117
137
  shadow,
118
- 'st-horizontal-padding': `${Number.parseInt(paddingX, 10) / 4}rem`,
119
- 'st-vertical-padding': `${Number.parseInt(paddingY, 10) / 4}rem`,
120
- 'st-align-items': alignItems[align],
121
- 'st-justify-content': justifyContent[justify],
122
- 'st-background-color': background,
138
+ variant,
139
+ 'border-radius': borderRadius || props['border-radius'],
140
+ 'st-host-width': width || '100%',
123
141
  'st-background-image': backgroundImageUrl?.trim()
124
142
  ? `url('${backgroundImageUrl.trim()}')`
125
143
  : undefined,
126
- 'st-host-width': width,
127
- 'st-gap': spaceBetween && `${Number.parseFloat(spaceBetween) / 4}rem`
144
+ ...(variant
145
+ ? {}
146
+ : applyDefaults({
147
+ paddingX,
148
+ paddingY,
149
+ align,
150
+ justify,
151
+ background,
152
+ spaceBetween
153
+ }))
128
154
  };
129
155
  // eslint-disable-next-line react/jsx-props-no-spreading
130
156
  return React.createElement("descope-container", { ...mergedProps, ref: ref });
@@ -17,12 +17,13 @@ type ContainerAlignment = {
17
17
  type Props = {
18
18
  direction?: 'row' | 'column';
19
19
  shadow?: 'md' | 'lg' | 'xl' | '2xl';
20
- 'border-radius'?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl';
20
+ borderRadius?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl';
21
21
  paddingX?: string;
22
22
  paddingY?: string;
23
23
  background?: string;
24
24
  backgroundImageUrl?: string;
25
25
  width?: string;
26
+ variant?: string;
26
27
  } & ((Flex & Never<ContainerAlignment>) | (ContainerAlignment & Never<Flex>));
27
28
  declare global {
28
29
  namespace React.JSX {
@@ -1 +1,2 @@
1
1
  export declare function handleCustomValidationMessages(): void;
2
+ export declare const isNumeric: (value?: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/flow-components",
3
- "version": "2.0.428",
3
+ "version": "2.0.430",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -54,7 +54,7 @@
54
54
  "@storybook/testing-library": "^0.2.2",
55
55
  "@testing-library/jest-dom": "^6.0.0",
56
56
  "@testing-library/react": "16.2.0",
57
- "@testing-library/user-event": "14.6.0",
57
+ "@testing-library/user-event": "14.6.1",
58
58
  "@types/color": "^4.0.0",
59
59
  "@types/jest": "^29.0.0",
60
60
  "@types/react": "^19.0.0",