react-native-ui-lib 7.38.1 → 7.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +7 -0
- package/package.json +1 -1
- package/scripts/docs/buildDocsCommon.js +17 -8
- package/src/components/avatar/avatar.api.json +1 -1
- package/src/components/avatar/index.d.ts +22 -20
- package/src/components/avatar/index.js +2 -1
- package/src/components/badge/index.js +10 -1
- package/src/components/button/ButtonConstants.d.ts +6 -0
- package/src/components/button/ButtonConstants.js +6 -0
- package/src/components/button/index.d.ts +18 -5
- package/src/components/button/index.js +17 -2
- package/src/components/card/index.js +3 -1
- package/src/components/checkbox/index.d.ts +1 -0
- package/src/components/checkbox/index.js +4 -1
- package/src/components/colorPalette/ColorPalette.api.json +103 -10
- package/src/components/colorPicker/colorPicker.api.json +107 -4
- package/src/components/colorSwatch/colorSwatch.api.json +161 -9
- package/src/components/connectionStatusBar/index.js +3 -1
- package/src/components/dateTimePicker/index.js +2 -1
- package/src/components/dateTimePicker/useOldApi.js +3 -1
- package/src/components/gridList/gridList.api.json +95 -5
- package/src/components/gridListItem/gridListItem.api.json +325 -19
- package/src/components/hint/hint.api.json +177 -19
- package/src/components/modal/index.js +3 -1
- package/src/components/pieChart/index.js +2 -1
- package/src/components/progressBar/progressBar.api.json +154 -5
- package/src/components/radioButton/index.js +8 -1
- package/src/components/skeletonView/index.js +3 -2
- package/src/components/stepper/stepper.api.json +226 -9
- package/src/components/svgImage/index.js +2 -1
- package/src/components/test.api.json +1 -33
- package/src/components/timeline/timeline.api.json +349 -61
- package/src/incubator/slider/SliderPresenter.js +11 -4
- package/src/incubator/toast/toast.api.json +127 -1
- package/src/services/HapticService.js +2 -1
- package/src/services/LogService.d.ts +7 -2
- package/src/services/LogService.js +5 -0
- /package/src/components/pieChart/{PieChart.api.json → pieChart.api.json} +0 -0
package/.eslintrc.js
CHANGED
|
@@ -8,6 +8,13 @@ module.exports = {
|
|
|
8
8
|
'no-undef': 'off',
|
|
9
9
|
/* Other Rules */
|
|
10
10
|
'no-unused-expressions': 'off',
|
|
11
|
+
'no-restricted-syntax': [
|
|
12
|
+
'error',
|
|
13
|
+
{
|
|
14
|
+
selector: `CallExpression[callee.object.name='console'][callee.property.name='error']`,
|
|
15
|
+
message: 'Using console.error is not allowed as it is sent to Sentry, please use LogService.error instead'
|
|
16
|
+
}
|
|
17
|
+
],
|
|
11
18
|
'arrow-parens': 'off',
|
|
12
19
|
// TODO: remove after migration of legacy lifecycle methods
|
|
13
20
|
camelcase: 'off',
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ const fs = require('fs');
|
|
|
7
7
|
|
|
8
8
|
const COMPONENTS_DOCS_DIR = './docs/components';
|
|
9
9
|
const SERVICES_DOCS_DIR = './docs/services';
|
|
10
|
+
const FOUNDATION_DOCS_DIR = './docs/foundation';
|
|
10
11
|
|
|
11
12
|
const VALID_COMPONENTS_CATEGORIES = [
|
|
12
13
|
'foundation',
|
|
@@ -92,14 +93,22 @@ function processComponents(components) {
|
|
|
92
93
|
content += `${buildOldDocs(component)}\n`;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
|
|
96
96
|
let dirPath;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
switch (component.category) {
|
|
98
|
+
case 'services': {
|
|
99
|
+
dirPath = `${SERVICES_DOCS_DIR}`;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case 'foundation': {
|
|
103
|
+
dirPath = `${FOUNDATION_DOCS_DIR}`;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
default: {
|
|
107
|
+
const componentParentDir =
|
|
108
|
+
componentParentName || isParentComponent ? `/${componentParentName || componentName}` : '';
|
|
109
|
+
dirPath = `${COMPONENTS_DOCS_DIR}/${component.category}${componentParentDir}`;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
103
112
|
}
|
|
104
113
|
|
|
105
114
|
if (!fs.existsSync(dirPath)) {
|
|
@@ -184,7 +193,7 @@ function buildOldDocs(component) {
|
|
|
184
193
|
/* Snippet */
|
|
185
194
|
if (component.snippet) {
|
|
186
195
|
content += `### Usage\n`;
|
|
187
|
-
content += `<UILivePreview code={\`${component.snippet
|
|
196
|
+
content += `<UILivePreview componentName={"${component.name}"} code={\`${component.snippet
|
|
188
197
|
?.map(item => _.replace(item, new RegExp(/\$[1-9]/, 'g'), ''))
|
|
189
198
|
.join('\n')
|
|
190
199
|
.toString()}\`}/>\n\n`;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
{
|
|
13
13
|
"name": "animate",
|
|
14
14
|
"type": "boolean",
|
|
15
|
-
"description": "Adds fade in animation when Avatar image loads",
|
|
15
|
+
"description": "Adds fade in animation when Avatar image loads. This prop isn't supported on web (will be set to false by default when using web).",
|
|
16
16
|
"default": "false"
|
|
17
17
|
},
|
|
18
18
|
{"name": "backgroundColor", "type": "string", "description": "Background color for Avatar"},
|
|
@@ -162,29 +162,30 @@ declare const Avatar: React.ForwardRefExoticComponent<Pick<AccessibilityProps, "
|
|
|
162
162
|
* Image props object
|
|
163
163
|
*/
|
|
164
164
|
imageProps?: Partial<Omit<import("react-native").ImageProps, "source"> & Pick<import("react-native").ImageBackgroundProps, "imageStyle"> & Partial<Record<"margin" | "marginL" | "marginT" | "marginR" | "marginB" | "marginH" | "marginV", boolean>> & import("../..").RecorderProps & {
|
|
165
|
+
/**
|
|
166
|
+
* Avatar colors to be used when useAutoColors is true
|
|
167
|
+
*/
|
|
165
168
|
sourceTransformer?: ((props: any) => import("../image").ImageSourceType) | undefined;
|
|
166
169
|
assetName?: string | undefined;
|
|
167
170
|
assetGroup?: string | undefined;
|
|
168
171
|
tintColor?: string | undefined;
|
|
169
|
-
supportRTL?: boolean | undefined;
|
|
172
|
+
supportRTL?: boolean | undefined; /**
|
|
173
|
+
* Background color for Avatar
|
|
174
|
+
*/
|
|
170
175
|
cover?: boolean | undefined;
|
|
171
176
|
aspectRatio?: number | undefined;
|
|
172
|
-
overlayType?: string | undefined;
|
|
177
|
+
overlayType?: string | undefined; /**
|
|
178
|
+
* Image props object
|
|
179
|
+
*/
|
|
173
180
|
overlayIntensity?: import("../overlay").OverlayIntensityType | undefined;
|
|
174
181
|
overlayColor?: string | undefined;
|
|
175
182
|
customOverlayContent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | undefined;
|
|
176
183
|
errorSource?: import("../image").ImageSourceType;
|
|
177
|
-
imageId?: string | undefined;
|
|
178
|
-
* Listener-callback for when an image's (uri) loading
|
|
179
|
-
* fails (equiv. to Image.onError()).
|
|
180
|
-
*/
|
|
184
|
+
imageId?: string | undefined;
|
|
181
185
|
useBackgroundContainer?: boolean | undefined;
|
|
182
186
|
width?: string | number | undefined;
|
|
183
187
|
height?: string | number | undefined;
|
|
184
|
-
source: import("../image").ImageSourceType;
|
|
185
|
-
* Hash the name (or label) to get a color, so each name will have a specific color.
|
|
186
|
-
* Default is false.
|
|
187
|
-
*/
|
|
188
|
+
source: import("../image").ImageSourceType;
|
|
188
189
|
} & AnimatedImageProps> | undefined;
|
|
189
190
|
/**
|
|
190
191
|
* Image style object used to pass additional style props
|
|
@@ -290,29 +291,30 @@ declare const _default: React.ForwardRefExoticComponent<Pick<AccessibilityProps,
|
|
|
290
291
|
* Image props object
|
|
291
292
|
*/
|
|
292
293
|
imageProps?: Partial<Omit<import("react-native").ImageProps, "source"> & Pick<import("react-native").ImageBackgroundProps, "imageStyle"> & Partial<Record<"margin" | "marginL" | "marginT" | "marginR" | "marginB" | "marginH" | "marginV", boolean>> & import("../..").RecorderProps & {
|
|
294
|
+
/**
|
|
295
|
+
* Avatar colors to be used when useAutoColors is true
|
|
296
|
+
*/
|
|
293
297
|
sourceTransformer?: ((props: any) => import("../image").ImageSourceType) | undefined;
|
|
294
298
|
assetName?: string | undefined;
|
|
295
299
|
assetGroup?: string | undefined;
|
|
296
300
|
tintColor?: string | undefined;
|
|
297
|
-
supportRTL?: boolean | undefined;
|
|
301
|
+
supportRTL?: boolean | undefined; /**
|
|
302
|
+
* Background color for Avatar
|
|
303
|
+
*/
|
|
298
304
|
cover?: boolean | undefined;
|
|
299
305
|
aspectRatio?: number | undefined;
|
|
300
|
-
overlayType?: string | undefined;
|
|
306
|
+
overlayType?: string | undefined; /**
|
|
307
|
+
* Image props object
|
|
308
|
+
*/
|
|
301
309
|
overlayIntensity?: import("../overlay").OverlayIntensityType | undefined;
|
|
302
310
|
overlayColor?: string | undefined;
|
|
303
311
|
customOverlayContent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | undefined;
|
|
304
312
|
errorSource?: import("../image").ImageSourceType;
|
|
305
|
-
imageId?: string | undefined;
|
|
306
|
-
* Listener-callback for when an image's (uri) loading
|
|
307
|
-
* fails (equiv. to Image.onError()).
|
|
308
|
-
*/
|
|
313
|
+
imageId?: string | undefined;
|
|
309
314
|
useBackgroundContainer?: boolean | undefined;
|
|
310
315
|
width?: string | number | undefined;
|
|
311
316
|
height?: string | number | undefined;
|
|
312
|
-
source: import("../image").ImageSourceType;
|
|
313
|
-
* Hash the name (or label) to get a color, so each name will have a specific color.
|
|
314
|
-
* Default is false.
|
|
315
|
-
*/
|
|
317
|
+
source: import("../image").ImageSourceType;
|
|
316
318
|
} & AnimatedImageProps> | undefined;
|
|
317
319
|
/**
|
|
318
320
|
* Image style object used to pass additional style props
|
|
@@ -16,6 +16,7 @@ import AnimatedImage from "../animatedImage";
|
|
|
16
16
|
import * as AvatarHelper from "../../helpers/AvatarHelper";
|
|
17
17
|
import { useThemeProps } from "../../hooks";
|
|
18
18
|
import { isSvg } from "../../utils/imageUtils";
|
|
19
|
+
import Constants from "../../commons/Constants";
|
|
19
20
|
export let BadgePosition = /*#__PURE__*/function (BadgePosition) {
|
|
20
21
|
BadgePosition["TOP_RIGHT"] = "TOP_RIGHT";
|
|
21
22
|
BadgePosition["TOP_LEFT"] = "TOP_LEFT";
|
|
@@ -149,7 +150,7 @@ const Avatar = forwardRef((props, ref) => {
|
|
|
149
150
|
const renderImage = () => {
|
|
150
151
|
if (source !== undefined) {
|
|
151
152
|
// Looks like reanimated does not support SVG
|
|
152
|
-
const ImageContainer = animate && !isSvg(source) ? AnimatedImage : Image;
|
|
153
|
+
const ImageContainer = animate && !isSvg(source) && !Constants.isWeb ? AnimatedImage : Image;
|
|
153
154
|
return <ImageContainer style={_imageStyle} source={source} onLoadStart={onImageLoadStart} onLoadEnd={onImageLoadEnd} onError={onImageLoadError} testID={`${testID}.image`} width={size} height={size} containerStyle={_baseContainerStyle} {...imageProps} />;
|
|
154
155
|
}
|
|
155
156
|
};
|
|
@@ -10,6 +10,8 @@ import Image from "../image";
|
|
|
10
10
|
import View from "../view";
|
|
11
11
|
import Text from "../text";
|
|
12
12
|
const LABEL_FORMATTER_VALUES = [1, 2, 3, 4];
|
|
13
|
+
const DEFAULT_PIMPLE_SIZE = 10;
|
|
14
|
+
const DEFAULT_BADGE_SIZE = 20;
|
|
13
15
|
/**
|
|
14
16
|
* @description: Round colored badge, typically used to show a number
|
|
15
17
|
* @extends: View
|
|
@@ -37,7 +39,14 @@ class Badge extends PureComponent {
|
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
41
|
get size() {
|
|
40
|
-
|
|
42
|
+
const {
|
|
43
|
+
size,
|
|
44
|
+
label
|
|
45
|
+
} = this.props;
|
|
46
|
+
if (size !== undefined) {
|
|
47
|
+
return size;
|
|
48
|
+
}
|
|
49
|
+
return label === undefined ? DEFAULT_PIMPLE_SIZE : DEFAULT_BADGE_SIZE;
|
|
41
50
|
}
|
|
42
51
|
isSmallBadge() {
|
|
43
52
|
return this.size <= 16;
|
|
@@ -17,4 +17,10 @@ export declare const MIN_WIDTH: {
|
|
|
17
17
|
MEDIUM: number;
|
|
18
18
|
LARGE: number;
|
|
19
19
|
};
|
|
20
|
+
export declare const SIZE_TO_VERTICAL_HITSLOP: {
|
|
21
|
+
readonly xSmall: 30;
|
|
22
|
+
readonly small: 25;
|
|
23
|
+
readonly medium: 20;
|
|
24
|
+
readonly large: 15;
|
|
25
|
+
};
|
|
20
26
|
export declare const DEFAULT_SIZE = ButtonSize.large;
|
|
@@ -17,4 +17,10 @@ export const MIN_WIDTH = {
|
|
|
17
17
|
MEDIUM: 77,
|
|
18
18
|
LARGE: 90
|
|
19
19
|
};
|
|
20
|
+
export const SIZE_TO_VERTICAL_HITSLOP = {
|
|
21
|
+
[ButtonSize.xSmall]: 30,
|
|
22
|
+
[ButtonSize.small]: 25,
|
|
23
|
+
[ButtonSize.medium]: 20,
|
|
24
|
+
[ButtonSize.large]: 15
|
|
25
|
+
};
|
|
20
26
|
export const DEFAULT_SIZE = ButtonSize.large;
|
|
@@ -11,9 +11,7 @@ declare class Button extends PureComponent<Props, ButtonState> {
|
|
|
11
11
|
static sizes: typeof ButtonSize;
|
|
12
12
|
static animationDirection: typeof ButtonAnimationDirection;
|
|
13
13
|
constructor(props: Props);
|
|
14
|
-
state:
|
|
15
|
-
size: undefined;
|
|
16
|
-
};
|
|
14
|
+
state: Record<'size', undefined | number>;
|
|
17
15
|
styles: {
|
|
18
16
|
container: {
|
|
19
17
|
backgroundColor: string;
|
|
@@ -370,7 +368,14 @@ declare class Button extends PureComponent<Props, ButtonState> {
|
|
|
370
368
|
getLabelColor(): string | undefined;
|
|
371
369
|
getIconColor(): string | undefined;
|
|
372
370
|
getLabelSizeStyle(): TextStyle | undefined;
|
|
373
|
-
getContainerSizeStyle():
|
|
371
|
+
getContainerSizeStyle(): Partial<{
|
|
372
|
+
height: number;
|
|
373
|
+
width: number;
|
|
374
|
+
padding: number;
|
|
375
|
+
paddingVertical: number;
|
|
376
|
+
paddingHorizontal: number;
|
|
377
|
+
minWidth: number;
|
|
378
|
+
}>;
|
|
374
379
|
getOutlineStyle(): {
|
|
375
380
|
borderWidth: number;
|
|
376
381
|
borderColor: string;
|
|
@@ -391,10 +396,18 @@ declare class Button extends PureComponent<Props, ButtonState> {
|
|
|
391
396
|
})[] | undefined;
|
|
392
397
|
getIconStyle(): [ImageStyle, StyleProp<ImageStyle>];
|
|
393
398
|
getAnimationDirectionStyle(): {
|
|
394
|
-
alignSelf:
|
|
399
|
+
readonly alignSelf: "flex-start";
|
|
400
|
+
} | {
|
|
401
|
+
readonly alignSelf: "flex-end";
|
|
395
402
|
} | undefined;
|
|
396
403
|
renderIcon(): React.JSX.Element | null;
|
|
397
404
|
renderLabel(): React.JSX.Element | null;
|
|
405
|
+
getAccessibleHitSlop(): {
|
|
406
|
+
top: number;
|
|
407
|
+
bottom: number;
|
|
408
|
+
left: number;
|
|
409
|
+
right: number;
|
|
410
|
+
};
|
|
398
411
|
render(): React.JSX.Element;
|
|
399
412
|
}
|
|
400
413
|
export { Button };
|
|
@@ -7,7 +7,7 @@ import TouchableOpacity from "../touchableOpacity";
|
|
|
7
7
|
import Text from "../text";
|
|
8
8
|
import Icon from "../icon";
|
|
9
9
|
import { ButtonSize, ButtonAnimationDirection, ButtonProps, DEFAULT_PROPS } from "./types";
|
|
10
|
-
import { PADDINGS, HORIZONTAL_PADDINGS, MIN_WIDTH, DEFAULT_SIZE } from "./ButtonConstants";
|
|
10
|
+
import { PADDINGS, HORIZONTAL_PADDINGS, MIN_WIDTH, DEFAULT_SIZE, SIZE_TO_VERTICAL_HITSLOP } from "./ButtonConstants";
|
|
11
11
|
export { ButtonSize, ButtonAnimationDirection, ButtonProps };
|
|
12
12
|
class Button extends PureComponent {
|
|
13
13
|
static displayName = 'Button';
|
|
@@ -351,6 +351,20 @@ class Button extends PureComponent {
|
|
|
351
351
|
}
|
|
352
352
|
return null;
|
|
353
353
|
}
|
|
354
|
+
getAccessibleHitSlop() {
|
|
355
|
+
const containerStyle = this.getContainerSizeStyle();
|
|
356
|
+
const isWidthSet = containerStyle.width !== undefined || containerStyle.minWidth !== undefined;
|
|
357
|
+
const width = containerStyle.width || containerStyle.minWidth || 0;
|
|
358
|
+
const widthWithPadding = width + (containerStyle.paddingHorizontal || containerStyle.padding || 0) * 2;
|
|
359
|
+
const horizontalHitslop = isWidthSet ? Math.max(0, (48 - widthWithPadding) / 2) : 10;
|
|
360
|
+
const verticalHitslop = (containerStyle.height ? Math.max(0, 48 - containerStyle.height) : SIZE_TO_VERTICAL_HITSLOP[this.props.size || DEFAULT_SIZE]) / 2;
|
|
361
|
+
return {
|
|
362
|
+
top: verticalHitslop,
|
|
363
|
+
bottom: verticalHitslop,
|
|
364
|
+
left: horizontalHitslop,
|
|
365
|
+
right: horizontalHitslop
|
|
366
|
+
};
|
|
367
|
+
}
|
|
354
368
|
render() {
|
|
355
369
|
const {
|
|
356
370
|
onPress,
|
|
@@ -360,6 +374,7 @@ class Button extends PureComponent {
|
|
|
360
374
|
animateLayout,
|
|
361
375
|
modifiers,
|
|
362
376
|
forwardedRef,
|
|
377
|
+
hitSlop: hitSlopProp,
|
|
363
378
|
...others
|
|
364
379
|
} = this.props;
|
|
365
380
|
const shadowStyle = this.getShadowStyle();
|
|
@@ -373,7 +388,7 @@ class Button extends PureComponent {
|
|
|
373
388
|
const borderRadiusStyle = this.getBorderRadiusStyle();
|
|
374
389
|
return <TouchableOpacity row centerV style={[this.styles.container, animateLayout && this.getAnimationDirectionStyle(), containerSizeStyle, this.isLink && this.styles.innerContainerLink, shadowStyle, margins, paddings, {
|
|
375
390
|
backgroundColor
|
|
376
|
-
}, borderRadiusStyle, outlineStyle, style]} activeOpacity={0.6} activeBackgroundColor={this.getActiveBackgroundColor()} onLayout={this.onLayout} onPress={onPress} disabled={disabled} testID={testID} {...others} ref={forwardedRef}>
|
|
391
|
+
}, 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}>
|
|
377
392
|
{this.props.children}
|
|
378
393
|
{this.props.iconOnRight ? this.renderLabel() : this.renderIcon()}
|
|
379
394
|
{this.props.iconOnRight ? this.renderIcon() : this.renderLabel()}
|
|
@@ -15,6 +15,7 @@ import { BlurViewPackage } from "../../optionalDependencies";
|
|
|
15
15
|
import Assets from "../../assets";
|
|
16
16
|
import CardContext from "./CardContext";
|
|
17
17
|
import * as CardPresenter from "./CardPresenter";
|
|
18
|
+
import { LogService } from "../../services";
|
|
18
19
|
const BlurView = BlurViewPackage?.BlurView;
|
|
19
20
|
const DEFAULT_BORDER_RADIUS = BorderRadiuses.br40;
|
|
20
21
|
const DEFAULT_SELECTION_PROPS = {
|
|
@@ -47,7 +48,8 @@ class Card extends PureComponent {
|
|
|
47
48
|
};
|
|
48
49
|
this.styles = createStyles(this.props);
|
|
49
50
|
if (props.enableBlur && !BlurView) {
|
|
50
|
-
|
|
51
|
+
// eslint-disable-next-line max-len
|
|
52
|
+
LogService.error(`RNUILib Card's "enableBlur" prop requires installing "@react-native-community/blur" dependency`);
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
componentDidUpdate(prevProps) {
|
|
@@ -117,6 +117,7 @@ declare class Checkbox extends Component<CheckboxProps, CheckboxState> {
|
|
|
117
117
|
getLabelStyle: () => {
|
|
118
118
|
color: string;
|
|
119
119
|
};
|
|
120
|
+
getAccessibleHitSlop(size: number): number;
|
|
120
121
|
renderCheckbox(): React.JSX.Element;
|
|
121
122
|
render(): React.JSX.Element;
|
|
122
123
|
validate: () => void;
|
|
@@ -144,6 +144,9 @@ class Checkbox extends Component {
|
|
|
144
144
|
color: this.props.disabled ? Colors.$textDisabled : this.state.showError ? Colors.$textDangerLight : Colors.$textDefault
|
|
145
145
|
};
|
|
146
146
|
};
|
|
147
|
+
getAccessibleHitSlop(size) {
|
|
148
|
+
return Math.max(0, (48 - size) / 2);
|
|
149
|
+
}
|
|
147
150
|
renderCheckbox() {
|
|
148
151
|
const {
|
|
149
152
|
selectedIcon,
|
|
@@ -156,7 +159,7 @@ class Checkbox extends Component {
|
|
|
156
159
|
} = this.props;
|
|
157
160
|
return (
|
|
158
161
|
//@ts-ignore
|
|
159
|
-
<TouchableOpacity {...this.getAccessibilityProps()} activeOpacity={1} testID={testID} {...others} style={[this.getBorderStyle(), style, !label && containerStyle]} onPress={this.onPress}>
|
|
162
|
+
<TouchableOpacity {...this.getAccessibilityProps()} activeOpacity={1} testID={testID} {...others} style={[this.getBorderStyle(), style, !label && containerStyle]} onPress={this.onPress} hitSlop={this.getAccessibleHitSlop(this.props.size || DEFAULT_SIZE)}>
|
|
160
163
|
{<Animated.View style={[this.styles.container, {
|
|
161
164
|
opacity: this.animationStyle.opacity
|
|
162
165
|
}, {
|
|
@@ -8,8 +8,16 @@
|
|
|
8
8
|
"https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/ColorPalette/ColorPalette.gif?raw=true"
|
|
9
9
|
],
|
|
10
10
|
"props": [
|
|
11
|
-
{
|
|
12
|
-
|
|
11
|
+
{
|
|
12
|
+
"name": "colors",
|
|
13
|
+
"type": "string[]",
|
|
14
|
+
"description": "Array of colors to render in the palette"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "value",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "The value of the selected swatch"
|
|
20
|
+
},
|
|
13
21
|
{
|
|
14
22
|
"name": "usePagination",
|
|
15
23
|
"type": "boolean",
|
|
@@ -22,7 +30,12 @@
|
|
|
22
30
|
"description": "Whether the colors pagination scrolls in a loop",
|
|
23
31
|
"default": "true"
|
|
24
32
|
},
|
|
25
|
-
{
|
|
33
|
+
{
|
|
34
|
+
"name": "numberOfRows",
|
|
35
|
+
"type": "number",
|
|
36
|
+
"description": "The number of color rows from 2 to 5",
|
|
37
|
+
"default": "3"
|
|
38
|
+
},
|
|
26
39
|
{
|
|
27
40
|
"name": "animatedIndex",
|
|
28
41
|
"type": "number",
|
|
@@ -34,12 +47,36 @@
|
|
|
34
47
|
"type": "(value: string, colorInfo: ColorInfo) => void",
|
|
35
48
|
"description": "Invoked once when value changes by selecting one of the swatches in the palette"
|
|
36
49
|
},
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{
|
|
50
|
+
{
|
|
51
|
+
"name": "swatchStyle",
|
|
52
|
+
"type": "ViewStyle",
|
|
53
|
+
"description": "Style to pass all the ColorSwatches in the palette"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "containerWidth",
|
|
57
|
+
"type": "number",
|
|
58
|
+
"description": "The container margins"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "containerStyle",
|
|
62
|
+
"type": "ViewStyle",
|
|
63
|
+
"description": "Component's container style"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "style",
|
|
67
|
+
"type": "ViewStyle",
|
|
68
|
+
"description": "Component's style"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "testID",
|
|
72
|
+
"type": "string",
|
|
73
|
+
"description": "The test id for e2e tests"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "backgroundColor",
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "The ColorPalette's background color"
|
|
79
|
+
}
|
|
43
80
|
],
|
|
44
81
|
"snippet": [
|
|
45
82
|
"<ColorPalette",
|
|
@@ -47,5 +84,61 @@
|
|
|
47
84
|
" value={selectedColor$2}",
|
|
48
85
|
" onValueChange={() => console.log('value changed')$3}",
|
|
49
86
|
"/>"
|
|
50
|
-
]
|
|
87
|
+
],
|
|
88
|
+
"docs": {
|
|
89
|
+
"hero": {
|
|
90
|
+
"title": "ColorPalette",
|
|
91
|
+
"description": "markdown:Our Color Palette is basically an arrangement of Color Swatches representing various colors and styles. \nIn ColorPalette only a single color swatch can be selected.",
|
|
92
|
+
"type": "hero",
|
|
93
|
+
"layout": "horizontal",
|
|
94
|
+
"content": [
|
|
95
|
+
{
|
|
96
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ColorPalette/ColorPalette_cover.png"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
"tabs": [
|
|
101
|
+
{
|
|
102
|
+
"title": "Overview",
|
|
103
|
+
"sections": [
|
|
104
|
+
{
|
|
105
|
+
"type": "list",
|
|
106
|
+
"items": [
|
|
107
|
+
{
|
|
108
|
+
"title": "Color Palette large (multiple rows):",
|
|
109
|
+
"description": "markdown:In some cases, product or flow will benefit from a bigger palette. \nThis type of palette is navigated with pagination. \nMinimum number of rows is 2 and maximum is 5. \nThe palette adapts to the screen width, with a minimum spacing of S5 between colors swatches.",
|
|
110
|
+
"content": [
|
|
111
|
+
{
|
|
112
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ColorPalette/ColorPalette_types_large.png"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"title": "Color Palette small (single row):",
|
|
118
|
+
"description": "markdown:In screens with a limited space a smaller palette can be used. \nIf the amount of color swatches is larger than the screen width, the Color Palette becomes scrollable. \nTapping the “+” button will open the Color Picker dialog, allowing user to create a custom color. \nWhen Color Palette is scrollable, “add” button will be sticky to screen left. \nAfter the custom color is created, it’s added as a Color Swatch to the right of the “add” button, and selected as the main color. \nIf the selected color is outside of the view port when screen is loaded, the palette will be scrolled to the primary swatch. \nTransparent swatches are fixed to the left of other (regular) Color Swatches.",
|
|
119
|
+
"content": [
|
|
120
|
+
{
|
|
121
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ColorPalette/ColorPalette_types_small.png"
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
"layout": "horizontal",
|
|
127
|
+
"title": "Palette Types",
|
|
128
|
+
"description": "Color Palette can be a single row of Color Swatches or have multiple rows:"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"type": "section",
|
|
132
|
+
"layout": "horizontal",
|
|
133
|
+
"content": [
|
|
134
|
+
{
|
|
135
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ColorPalette/ColorPalette_types_spec.png"
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"title": "Spec"
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
}
|
|
51
144
|
}
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
"type": "string[]",
|
|
14
14
|
"description": "Array of colors for the picker's color palette (hex values)"
|
|
15
15
|
},
|
|
16
|
-
{
|
|
16
|
+
{
|
|
17
|
+
"name": "value",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "The value of the selected swatch"
|
|
20
|
+
},
|
|
17
21
|
{
|
|
18
22
|
"name": "animatedIndex",
|
|
19
23
|
"type": "number",
|
|
@@ -31,8 +35,16 @@
|
|
|
31
35
|
"description": "Accessibility labels as an object of strings",
|
|
32
36
|
"default": "{\n addButton: 'add custom color using hex code',\n dismissButton: 'dismiss',\n doneButton: 'done',\n input: 'custom hex color code'\n}"
|
|
33
37
|
},
|
|
34
|
-
{
|
|
35
|
-
|
|
38
|
+
{
|
|
39
|
+
"name": "testID",
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "The test id for e2e tests"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "backgroundColor",
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "The ColorPicker's background color"
|
|
47
|
+
}
|
|
36
48
|
],
|
|
37
49
|
"snippet": [
|
|
38
50
|
"<ColorPicker",
|
|
@@ -43,5 +55,96 @@
|
|
|
43
55
|
" onSubmit={() => console.log('submit')$5}",
|
|
44
56
|
" onValueChange={() => console.log('value changed')$6}",
|
|
45
57
|
"/>"
|
|
46
|
-
]
|
|
58
|
+
],
|
|
59
|
+
"docs": {
|
|
60
|
+
"hero": {
|
|
61
|
+
"title": "ColorPicker",
|
|
62
|
+
"description": "markdown:Picking color for background, typography and other elements is possible by various means, among these are: \nColor Swatch, Color Palette and Color Picker Dialog. \nAll these can be implemented in the color picking flow. ",
|
|
63
|
+
"type": "hero",
|
|
64
|
+
"layout": "horizontal",
|
|
65
|
+
"content": [
|
|
66
|
+
{
|
|
67
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ColorPicker/ColorPicker_cover.png"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"tabs": [
|
|
72
|
+
{
|
|
73
|
+
"title": "Overview",
|
|
74
|
+
"sections": [
|
|
75
|
+
{
|
|
76
|
+
"type": "list",
|
|
77
|
+
"items": [
|
|
78
|
+
{
|
|
79
|
+
"title": "",
|
|
80
|
+
"description": "markdown:1. Tapping 'Add New' in the Color Palette opens a color picker dialog.
\n2. Using HLS controls (or even typing actual HEX value) user can achieve any color. ",
|
|
81
|
+
"content": [
|
|
82
|
+
{
|
|
83
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ColorPicker/ColorPicker_usage1.png"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"title": "",
|
|
89
|
+
"description": "markdown:3. Changes are saved by tapping on ‘V’. \n4. New color styles is saved in the Color Palette and selected as the theme color. ",
|
|
90
|
+
"content": [
|
|
91
|
+
{
|
|
92
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ColorPicker/ColorPicker_usage2.png"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"layout": "horizontal",
|
|
98
|
+
"title": "Usage Example",
|
|
99
|
+
"description": "In this example, user picks his own theme color."
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"type": "section",
|
|
103
|
+
"title": "Additional entry points examples",
|
|
104
|
+
"description": "As mentioned, Color Picker dialog can be triggered by various entry points. ",
|
|
105
|
+
"content": [
|
|
106
|
+
{
|
|
107
|
+
"value": "https://embed.figma.com/design/xFjvYNkGTmYTGYMLrmz9Ir/Guidelines-to-Docs?node-id=2476-69290&m=dev&embed-host=share&page-selector=false"
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"type": "list",
|
|
113
|
+
"items": [
|
|
114
|
+
{
|
|
115
|
+
"title": "",
|
|
116
|
+
"description": "markdown:1. Tapping on the HEX value will “activate” the input field (Main Input) and display the keyboard. New color can be created either by typing a hex value or by pasting a specific value. \n2. Until new valid hex value is provided, the initial color background is kept. Hex value is highlighted with either white at 25% or black at 25%, depending on the background color. ",
|
|
117
|
+
"content": [
|
|
118
|
+
{
|
|
119
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ColorPicker/ColorPicker_hex1.png"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"title": "",
|
|
125
|
+
"description": "markdown:3. ‘#’ symbol is permanent and cant be deleted. \n4. Once hex value is valid (6 characters), background color changes accordingly. ",
|
|
126
|
+
"content": [
|
|
127
|
+
{
|
|
128
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ColorPicker/ColorPicker_hex2.png"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
"layout": "horizontal",
|
|
134
|
+
"title": "Adding HEX values manually",
|
|
135
|
+
"description": "Color Picker dialog allows manual entry of the HEX values:"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"type": "section",
|
|
139
|
+
"title": "Spec",
|
|
140
|
+
"content": [
|
|
141
|
+
{
|
|
142
|
+
"value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/ColorPicker/ColorPicker_spec.png"
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
}
|
|
47
150
|
}
|