@razorpay/blade 11.12.0 → 11.13.1
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/build/lib/native/components/ProgressBar/CircularProgressBar.native.js +31 -0
- package/build/lib/native/components/ProgressBar/CircularProgressBar.native.js.map +1 -0
- package/build/lib/native/components/ProgressBar/CircularProgressLabel.js +17 -0
- package/build/lib/native/components/ProgressBar/CircularProgressLabel.js.map +1 -0
- package/build/lib/native/components/ProgressBar/ProgressBar.js +2 -1
- package/build/lib/native/components/ProgressBar/ProgressBar.js.map +1 -1
- package/build/lib/native/components/ProgressBar/ProgressBarFilled.native.js +1 -1
- package/build/lib/native/components/ProgressBar/ProgressBarFilled.native.js.map +1 -1
- package/build/lib/native/components/ProgressBar/progressBarTokens.js +6 -2
- package/build/lib/native/components/ProgressBar/progressBarTokens.js.map +1 -1
- package/build/lib/native/tokens/global/size.js +1 -1
- package/build/lib/native/tokens/global/size.js.map +1 -1
- package/build/lib/web/development/components/Input/PhoneNumberInput/CountrySelector.web.js +9 -1
- package/build/lib/web/development/components/Input/PhoneNumberInput/CountrySelector.web.js.map +1 -1
- package/build/lib/web/development/components/ProgressBar/CircularProgressBar.web.js +140 -0
- package/build/lib/web/development/components/ProgressBar/CircularProgressBar.web.js.map +1 -0
- package/build/lib/web/development/components/ProgressBar/CircularProgressLabel.js +38 -0
- package/build/lib/web/development/components/ProgressBar/CircularProgressLabel.js.map +1 -0
- package/build/lib/web/development/components/ProgressBar/ProgressBar.js +47 -10
- package/build/lib/web/development/components/ProgressBar/ProgressBar.js.map +1 -1
- package/build/lib/web/development/components/ProgressBar/ProgressBarFilled.web.js +6 -6
- package/build/lib/web/development/components/ProgressBar/ProgressBarFilled.web.js.map +1 -1
- package/build/lib/web/development/components/ProgressBar/progressBarTokens.js +45 -1
- package/build/lib/web/development/components/ProgressBar/progressBarTokens.js.map +1 -1
- package/build/lib/web/development/tokens/global/size.js +4 -0
- package/build/lib/web/development/tokens/global/size.js.map +1 -1
- package/build/lib/web/production/components/Input/PhoneNumberInput/CountrySelector.web.js +9 -1
- package/build/lib/web/production/components/Input/PhoneNumberInput/CountrySelector.web.js.map +1 -1
- package/build/lib/web/production/components/ProgressBar/CircularProgressBar.web.js +140 -0
- package/build/lib/web/production/components/ProgressBar/CircularProgressBar.web.js.map +1 -0
- package/build/lib/web/production/components/ProgressBar/CircularProgressLabel.js +38 -0
- package/build/lib/web/production/components/ProgressBar/CircularProgressLabel.js.map +1 -0
- package/build/lib/web/production/components/ProgressBar/ProgressBar.js +47 -10
- package/build/lib/web/production/components/ProgressBar/ProgressBar.js.map +1 -1
- package/build/lib/web/production/components/ProgressBar/ProgressBarFilled.web.js +6 -6
- package/build/lib/web/production/components/ProgressBar/ProgressBarFilled.web.js.map +1 -1
- package/build/lib/web/production/components/ProgressBar/progressBarTokens.js +45 -1
- package/build/lib/web/production/components/ProgressBar/progressBarTokens.js.map +1 -1
- package/build/lib/web/production/tokens/global/size.js +4 -0
- package/build/lib/web/production/tokens/global/size.js.map +1 -1
- package/build/types/components/index.d.ts +11 -5
- package/build/types/components/index.native.d.ts +11 -5
- package/build/types/tokens/index.d.ts +4 -0
- package/build/types/tokens/index.native.d.ts +4 -0
- package/codemods/migrate-progressbar/transformers/__test__/migrate-progressbar.test.ts +28 -0
- package/codemods/migrate-progressbar/transformers/index.ts +89 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"size.js","sources":["../../../../../../src/tokens/global/size.ts"],"sourcesContent":["/**\n * Size tokens are currently not exposed for users (therefore not available in theme)\n */\nexport const size = {\n /** 0 px */\n 0: 0,\n /** 1 px */\n 1: 1,\n /** 2 px */\n 2: 2,\n /** 3 px */\n 3: 3,\n /** 4 px */\n 4: 4,\n /** 5 px */\n 5: 5,\n /** 6 px */\n 6: 6,\n /** 8 px */\n 8: 8,\n /** 10 px */\n 10: 10,\n /** 12 px */\n 12: 12,\n /** 16 px */\n 16: 16,\n /** 18 px */\n 18: 18,\n /** 20 px */\n 20: 20,\n /** 24 px */\n 24: 24,\n /** 28 px */\n 28: 28,\n /** 32 px */\n 32: 32,\n /** 36 px */\n 36: 36,\n /** 40 px */\n 40: 40,\n /** 44 px */\n 44: 44,\n /** 48 px */\n 48: 48,\n /** 56 px */\n 56: 56,\n /** 64 px */\n 64: 64,\n /** 100 px */\n 100: 100,\n /** 120 px */\n 120: 120,\n /** 140 px */\n 140: 140,\n /** 160 px */\n 160: 160,\n /** 176 px */\n 176: 176,\n /** 200 px */\n 200: 200,\n /** 240 px */\n 240: 240,\n /** 300 px */\n 300: 300,\n /** 360 px */\n 360: 360,\n /** 400 px */\n 400: 400,\n /** 584 px */\n 584: 584,\n /** 640 px */\n 640: 640,\n /** 760 px */\n 760: 760,\n /** 800 px */\n 800: 800,\n /** 1024 px */\n 1024: 1024,\n /** 1136 px */\n 1136: 1136,\n} as const;\n\nexport type Size = typeof size;\n"],"names":["size"],"mappings":"AAAA;AACA;AACA;AACO,IAAMA,IAAI,GAAG;AAClB;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,IAAI,EAAE,IAAI;AACV;AACA,EAAA,IAAI,EAAE,IAAA;AACR;;;;"}
|
|
1
|
+
{"version":3,"file":"size.js","sources":["../../../../../../src/tokens/global/size.ts"],"sourcesContent":["/**\n * Size tokens are currently not exposed for users (therefore not available in theme)\n */\nexport const size = {\n /** 0 px */\n 0: 0,\n /** 1 px */\n 1: 1,\n /** 2 px */\n 2: 2,\n /** 3 px */\n 3: 3,\n /** 4 px */\n 4: 4,\n /** 5 px */\n 5: 5,\n /** 6 px */\n 6: 6,\n /** 7 px */\n 7: 7,\n /** 8 px */\n 8: 8,\n /** 10 px */\n 10: 10,\n /** 12 px */\n 12: 12,\n /** 16 px */\n 16: 16,\n /** 18 px */\n 18: 18,\n /** 20 px */\n 20: 20,\n /** 24 px */\n 24: 24,\n /** 28 px */\n 28: 28,\n /** 32 px */\n 32: 32,\n /** 36 px */\n 36: 36,\n /** 40 px */\n 40: 40,\n /** 44 px */\n 44: 44,\n /** 48 px */\n 48: 48,\n /** 56 px */\n 56: 56,\n /** 64 px */\n 64: 64,\n /** 72 px */\n 72: 72,\n /** 100 px */\n 100: 100,\n /** 120 px */\n 120: 120,\n /** 140 px */\n 140: 140,\n /** 160 px */\n 160: 160,\n /** 176 px */\n 176: 176,\n /** 200 px */\n 200: 200,\n /** 240 px */\n 240: 240,\n /** 300 px */\n 300: 300,\n /** 360 px */\n 360: 360,\n /** 400 px */\n 400: 400,\n /** 584 px */\n 584: 584,\n /** 640 px */\n 640: 640,\n /** 760 px */\n 760: 760,\n /** 800 px */\n 800: 800,\n /** 1024 px */\n 1024: 1024,\n /** 1136 px */\n 1136: 1136,\n} as const;\n\nexport type Size = typeof size;\n"],"names":["size"],"mappings":"AAAA;AACA;AACA;AACO,IAAMA,IAAI,GAAG;AAClB;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,CAAC,EAAE,CAAC;AACJ;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,EAAE,EAAE,EAAE;AACN;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,GAAG,EAAE,GAAG;AACR;AACA,EAAA,IAAI,EAAE,IAAI;AACV;AACA,EAAA,IAAI,EAAE,IAAA;AACR;;;;"}
|
|
@@ -7070,15 +7070,21 @@ type ProgressBarCommonProps = {
|
|
|
7070
7070
|
* Sets the color of the progress bar which changes the feedback color.
|
|
7071
7071
|
*/
|
|
7072
7072
|
color?: FeedbackColors;
|
|
7073
|
+
/**
|
|
7074
|
+
* Sets the type of the progress bar.
|
|
7075
|
+
* @default 'progress'
|
|
7076
|
+
*/
|
|
7077
|
+
type?: 'meter' | 'progress';
|
|
7073
7078
|
/**
|
|
7074
7079
|
* Sets the label to be rendered for the progress bar. This value will also be used as default for `accessibilityLabel`.
|
|
7075
7080
|
*/
|
|
7076
7081
|
label?: string;
|
|
7077
7082
|
/**
|
|
7078
7083
|
* Sets the size of the progress bar.
|
|
7084
|
+
* Note: 'large' size isn't available when the variant is 'linear'.
|
|
7079
7085
|
* @default 'small'
|
|
7080
7086
|
*/
|
|
7081
|
-
size?: 'small' | 'medium';
|
|
7087
|
+
size?: 'small' | 'medium' | 'large';
|
|
7082
7088
|
/**
|
|
7083
7089
|
* Sets the progress value of the progress bar.
|
|
7084
7090
|
* @default 'small'
|
|
@@ -7095,13 +7101,13 @@ type ProgressBarCommonProps = {
|
|
|
7095
7101
|
*/
|
|
7096
7102
|
max?: number;
|
|
7097
7103
|
} & TestID & StyledPropsBlade;
|
|
7098
|
-
type ProgressBarVariant = 'progress' | 'meter';
|
|
7104
|
+
type ProgressBarVariant = 'progress' | 'meter' | 'linear' | 'circular';
|
|
7099
7105
|
type ProgressBarProgressProps = ProgressBarCommonProps & {
|
|
7100
7106
|
/**
|
|
7101
7107
|
* Sets the variant to be rendered for the progress bar.
|
|
7102
7108
|
* @default 'progress'
|
|
7103
7109
|
*/
|
|
7104
|
-
variant?: Extract<ProgressBarVariant, 'progress'>;
|
|
7110
|
+
variant?: Extract<ProgressBarVariant, 'progress' | 'linear' | 'circular'>;
|
|
7105
7111
|
/**
|
|
7106
7112
|
* Sets whether the progress bar is in an indeterminate state.
|
|
7107
7113
|
* @default false
|
|
@@ -7118,7 +7124,7 @@ type ProgressBarMeterProps = ProgressBarCommonProps & {
|
|
|
7118
7124
|
* Sets the variant to be rendered for thr progress bar.
|
|
7119
7125
|
* @default 'progress'
|
|
7120
7126
|
*/
|
|
7121
|
-
variant?: Extract<ProgressBarVariant, 'meter'>;
|
|
7127
|
+
variant?: Extract<ProgressBarVariant, 'meter' | 'linear' | 'circular'>;
|
|
7122
7128
|
/**
|
|
7123
7129
|
* Sets whether the progress bar is in an indeterminate state.
|
|
7124
7130
|
* @default false
|
|
@@ -7131,7 +7137,7 @@ type ProgressBarMeterProps = ProgressBarCommonProps & {
|
|
|
7131
7137
|
showPercentage?: undefined;
|
|
7132
7138
|
};
|
|
7133
7139
|
type ProgressBarProps = ProgressBarProgressProps | ProgressBarMeterProps;
|
|
7134
|
-
declare const ProgressBar: ({ accessibilityLabel, color, isIndeterminate, label, showPercentage, size, value, variant, min, max, testID, ...styledProps }: ProgressBarProps) => ReactElement;
|
|
7140
|
+
declare const ProgressBar: ({ accessibilityLabel, color, type, isIndeterminate, label, showPercentage, size, value, variant, min, max, testID, ...styledProps }: ProgressBarProps) => ReactElement;
|
|
7135
7141
|
|
|
7136
7142
|
type RadioProps = {
|
|
7137
7143
|
/**
|
|
@@ -6103,15 +6103,21 @@ type ProgressBarCommonProps = {
|
|
|
6103
6103
|
* Sets the color of the progress bar which changes the feedback color.
|
|
6104
6104
|
*/
|
|
6105
6105
|
color?: FeedbackColors;
|
|
6106
|
+
/**
|
|
6107
|
+
* Sets the type of the progress bar.
|
|
6108
|
+
* @default 'progress'
|
|
6109
|
+
*/
|
|
6110
|
+
type?: 'meter' | 'progress';
|
|
6106
6111
|
/**
|
|
6107
6112
|
* Sets the label to be rendered for the progress bar. This value will also be used as default for `accessibilityLabel`.
|
|
6108
6113
|
*/
|
|
6109
6114
|
label?: string;
|
|
6110
6115
|
/**
|
|
6111
6116
|
* Sets the size of the progress bar.
|
|
6117
|
+
* Note: 'large' size isn't available when the variant is 'linear'.
|
|
6112
6118
|
* @default 'small'
|
|
6113
6119
|
*/
|
|
6114
|
-
size?: 'small' | 'medium';
|
|
6120
|
+
size?: 'small' | 'medium' | 'large';
|
|
6115
6121
|
/**
|
|
6116
6122
|
* Sets the progress value of the progress bar.
|
|
6117
6123
|
* @default 'small'
|
|
@@ -6128,13 +6134,13 @@ type ProgressBarCommonProps = {
|
|
|
6128
6134
|
*/
|
|
6129
6135
|
max?: number;
|
|
6130
6136
|
} & TestID & StyledPropsBlade;
|
|
6131
|
-
type ProgressBarVariant = 'progress' | 'meter';
|
|
6137
|
+
type ProgressBarVariant = 'progress' | 'meter' | 'linear' | 'circular';
|
|
6132
6138
|
type ProgressBarProgressProps = ProgressBarCommonProps & {
|
|
6133
6139
|
/**
|
|
6134
6140
|
* Sets the variant to be rendered for the progress bar.
|
|
6135
6141
|
* @default 'progress'
|
|
6136
6142
|
*/
|
|
6137
|
-
variant?: Extract<ProgressBarVariant, 'progress'>;
|
|
6143
|
+
variant?: Extract<ProgressBarVariant, 'progress' | 'linear' | 'circular'>;
|
|
6138
6144
|
/**
|
|
6139
6145
|
* Sets whether the progress bar is in an indeterminate state.
|
|
6140
6146
|
* @default false
|
|
@@ -6151,7 +6157,7 @@ type ProgressBarMeterProps = ProgressBarCommonProps & {
|
|
|
6151
6157
|
* Sets the variant to be rendered for thr progress bar.
|
|
6152
6158
|
* @default 'progress'
|
|
6153
6159
|
*/
|
|
6154
|
-
variant?: Extract<ProgressBarVariant, 'meter'>;
|
|
6160
|
+
variant?: Extract<ProgressBarVariant, 'meter' | 'linear' | 'circular'>;
|
|
6155
6161
|
/**
|
|
6156
6162
|
* Sets whether the progress bar is in an indeterminate state.
|
|
6157
6163
|
* @default false
|
|
@@ -6164,7 +6170,7 @@ type ProgressBarMeterProps = ProgressBarCommonProps & {
|
|
|
6164
6170
|
showPercentage?: undefined;
|
|
6165
6171
|
};
|
|
6166
6172
|
type ProgressBarProps = ProgressBarProgressProps | ProgressBarMeterProps;
|
|
6167
|
-
declare const ProgressBar: ({ accessibilityLabel, color, isIndeterminate, label, showPercentage, size, value, variant, min, max, testID, ...styledProps }: ProgressBarProps) => ReactElement;
|
|
6173
|
+
declare const ProgressBar: ({ accessibilityLabel, color, type, isIndeterminate, label, showPercentage, size, value, variant, min, max, testID, ...styledProps }: ProgressBarProps) => ReactElement;
|
|
6168
6174
|
|
|
6169
6175
|
type RadioProps = {
|
|
6170
6176
|
/**
|
|
@@ -737,6 +737,8 @@ declare const size: {
|
|
|
737
737
|
readonly 5: 5;
|
|
738
738
|
/** 6 px */
|
|
739
739
|
readonly 6: 6;
|
|
740
|
+
/** 7 px */
|
|
741
|
+
readonly 7: 7;
|
|
740
742
|
/** 8 px */
|
|
741
743
|
readonly 8: 8;
|
|
742
744
|
/** 10 px */
|
|
@@ -767,6 +769,8 @@ declare const size: {
|
|
|
767
769
|
readonly 56: 56;
|
|
768
770
|
/** 64 px */
|
|
769
771
|
readonly 64: 64;
|
|
772
|
+
/** 72 px */
|
|
773
|
+
readonly 72: 72;
|
|
770
774
|
/** 100 px */
|
|
771
775
|
readonly 100: 100;
|
|
772
776
|
/** 120 px */
|
|
@@ -737,6 +737,8 @@ declare const size: {
|
|
|
737
737
|
readonly 5: 5;
|
|
738
738
|
/** 6 px */
|
|
739
739
|
readonly 6: 6;
|
|
740
|
+
/** 7 px */
|
|
741
|
+
readonly 7: 7;
|
|
740
742
|
/** 8 px */
|
|
741
743
|
readonly 8: 8;
|
|
742
744
|
/** 10 px */
|
|
@@ -767,6 +769,8 @@ declare const size: {
|
|
|
767
769
|
readonly 56: 56;
|
|
768
770
|
/** 64 px */
|
|
769
771
|
readonly 64: 64;
|
|
772
|
+
/** 72 px */
|
|
773
|
+
readonly 72: 72;
|
|
770
774
|
/** 100 px */
|
|
771
775
|
readonly 100: 100;
|
|
772
776
|
/** 120 px */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { applyTransform } from '@hypermod/utils';
|
|
2
|
+
import * as transformer from '..';
|
|
3
|
+
|
|
4
|
+
it('should migrate the ProgressBar component', async () => {
|
|
5
|
+
const result = await applyTransform(
|
|
6
|
+
transformer,
|
|
7
|
+
`
|
|
8
|
+
const App = () => (
|
|
9
|
+
<>
|
|
10
|
+
<ProgressBar value={20} label="Label" />
|
|
11
|
+
<ProgressBar variant="meter" value={20} label="Label" />
|
|
12
|
+
<ProgressBar variant="progress" value={20} label="Label" />
|
|
13
|
+
</>
|
|
14
|
+
);
|
|
15
|
+
`,
|
|
16
|
+
{ parser: 'tsx' },
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
expect(result).toMatchInlineSnapshot(`
|
|
20
|
+
"const App = () => (
|
|
21
|
+
<>
|
|
22
|
+
<ProgressBar value={20} label="Label" type="progress" />
|
|
23
|
+
<ProgressBar type="meter" value={20} label="Label" />
|
|
24
|
+
<ProgressBar type="progress" value={20} label="Label" />
|
|
25
|
+
</>
|
|
26
|
+
);"
|
|
27
|
+
`);
|
|
28
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Transform } from 'jscodeshift';
|
|
2
|
+
|
|
3
|
+
import { red, isExpression } from '../../brand-refresh/transformers/utils';
|
|
4
|
+
|
|
5
|
+
const transformer: Transform = (file, api, options) => {
|
|
6
|
+
// Don't transform if the file doesn't import `@razorapy/blade/components` because it's not using Blade components
|
|
7
|
+
// Allow the migration test file to be transformed
|
|
8
|
+
if (!file.source.includes('@razorpay/blade/components') && file.path !== undefined) {
|
|
9
|
+
return file.source;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const j = api.jscodeshift;
|
|
13
|
+
const root = j.withParser('tsx')(file.source);
|
|
14
|
+
|
|
15
|
+
// Add type prop if variant prop is not defined
|
|
16
|
+
try {
|
|
17
|
+
root
|
|
18
|
+
.find(j.JSXElement, {
|
|
19
|
+
openingElement: {
|
|
20
|
+
name: {
|
|
21
|
+
name: 'ProgressBar',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
.replaceWith(({ node }) => {
|
|
26
|
+
const variantAttribute = node.openingElement.attributes.find(
|
|
27
|
+
(attribute) => attribute.name?.name === 'variant',
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (!variantAttribute) {
|
|
31
|
+
node.openingElement.attributes?.push(
|
|
32
|
+
j.jsxAttribute(j.jsxIdentifier('type'), j.literal('progress')),
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return node;
|
|
37
|
+
});
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error(
|
|
40
|
+
red(
|
|
41
|
+
`⛔️ ${file.path}: Oops! Ran into an issue while adding the "type" prop to the ProgressBar component.`,
|
|
42
|
+
),
|
|
43
|
+
`\n${red(error.stack)}\n`,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Update the variant prop to type prop if defined
|
|
48
|
+
try {
|
|
49
|
+
root
|
|
50
|
+
.find(j.JSXElement, {
|
|
51
|
+
openingElement: {
|
|
52
|
+
name: {
|
|
53
|
+
name: 'ProgressBar',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
.find(j.JSXAttribute, {
|
|
58
|
+
name: {
|
|
59
|
+
name: 'variant',
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
.replaceWith(({ node }) => {
|
|
63
|
+
if (isExpression(node)) {
|
|
64
|
+
console.warn(
|
|
65
|
+
red('\n⛔️ Expression found in the "variant" attribute, please update manually:'),
|
|
66
|
+
red(`${file.path}:${node.loc?.start.line}:${node.loc.start.column}\n`),
|
|
67
|
+
);
|
|
68
|
+
return node;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (node.value?.value === 'progress' || node.value?.value === 'meter') {
|
|
72
|
+
node.name.name = 'type';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return node;
|
|
76
|
+
});
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error(
|
|
79
|
+
red(
|
|
80
|
+
`⛔️ ${file.path}: Oops! Ran into an issue while updating the "variant" prop of the ProgressBar component.`,
|
|
81
|
+
),
|
|
82
|
+
`\n${red(error.stack)}\n`,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return root.toSource(options.printOptions);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default transformer;
|