react-native-ui-lib 7.46.2 → 7.46.3-snapshot.7330
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/package.json +1 -1
- package/src/commons/modifiers.d.ts +1 -0
- package/src/commons/modifiers.js +5 -2
- package/src/components/button/button.api.json +5 -0
- package/src/components/button/index.d.ts +8 -0
- package/src/components/button/index.js +18 -1
- package/src/components/button/types.d.ts +4 -0
- package/src/incubator/gradient/BorderGradient.d.ts +4 -0
- package/src/incubator/gradient/BorderGradient.js +45 -0
- package/src/incubator/gradient/CircleGradient.d.ts +4 -0
- package/src/incubator/gradient/CircleGradient.js +35 -0
- package/src/incubator/gradient/RectangleGradient.d.ts +4 -0
- package/src/incubator/gradient/RectangleGradient.js +32 -0
- package/src/incubator/gradient/index.d.ts +5 -0
- package/src/incubator/gradient/index.js +31 -0
- package/src/incubator/gradient/types.d.ts +26 -0
- package/src/incubator/gradient/types.js +1 -0
- package/src/incubator/gradient/useAngleTransform.d.ts +27 -0
- package/src/incubator/gradient/useAngleTransform.js +72 -0
- package/src/incubator/index.d.ts +1 -0
- package/src/incubator/index.js +2 -1
- package/src/optionalDependencies/LinearGradientPackage.d.ts +1 -1
package/package.json
CHANGED
|
@@ -111,6 +111,7 @@ export declare function extractModifierProps(props: Dictionary<any>): _.Dictiona
|
|
|
111
111
|
*/
|
|
112
112
|
export declare function extractOwnProps(props: Dictionary<any>, ignoreProps: string[]): _.Omit<_.Dictionary<any>, string>;
|
|
113
113
|
export declare function extractComponentProps(component: any, props: Dictionary<any>, ignoreProps?: string[]): _.Omit<_.Dictionary<any>, string>;
|
|
114
|
+
export declare function getComponentName(componentDisplayName: string): any;
|
|
114
115
|
export declare function getThemeProps<T extends object>(props?: T, context?: any, componentDisplayName?: string): T;
|
|
115
116
|
export declare function generateModifiersStyle(options: ModifiersOptions | undefined, props: Dictionary<any>): ExtractedStyle;
|
|
116
117
|
export declare function getAlteredModifiersOptions(currentProps: any, nextProps: any): AlteredOptions;
|
package/src/commons/modifiers.js
CHANGED
|
@@ -248,12 +248,15 @@ export function extractComponentProps(component, props, ignoreProps = []) {
|
|
|
248
248
|
const componentProps = _flow(props => _pickBy(props, (_value, key) => _includes(Object.keys(componentPropTypes), key)), props => _omit(props, ignoreProps))(props);
|
|
249
249
|
return componentProps;
|
|
250
250
|
}
|
|
251
|
+
export function getComponentName(componentDisplayName) {
|
|
252
|
+
//@ts-ignore
|
|
253
|
+
return componentDisplayName || this.displayName || this.constructor.displayName || this.constructor.name;
|
|
254
|
+
}
|
|
251
255
|
|
|
252
256
|
//@ts-ignore
|
|
253
257
|
export function getThemeProps(props = this.props, context = this.context, componentDisplayName = '') {
|
|
254
|
-
const componentName =
|
|
255
258
|
//@ts-ignore
|
|
256
|
-
|
|
259
|
+
const componentName = getComponentName.call(this, componentDisplayName);
|
|
257
260
|
let themeProps;
|
|
258
261
|
if (_isFunction(ThemeManager.components[componentName])) {
|
|
259
262
|
themeProps = ThemeManager.components[componentName](props, context);
|
|
@@ -161,6 +161,11 @@
|
|
|
161
161
|
"name": "animateTo",
|
|
162
162
|
"type": "ButtonAnimationDirection",
|
|
163
163
|
"description": "the direction of the animation ('left' and 'right' will effect the button's own alignment)"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"name": "customBackground",
|
|
167
|
+
"type": "React.ReactElement",
|
|
168
|
+
"description": "Custom element to render as button background (takes precedence over backgroundColor)"
|
|
164
169
|
}
|
|
165
170
|
],
|
|
166
171
|
"snippet": [
|
|
@@ -356,6 +356,9 @@ declare class Button extends PureComponent<Props, ButtonState> {
|
|
|
356
356
|
verticalAlign?: "auto" | "top" | "bottom" | "middle" | undefined;
|
|
357
357
|
includeFontPadding?: boolean | undefined;
|
|
358
358
|
};
|
|
359
|
+
backgroundElement: {
|
|
360
|
+
overflow: "hidden";
|
|
361
|
+
};
|
|
359
362
|
};
|
|
360
363
|
componentDidUpdate(prevProps: Props): void;
|
|
361
364
|
onLayout: (event: LayoutChangeEvent) => void;
|
|
@@ -407,6 +410,7 @@ declare class Button extends PureComponent<Props, ButtonState> {
|
|
|
407
410
|
left: number;
|
|
408
411
|
right: number;
|
|
409
412
|
};
|
|
413
|
+
renderCustomBackground(): React.JSX.Element | undefined;
|
|
410
414
|
render(): React.JSX.Element;
|
|
411
415
|
}
|
|
412
416
|
export { Button };
|
|
@@ -440,6 +444,7 @@ declare const _default: React.ForwardRefExoticComponent<((import("../touchableOp
|
|
|
440
444
|
getActiveBackgroundColor?: ((backgroundColor: string, props: any) => string) | undefined;
|
|
441
445
|
animateLayout?: boolean | undefined;
|
|
442
446
|
animateTo?: import("./types").ButtonAnimationDirectionProp | undefined;
|
|
447
|
+
customBackground?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
443
448
|
}) | Omit<import("../touchableOpacity").TouchableOpacityProps & import("../../commons/modifiers").CustomModifier & Partial<Record<"bg-transparent" | "bg-black" | "bg-white" | "bg-dark" | "bg-$backgroundDefault" | "bg-$backgroundElevated" | "bg-$backgroundElevatedLight" | "bg-$backgroundNeutralHeavy" | "bg-$backgroundNeutralIdle" | "bg-$backgroundNeutralMedium" | "bg-$backgroundNeutral" | "bg-$backgroundNeutralLight" | "bg-$backgroundPrimaryHeavy" | "bg-$backgroundPrimaryMedium" | "bg-$backgroundPrimaryLight" | "bg-$backgroundGeneralHeavy" | "bg-$backgroundGeneralMedium" | "bg-$backgroundGeneralLight" | "bg-$backgroundSuccessHeavy" | "bg-$backgroundSuccessLight" | "bg-$backgroundWarningHeavy" | "bg-$backgroundWarningLight" | "bg-$backgroundMajorLight" | "bg-$backgroundMajorHeavy" | "bg-$backgroundDangerHeavy" | "bg-$backgroundDangerLight" | "bg-$backgroundDisabled" | "bg-$backgroundDark" | "bg-$backgroundDarkElevated" | "bg-$backgroundDarkActive" | "bg-$backgroundInverted" | "bg-$textDisabled" | "bg-$textDefault" | "bg-$textNeutralHeavy" | "bg-$textNeutral" | "bg-$textNeutralLight" | "bg-$textDefaultLight" | "bg-$textPrimary" | "bg-$textGeneral" | "bg-$textSuccess" | "bg-$textSuccessLight" | "bg-$textMajor" | "bg-$textDanger" | "bg-$textDangerLight" | "bg-$iconDefault" | "bg-$iconNeutral" | "bg-$iconDefaultLight" | "bg-$iconPrimary" | "bg-$iconPrimaryLight" | "bg-$iconGeneral" | "bg-$iconGeneralLight" | "bg-$iconSuccess" | "bg-$iconSuccessLight" | "bg-$iconMajor" | "bg-$iconDanger" | "bg-$iconDangerLight" | "bg-$iconDisabled" | "bg-$outlineDefault" | "bg-$outlineDisabled" | "bg-$outlineDisabledHeavy" | "bg-$outlineNeutral" | "bg-$outlineNeutralHeavy" | "bg-$outlinePrimary" | "bg-$outlinePrimaryMedium" | "bg-$outlineGeneral" | "bg-$outlineWarning" | "bg-$outlineDanger" | "bg-$outlineInverted" | "bg-$black" | "bg-$white" | "bg-grey1" | "bg-grey5" | "bg-grey10" | "bg-grey20" | "bg-grey30" | "bg-grey40" | "bg-grey50" | "bg-grey60" | "bg-grey70" | "bg-grey80" | "bg-blue1" | "bg-blue5" | "bg-blue10" | "bg-blue20" | "bg-blue30" | "bg-blue40" | "bg-blue50" | "bg-blue60" | "bg-blue70" | "bg-blue80" | "bg-cyan10" | "bg-cyan20" | "bg-cyan30" | "bg-cyan40" | "bg-cyan50" | "bg-cyan60" | "bg-cyan70" | "bg-cyan80" | "bg-green1" | "bg-green5" | "bg-green10" | "bg-green20" | "bg-green30" | "bg-green40" | "bg-green50" | "bg-green60" | "bg-green70" | "bg-green80" | "bg-yellow1" | "bg-yellow5" | "bg-yellow10" | "bg-yellow20" | "bg-yellow30" | "bg-yellow40" | "bg-yellow50" | "bg-yellow60" | "bg-yellow70" | "bg-yellow80" | "bg-orange1" | "bg-orange5" | "bg-orange10" | "bg-orange20" | "bg-orange30" | "bg-orange40" | "bg-orange50" | "bg-orange60" | "bg-orange70" | "bg-orange80" | "bg-red1" | "bg-red5" | "bg-red10" | "bg-red20" | "bg-red30" | "bg-red40" | "bg-red50" | "bg-red60" | "bg-red70" | "bg-red80" | "bg-purple1" | "bg-purple5" | "bg-purple10" | "bg-purple20" | "bg-purple30" | "bg-purple40" | "bg-purple50" | "bg-purple60" | "bg-purple70" | "bg-purple80" | "bg-violet1" | "bg-violet5" | "bg-violet10" | "bg-violet20" | "bg-violet30" | "bg-violet40" | "bg-violet50" | "bg-violet60" | "bg-violet70" | "bg-violet80", boolean>> & Partial<Record<"margin" | "marginL" | "marginT" | "marginR" | "marginB" | "marginH" | "marginV", boolean>> & {
|
|
444
449
|
label?: string | undefined;
|
|
445
450
|
color?: string | undefined;
|
|
@@ -470,6 +475,7 @@ declare const _default: React.ForwardRefExoticComponent<((import("../touchableOp
|
|
|
470
475
|
getActiveBackgroundColor?: ((backgroundColor: string, props: any) => string) | undefined;
|
|
471
476
|
animateLayout?: boolean | undefined;
|
|
472
477
|
animateTo?: import("./types").ButtonAnimationDirectionProp | undefined;
|
|
478
|
+
customBackground?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
473
479
|
}, "ref"> | Omit<import("../touchableOpacity").TouchableOpacityProps & import("../../commons/modifiers").CustomModifier & Partial<Record<"transparent" | "black" | "white" | "dark" | "$backgroundDefault" | "$backgroundElevated" | "$backgroundElevatedLight" | "$backgroundNeutralHeavy" | "$backgroundNeutralIdle" | "$backgroundNeutralMedium" | "$backgroundNeutral" | "$backgroundNeutralLight" | "$backgroundPrimaryHeavy" | "$backgroundPrimaryMedium" | "$backgroundPrimaryLight" | "$backgroundGeneralHeavy" | "$backgroundGeneralMedium" | "$backgroundGeneralLight" | "$backgroundSuccessHeavy" | "$backgroundSuccessLight" | "$backgroundWarningHeavy" | "$backgroundWarningLight" | "$backgroundMajorLight" | "$backgroundMajorHeavy" | "$backgroundDangerHeavy" | "$backgroundDangerLight" | "$backgroundDisabled" | "$backgroundDark" | "$backgroundDarkElevated" | "$backgroundDarkActive" | "$backgroundInverted" | "$textDisabled" | "$textDefault" | "$textNeutralHeavy" | "$textNeutral" | "$textNeutralLight" | "$textDefaultLight" | "$textPrimary" | "$textGeneral" | "$textSuccess" | "$textSuccessLight" | "$textMajor" | "$textDanger" | "$textDangerLight" | "$iconDefault" | "$iconNeutral" | "$iconDefaultLight" | "$iconPrimary" | "$iconPrimaryLight" | "$iconGeneral" | "$iconGeneralLight" | "$iconSuccess" | "$iconSuccessLight" | "$iconMajor" | "$iconDanger" | "$iconDangerLight" | "$iconDisabled" | "$outlineDefault" | "$outlineDisabled" | "$outlineDisabledHeavy" | "$outlineNeutral" | "$outlineNeutralHeavy" | "$outlinePrimary" | "$outlinePrimaryMedium" | "$outlineGeneral" | "$outlineWarning" | "$outlineDanger" | "$outlineInverted" | "$black" | "$white" | "grey1" | "grey5" | "grey10" | "grey20" | "grey30" | "grey40" | "grey50" | "grey60" | "grey70" | "grey80" | "blue1" | "blue5" | "blue10" | "blue20" | "blue30" | "blue40" | "blue50" | "blue60" | "blue70" | "blue80" | "cyan10" | "cyan20" | "cyan30" | "cyan40" | "cyan50" | "cyan60" | "cyan70" | "cyan80" | "green1" | "green5" | "green10" | "green20" | "green30" | "green40" | "green50" | "green60" | "green70" | "green80" | "yellow1" | "yellow5" | "yellow10" | "yellow20" | "yellow30" | "yellow40" | "yellow50" | "yellow60" | "yellow70" | "yellow80" | "orange1" | "orange5" | "orange10" | "orange20" | "orange30" | "orange40" | "orange50" | "orange60" | "orange70" | "orange80" | "red1" | "red5" | "red10" | "red20" | "red30" | "red40" | "red50" | "red60" | "red70" | "red80" | "purple1" | "purple5" | "purple10" | "purple20" | "purple30" | "purple40" | "purple50" | "purple60" | "purple70" | "purple80" | "violet1" | "violet5" | "violet10" | "violet20" | "violet30" | "violet40" | "violet50" | "violet60" | "violet70" | "violet80", boolean>> & Partial<Record<"bg-transparent" | "bg-black" | "bg-white" | "bg-dark" | "bg-$backgroundDefault" | "bg-$backgroundElevated" | "bg-$backgroundElevatedLight" | "bg-$backgroundNeutralHeavy" | "bg-$backgroundNeutralIdle" | "bg-$backgroundNeutralMedium" | "bg-$backgroundNeutral" | "bg-$backgroundNeutralLight" | "bg-$backgroundPrimaryHeavy" | "bg-$backgroundPrimaryMedium" | "bg-$backgroundPrimaryLight" | "bg-$backgroundGeneralHeavy" | "bg-$backgroundGeneralMedium" | "bg-$backgroundGeneralLight" | "bg-$backgroundSuccessHeavy" | "bg-$backgroundSuccessLight" | "bg-$backgroundWarningHeavy" | "bg-$backgroundWarningLight" | "bg-$backgroundMajorLight" | "bg-$backgroundMajorHeavy" | "bg-$backgroundDangerHeavy" | "bg-$backgroundDangerLight" | "bg-$backgroundDisabled" | "bg-$backgroundDark" | "bg-$backgroundDarkElevated" | "bg-$backgroundDarkActive" | "bg-$backgroundInverted" | "bg-$textDisabled" | "bg-$textDefault" | "bg-$textNeutralHeavy" | "bg-$textNeutral" | "bg-$textNeutralLight" | "bg-$textDefaultLight" | "bg-$textPrimary" | "bg-$textGeneral" | "bg-$textSuccess" | "bg-$textSuccessLight" | "bg-$textMajor" | "bg-$textDanger" | "bg-$textDangerLight" | "bg-$iconDefault" | "bg-$iconNeutral" | "bg-$iconDefaultLight" | "bg-$iconPrimary" | "bg-$iconPrimaryLight" | "bg-$iconGeneral" | "bg-$iconGeneralLight" | "bg-$iconSuccess" | "bg-$iconSuccessLight" | "bg-$iconMajor" | "bg-$iconDanger" | "bg-$iconDangerLight" | "bg-$iconDisabled" | "bg-$outlineDefault" | "bg-$outlineDisabled" | "bg-$outlineDisabledHeavy" | "bg-$outlineNeutral" | "bg-$outlineNeutralHeavy" | "bg-$outlinePrimary" | "bg-$outlinePrimaryMedium" | "bg-$outlineGeneral" | "bg-$outlineWarning" | "bg-$outlineDanger" | "bg-$outlineInverted" | "bg-$black" | "bg-$white" | "bg-grey1" | "bg-grey5" | "bg-grey10" | "bg-grey20" | "bg-grey30" | "bg-grey40" | "bg-grey50" | "bg-grey60" | "bg-grey70" | "bg-grey80" | "bg-blue1" | "bg-blue5" | "bg-blue10" | "bg-blue20" | "bg-blue30" | "bg-blue40" | "bg-blue50" | "bg-blue60" | "bg-blue70" | "bg-blue80" | "bg-cyan10" | "bg-cyan20" | "bg-cyan30" | "bg-cyan40" | "bg-cyan50" | "bg-cyan60" | "bg-cyan70" | "bg-cyan80" | "bg-green1" | "bg-green5" | "bg-green10" | "bg-green20" | "bg-green30" | "bg-green40" | "bg-green50" | "bg-green60" | "bg-green70" | "bg-green80" | "bg-yellow1" | "bg-yellow5" | "bg-yellow10" | "bg-yellow20" | "bg-yellow30" | "bg-yellow40" | "bg-yellow50" | "bg-yellow60" | "bg-yellow70" | "bg-yellow80" | "bg-orange1" | "bg-orange5" | "bg-orange10" | "bg-orange20" | "bg-orange30" | "bg-orange40" | "bg-orange50" | "bg-orange60" | "bg-orange70" | "bg-orange80" | "bg-red1" | "bg-red5" | "bg-red10" | "bg-red20" | "bg-red30" | "bg-red40" | "bg-red50" | "bg-red60" | "bg-red70" | "bg-red80" | "bg-purple1" | "bg-purple5" | "bg-purple10" | "bg-purple20" | "bg-purple30" | "bg-purple40" | "bg-purple50" | "bg-purple60" | "bg-purple70" | "bg-purple80" | "bg-violet1" | "bg-violet5" | "bg-violet10" | "bg-violet20" | "bg-violet30" | "bg-violet40" | "bg-violet50" | "bg-violet60" | "bg-violet70" | "bg-violet80", boolean>> & Partial<Record<"margin" | "marginL" | "marginT" | "marginR" | "marginB" | "marginH" | "marginV", boolean>> & {
|
|
474
480
|
label?: string | undefined;
|
|
475
481
|
color?: string | undefined;
|
|
@@ -500,6 +506,7 @@ declare const _default: React.ForwardRefExoticComponent<((import("../touchableOp
|
|
|
500
506
|
getActiveBackgroundColor?: ((backgroundColor: string, props: any) => string) | undefined;
|
|
501
507
|
animateLayout?: boolean | undefined;
|
|
502
508
|
animateTo?: import("./types").ButtonAnimationDirectionProp | undefined;
|
|
509
|
+
customBackground?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
503
510
|
}, "ref"> | Omit<import("../touchableOpacity").TouchableOpacityProps & Partial<Record<"text10" | "text20" | "text30" | "text40" | "text50" | "text60" | "text65" | "text70" | "text80" | "text90" | "text100" | "text10T" | "text10L" | "text10R" | "text10M" | "text10BO" | "text10H" | "text10BL" | "text20T" | "text20L" | "text20R" | "text20M" | "text20BO" | "text20H" | "text20BL" | "text30T" | "text30L" | "text30R" | "text30M" | "text30BO" | "text30H" | "text30BL" | "text40T" | "text40L" | "text40R" | "text40M" | "text40BO" | "text40H" | "text40BL" | "text50T" | "text50L" | "text50R" | "text50M" | "text50BO" | "text50H" | "text50BL" | "text60T" | "text60L" | "text60R" | "text60M" | "text60BO" | "text60H" | "text60BL" | "text65T" | "text65L" | "text65R" | "text65M" | "text65BO" | "text65H" | "text65BL" | "text70T" | "text70L" | "text70R" | "text70M" | "text70BO" | "text70H" | "text70BL" | "text80T" | "text80L" | "text80R" | "text80M" | "text80BO" | "text80H" | "text80BL" | "text90T" | "text90L" | "text90R" | "text90M" | "text90BO" | "text90H" | "text90BL" | "text100T" | "text100L" | "text100R" | "text100M" | "text100BO" | "text100H" | "text100BL", boolean>> & import("../../commons/modifiers").CustomModifier & Partial<Record<"bg-transparent" | "bg-black" | "bg-white" | "bg-dark" | "bg-$backgroundDefault" | "bg-$backgroundElevated" | "bg-$backgroundElevatedLight" | "bg-$backgroundNeutralHeavy" | "bg-$backgroundNeutralIdle" | "bg-$backgroundNeutralMedium" | "bg-$backgroundNeutral" | "bg-$backgroundNeutralLight" | "bg-$backgroundPrimaryHeavy" | "bg-$backgroundPrimaryMedium" | "bg-$backgroundPrimaryLight" | "bg-$backgroundGeneralHeavy" | "bg-$backgroundGeneralMedium" | "bg-$backgroundGeneralLight" | "bg-$backgroundSuccessHeavy" | "bg-$backgroundSuccessLight" | "bg-$backgroundWarningHeavy" | "bg-$backgroundWarningLight" | "bg-$backgroundMajorLight" | "bg-$backgroundMajorHeavy" | "bg-$backgroundDangerHeavy" | "bg-$backgroundDangerLight" | "bg-$backgroundDisabled" | "bg-$backgroundDark" | "bg-$backgroundDarkElevated" | "bg-$backgroundDarkActive" | "bg-$backgroundInverted" | "bg-$textDisabled" | "bg-$textDefault" | "bg-$textNeutralHeavy" | "bg-$textNeutral" | "bg-$textNeutralLight" | "bg-$textDefaultLight" | "bg-$textPrimary" | "bg-$textGeneral" | "bg-$textSuccess" | "bg-$textSuccessLight" | "bg-$textMajor" | "bg-$textDanger" | "bg-$textDangerLight" | "bg-$iconDefault" | "bg-$iconNeutral" | "bg-$iconDefaultLight" | "bg-$iconPrimary" | "bg-$iconPrimaryLight" | "bg-$iconGeneral" | "bg-$iconGeneralLight" | "bg-$iconSuccess" | "bg-$iconSuccessLight" | "bg-$iconMajor" | "bg-$iconDanger" | "bg-$iconDangerLight" | "bg-$iconDisabled" | "bg-$outlineDefault" | "bg-$outlineDisabled" | "bg-$outlineDisabledHeavy" | "bg-$outlineNeutral" | "bg-$outlineNeutralHeavy" | "bg-$outlinePrimary" | "bg-$outlinePrimaryMedium" | "bg-$outlineGeneral" | "bg-$outlineWarning" | "bg-$outlineDanger" | "bg-$outlineInverted" | "bg-$black" | "bg-$white" | "bg-grey1" | "bg-grey5" | "bg-grey10" | "bg-grey20" | "bg-grey30" | "bg-grey40" | "bg-grey50" | "bg-grey60" | "bg-grey70" | "bg-grey80" | "bg-blue1" | "bg-blue5" | "bg-blue10" | "bg-blue20" | "bg-blue30" | "bg-blue40" | "bg-blue50" | "bg-blue60" | "bg-blue70" | "bg-blue80" | "bg-cyan10" | "bg-cyan20" | "bg-cyan30" | "bg-cyan40" | "bg-cyan50" | "bg-cyan60" | "bg-cyan70" | "bg-cyan80" | "bg-green1" | "bg-green5" | "bg-green10" | "bg-green20" | "bg-green30" | "bg-green40" | "bg-green50" | "bg-green60" | "bg-green70" | "bg-green80" | "bg-yellow1" | "bg-yellow5" | "bg-yellow10" | "bg-yellow20" | "bg-yellow30" | "bg-yellow40" | "bg-yellow50" | "bg-yellow60" | "bg-yellow70" | "bg-yellow80" | "bg-orange1" | "bg-orange5" | "bg-orange10" | "bg-orange20" | "bg-orange30" | "bg-orange40" | "bg-orange50" | "bg-orange60" | "bg-orange70" | "bg-orange80" | "bg-red1" | "bg-red5" | "bg-red10" | "bg-red20" | "bg-red30" | "bg-red40" | "bg-red50" | "bg-red60" | "bg-red70" | "bg-red80" | "bg-purple1" | "bg-purple5" | "bg-purple10" | "bg-purple20" | "bg-purple30" | "bg-purple40" | "bg-purple50" | "bg-purple60" | "bg-purple70" | "bg-purple80" | "bg-violet1" | "bg-violet5" | "bg-violet10" | "bg-violet20" | "bg-violet30" | "bg-violet40" | "bg-violet50" | "bg-violet60" | "bg-violet70" | "bg-violet80", boolean>> & Partial<Record<"margin" | "marginL" | "marginT" | "marginR" | "marginB" | "marginH" | "marginV", boolean>> & {
|
|
504
511
|
label?: string | undefined;
|
|
505
512
|
color?: string | undefined;
|
|
@@ -530,5 +537,6 @@ declare const _default: React.ForwardRefExoticComponent<((import("../touchableOp
|
|
|
530
537
|
getActiveBackgroundColor?: ((backgroundColor: string, props: any) => string) | undefined;
|
|
531
538
|
animateLayout?: boolean | undefined;
|
|
532
539
|
animateTo?: import("./types").ButtonAnimationDirectionProp | undefined;
|
|
540
|
+
customBackground?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
533
541
|
}, "ref">) & React.RefAttributes<{}>> & ComponentStatics<typeof Button>;
|
|
534
542
|
export default _default;
|
|
@@ -4,6 +4,7 @@ import { Platform, StyleSheet, LayoutAnimation } from 'react-native';
|
|
|
4
4
|
import { asBaseComponent, forwardRef, Constants } from "../../commons/new";
|
|
5
5
|
import { Colors, Typography, BorderRadiuses } from "../../style";
|
|
6
6
|
import TouchableOpacity from "../touchableOpacity";
|
|
7
|
+
import View from "../view";
|
|
7
8
|
import Text from "../text";
|
|
8
9
|
import Icon from "../icon";
|
|
9
10
|
import { ButtonSize, ButtonAnimationDirection, ButtonProps, DEFAULT_PROPS } from "./types";
|
|
@@ -358,6 +359,17 @@ class Button extends PureComponent {
|
|
|
358
359
|
right: horizontalHitslop
|
|
359
360
|
};
|
|
360
361
|
}
|
|
362
|
+
renderCustomBackground() {
|
|
363
|
+
const {
|
|
364
|
+
customBackground
|
|
365
|
+
} = this.props;
|
|
366
|
+
if (customBackground) {
|
|
367
|
+
const borderRadiusStyle = this.getBorderRadiusStyle();
|
|
368
|
+
return <View absF style={[this.styles.backgroundElement, borderRadiusStyle]}>
|
|
369
|
+
{customBackground}
|
|
370
|
+
</View>;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
361
373
|
render() {
|
|
362
374
|
const {
|
|
363
375
|
onPress,
|
|
@@ -368,6 +380,7 @@ class Button extends PureComponent {
|
|
|
368
380
|
modifiers,
|
|
369
381
|
forwardedRef,
|
|
370
382
|
hitSlop: hitSlopProp,
|
|
383
|
+
customBackground,
|
|
371
384
|
...others
|
|
372
385
|
} = this.props;
|
|
373
386
|
const shadowStyle = this.getShadowStyle();
|
|
@@ -375,13 +388,14 @@ class Button extends PureComponent {
|
|
|
375
388
|
margins,
|
|
376
389
|
paddings
|
|
377
390
|
} = modifiers;
|
|
378
|
-
const backgroundColor = this.getBackgroundColor();
|
|
391
|
+
const backgroundColor = customBackground ? undefined : this.getBackgroundColor();
|
|
379
392
|
const outlineStyle = this.getOutlineStyle();
|
|
380
393
|
const containerSizeStyle = this.getContainerSizeStyle();
|
|
381
394
|
const borderRadiusStyle = this.getBorderRadiusStyle();
|
|
382
395
|
return <TouchableOpacity row centerV style={[this.styles.container, animateLayout && this.getAnimationDirectionStyle(), containerSizeStyle, this.isLink && this.styles.innerContainerLink, shadowStyle, margins, paddings, {
|
|
383
396
|
backgroundColor
|
|
384
397
|
}, borderRadiusStyle, outlineStyle, style]} activeOpacity={0.6} activeBackgroundColor={this.getActiveBackgroundColor()} onLayout={this.onLayout} onPress={onPress} disabled={disabled} testID={testID} hitSlop={hitSlopProp ?? this.getAccessibleHitSlop()} {...others} ref={forwardedRef}>
|
|
398
|
+
{this.renderCustomBackground()}
|
|
385
399
|
{this.props.children}
|
|
386
400
|
{this.props.iconOnRight ? this.renderLabel() : this.renderIcon()}
|
|
387
401
|
{this.props.iconOnRight ? this.renderIcon() : this.renderLabel()}
|
|
@@ -415,6 +429,9 @@ function createStyles() {
|
|
|
415
429
|
backgroundColor: 'transparent',
|
|
416
430
|
flexDirection: 'row',
|
|
417
431
|
...Typography.text70
|
|
432
|
+
},
|
|
433
|
+
backgroundElement: {
|
|
434
|
+
overflow: 'hidden'
|
|
418
435
|
}
|
|
419
436
|
});
|
|
420
437
|
}
|
|
@@ -138,6 +138,10 @@ export type ButtonProps = TouchableOpacityProps & TypographyModifiers & ColorsMo
|
|
|
138
138
|
* the direction of the animation ('left' and 'right' will effect the button's own alignment)
|
|
139
139
|
*/
|
|
140
140
|
animateTo?: ButtonAnimationDirectionProp;
|
|
141
|
+
/**
|
|
142
|
+
* Custom element to render as button background (takes precedence over backgroundColor)
|
|
143
|
+
*/
|
|
144
|
+
customBackground?: React.ReactElement;
|
|
141
145
|
};
|
|
142
146
|
export type ButtonState = {
|
|
143
147
|
size?: number;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LinearGradientPackage } from "../../optionalDependencies";
|
|
3
|
+
const LinearGradient = LinearGradientPackage?.default;
|
|
4
|
+
import View from "../../components/view";
|
|
5
|
+
import Spacings from "../../style/spacings";
|
|
6
|
+
import Colors from "../../style/colors";
|
|
7
|
+
import useAngleTransform from "./useAngleTransform";
|
|
8
|
+
const BorderGradient = props => {
|
|
9
|
+
const {
|
|
10
|
+
colors,
|
|
11
|
+
borderWidth = Spacings.s1,
|
|
12
|
+
borderRadius,
|
|
13
|
+
children,
|
|
14
|
+
width,
|
|
15
|
+
height,
|
|
16
|
+
angle,
|
|
17
|
+
...others
|
|
18
|
+
} = props;
|
|
19
|
+
const innerWidth = width ? width - borderWidth * 2 : undefined;
|
|
20
|
+
const innerHeight = height ? height - borderWidth * 2 : undefined;
|
|
21
|
+
const {
|
|
22
|
+
start,
|
|
23
|
+
end
|
|
24
|
+
} = useAngleTransform({
|
|
25
|
+
angle
|
|
26
|
+
});
|
|
27
|
+
if (!LinearGradient) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return <View width={width} height={height}>
|
|
31
|
+
<LinearGradient colors={colors} start={start} end={end} style={{
|
|
32
|
+
borderRadius
|
|
33
|
+
}}>
|
|
34
|
+
<View bg-white width={innerWidth} height={innerHeight} style={{
|
|
35
|
+
margin: borderWidth,
|
|
36
|
+
borderRadius,
|
|
37
|
+
borderWidth: 0,
|
|
38
|
+
borderColor: Colors.transparent
|
|
39
|
+
}} {...others}>
|
|
40
|
+
{children}
|
|
41
|
+
</View>
|
|
42
|
+
</LinearGradient>
|
|
43
|
+
</View>;
|
|
44
|
+
};
|
|
45
|
+
export default BorderGradient;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LinearGradientPackage } from "../../optionalDependencies";
|
|
3
|
+
const LinearGradient = LinearGradientPackage?.default;
|
|
4
|
+
import View from "../../components/view";
|
|
5
|
+
import useAngleTransform from "./useAngleTransform";
|
|
6
|
+
const CircleGradient = props => {
|
|
7
|
+
const {
|
|
8
|
+
colors,
|
|
9
|
+
radius,
|
|
10
|
+
angle,
|
|
11
|
+
children,
|
|
12
|
+
...others
|
|
13
|
+
} = props;
|
|
14
|
+
const internalDiameter = radius ? radius * 2 : undefined;
|
|
15
|
+
const {
|
|
16
|
+
start,
|
|
17
|
+
end
|
|
18
|
+
} = useAngleTransform({
|
|
19
|
+
angle
|
|
20
|
+
});
|
|
21
|
+
if (!LinearGradient) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return <View width={internalDiameter} height={internalDiameter} style={{
|
|
25
|
+
borderRadius: 999,
|
|
26
|
+
overflow: 'hidden'
|
|
27
|
+
}}>
|
|
28
|
+
<LinearGradient colors={colors} start={start} end={end}>
|
|
29
|
+
<View width={internalDiameter} height={internalDiameter} {...others}>
|
|
30
|
+
{children}
|
|
31
|
+
</View>
|
|
32
|
+
</LinearGradient>
|
|
33
|
+
</View>;
|
|
34
|
+
};
|
|
35
|
+
export default CircleGradient;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LinearGradientPackage } from "../../optionalDependencies";
|
|
3
|
+
const LinearGradient = LinearGradientPackage?.default;
|
|
4
|
+
import View from "../../components/view";
|
|
5
|
+
import useAngleTransform from "./useAngleTransform";
|
|
6
|
+
const RectangleGradient = props => {
|
|
7
|
+
const {
|
|
8
|
+
colors,
|
|
9
|
+
width,
|
|
10
|
+
height,
|
|
11
|
+
angle,
|
|
12
|
+
children,
|
|
13
|
+
...others
|
|
14
|
+
} = props;
|
|
15
|
+
const {
|
|
16
|
+
start,
|
|
17
|
+
end
|
|
18
|
+
} = useAngleTransform({
|
|
19
|
+
angle
|
|
20
|
+
});
|
|
21
|
+
if (!LinearGradient) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return <View width={width} height={height}>
|
|
25
|
+
<LinearGradient colors={colors} start={start} end={end}>
|
|
26
|
+
<View width={width} height={height} {...others}>
|
|
27
|
+
{children}
|
|
28
|
+
</View>
|
|
29
|
+
</LinearGradient>
|
|
30
|
+
</View>;
|
|
31
|
+
};
|
|
32
|
+
export default RectangleGradient;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { LinearGradientPackage } from "../../optionalDependencies";
|
|
3
|
+
const LinearGradient = LinearGradientPackage?.default;
|
|
4
|
+
import { LogService } from "../../services";
|
|
5
|
+
import { GradientProps } from "./types";
|
|
6
|
+
import RectangleGradient from "./RectangleGradient";
|
|
7
|
+
import CircleGradient from "./CircleGradient";
|
|
8
|
+
import BorderGradient from "./BorderGradient";
|
|
9
|
+
export { GradientProps };
|
|
10
|
+
const Gradient = props => {
|
|
11
|
+
const {
|
|
12
|
+
type = 'rectangle',
|
|
13
|
+
...others
|
|
14
|
+
} = props;
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (LinearGradient === undefined) {
|
|
17
|
+
LogService.error(`RNUILib Gradient requires installing "react-native-linear-gradient" dependency`);
|
|
18
|
+
}
|
|
19
|
+
}, []);
|
|
20
|
+
switch (type) {
|
|
21
|
+
case 'rectangle':
|
|
22
|
+
return <RectangleGradient {...others} />;
|
|
23
|
+
case 'circle':
|
|
24
|
+
return <CircleGradient {...others} />;
|
|
25
|
+
case 'border':
|
|
26
|
+
return <BorderGradient {...others} />;
|
|
27
|
+
default:
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export default Gradient;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LinearGradientProps } from 'react-native-linear-gradient';
|
|
2
|
+
type CommonGradientProps = Pick<LinearGradientProps, 'colors' | 'children'> & {
|
|
3
|
+
angle?: number;
|
|
4
|
+
center?: boolean;
|
|
5
|
+
centerH?: boolean;
|
|
6
|
+
centerV?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type GradientProps = ({
|
|
9
|
+
type: 'rectangle';
|
|
10
|
+
} & RectangleGradientProps) | ({
|
|
11
|
+
type: 'circle';
|
|
12
|
+
} & CircleGradientProps) | ({
|
|
13
|
+
type: 'border';
|
|
14
|
+
} & BorderGradientProps);
|
|
15
|
+
export type RectangleGradientProps = CommonGradientProps & {
|
|
16
|
+
width?: number;
|
|
17
|
+
height?: number;
|
|
18
|
+
};
|
|
19
|
+
export type CircleGradientProps = CommonGradientProps & {
|
|
20
|
+
radius: number;
|
|
21
|
+
};
|
|
22
|
+
export type BorderGradientProps = RectangleGradientProps & {
|
|
23
|
+
borderWidth?: number;
|
|
24
|
+
borderRadius?: number;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare function getStartEndFromAngle(angle?: number): {
|
|
2
|
+
start: {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
end: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare const _forTesting: {
|
|
12
|
+
getStartEndFromAngle: typeof getStartEndFromAngle;
|
|
13
|
+
};
|
|
14
|
+
export type AngleTransformProps = {
|
|
15
|
+
angle?: number;
|
|
16
|
+
};
|
|
17
|
+
declare const useAngleTransform: (props: AngleTransformProps) => {
|
|
18
|
+
start: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
22
|
+
end: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export default useAngleTransform;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
const EPSILON = 1e-12;
|
|
3
|
+
function getStartEndFromAngle(angle = 0) {
|
|
4
|
+
// Normalize angle to [0, 360)
|
|
5
|
+
let a = angle % 360;
|
|
6
|
+
if (a < 0) {
|
|
7
|
+
a += 360;
|
|
8
|
+
}
|
|
9
|
+
const rad = a * Math.PI / 180;
|
|
10
|
+
|
|
11
|
+
// Direction vector where 0deg points up, 90deg right, etc.
|
|
12
|
+
const vx = Math.sin(rad);
|
|
13
|
+
const vy = -Math.cos(rad);
|
|
14
|
+
|
|
15
|
+
// Distance from center (0.5,0.5) to box edge along v
|
|
16
|
+
const denomX = Math.abs(vx) > EPSILON ? 0.5 / Math.abs(vx) : Number.POSITIVE_INFINITY;
|
|
17
|
+
const denomY = Math.abs(vy) > EPSILON ? 0.5 / Math.abs(vy) : Number.POSITIVE_INFINITY;
|
|
18
|
+
const t = Math.min(denomX, denomY);
|
|
19
|
+
const cx = 0.5;
|
|
20
|
+
const cy = 0.5;
|
|
21
|
+
const end = {
|
|
22
|
+
x: cx + vx * t,
|
|
23
|
+
y: cy + vy * t
|
|
24
|
+
};
|
|
25
|
+
const start = {
|
|
26
|
+
x: cx - vx * t,
|
|
27
|
+
y: cy - vy * t
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// Quantize to avoid tiny floating errors for canonical angles (0, 45, 90, ...).
|
|
31
|
+
const quantize = v => {
|
|
32
|
+
if (Math.abs(v - 0) < EPSILON) {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
if (Math.abs(v - 0.5) < EPSILON) {
|
|
36
|
+
return 0.5;
|
|
37
|
+
}
|
|
38
|
+
if (Math.abs(v - 1) < EPSILON) {
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
// Clamp just in case of tiny over/underflows
|
|
42
|
+
if (v < 0) {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
if (v > 1) {
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
return v;
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
start: {
|
|
52
|
+
x: quantize(start.x),
|
|
53
|
+
y: quantize(start.y)
|
|
54
|
+
},
|
|
55
|
+
end: {
|
|
56
|
+
x: quantize(end.x),
|
|
57
|
+
y: quantize(end.y)
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export const _forTesting = {
|
|
62
|
+
getStartEndFromAngle
|
|
63
|
+
}; // exporting private functions for testing only
|
|
64
|
+
|
|
65
|
+
const useAngleTransform = props => {
|
|
66
|
+
const {
|
|
67
|
+
angle
|
|
68
|
+
} = props;
|
|
69
|
+
const startEnd = useMemo(() => getStartEndFromAngle(angle), [angle]);
|
|
70
|
+
return startEnd;
|
|
71
|
+
};
|
|
72
|
+
export default useAngleTransform;
|
package/src/incubator/index.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export { default as Slider, SliderRef, SliderProps } from './slider';
|
|
|
8
8
|
export { default as Dialog, DialogProps, DialogHeaderProps, DialogStatics, DialogImperativeMethods } from './dialog';
|
|
9
9
|
export { default as ChipsInput, ChipsInputProps, ChipsInputChangeReason, ChipsInputChipProps } from '../components/chipsInput';
|
|
10
10
|
export { default as WheelPicker, WheelPickerProps, WheelPickerItemProps, WheelPickerAlign, WheelPickerItemValue } from '../components/WheelPicker';
|
|
11
|
+
export { default as Gradient, GradientProps } from './gradient';
|
package/src/incubator/index.js
CHANGED
|
@@ -9,4 +9,5 @@ export { default as Slider, SliderRef, SliderProps } from "./slider";
|
|
|
9
9
|
export { default as Dialog, DialogProps, DialogHeaderProps, DialogStatics, DialogImperativeMethods } from "./dialog";
|
|
10
10
|
// TODO: delete exports after fully removing from private
|
|
11
11
|
export { default as ChipsInput, ChipsInputProps, ChipsInputChangeReason, ChipsInputChipProps } from "../components/chipsInput";
|
|
12
|
-
export { default as WheelPicker, WheelPickerProps, WheelPickerItemProps, WheelPickerAlign, WheelPickerItemValue } from "../components/WheelPicker";
|
|
12
|
+
export { default as WheelPicker, WheelPickerProps, WheelPickerItemProps, WheelPickerAlign, WheelPickerItemValue } from "../components/WheelPicker";
|
|
13
|
+
export { default as Gradient, GradientProps } from "./gradient";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare let LinearGradientPackage:
|
|
1
|
+
declare let LinearGradientPackage: typeof import('react-native-linear-gradient') | undefined;
|
|
2
2
|
export default LinearGradientPackage;
|