@via-profit/ui-kit 0.1.0-rc.76 → 0.1.0-rc.78
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/Accordion/AccordionActions.d.ts +8 -0
- package/Accordion/AccordionActions.js +31 -0
- package/Accordion/AccordionContainer.d.ts +8 -0
- package/Accordion/AccordionContainer.js +61 -0
- package/Accordion/AccordionContent.d.ts +10 -0
- package/Accordion/AccordionContent.js +35 -0
- package/Accordion/AccordionHeader.d.ts +10 -0
- package/Accordion/AccordionHeader.js +53 -0
- package/Accordion/Chevron.d.ts +4 -0
- package/Accordion/Chevron.js +13 -0
- package/Accordion/index.d.ts +86 -0
- package/Accordion/index.js +65 -0
- package/Button/ButtonIconWrapper.d.ts +1 -1
- package/Calendar/CalendarBottomBar.d.ts +4 -0
- package/Calendar/CalendarBottomBar.js +28 -0
- package/Calendar/CalendarMonthControl.d.ts +6 -0
- package/Calendar/CalendarMonthControl.js +41 -0
- package/Calendar/IconChevronLeft.d.ts +3 -0
- package/Calendar/IconChevronLeft.js +9 -0
- package/CountryFlags/Uknown.d.ts +3 -0
- package/CountryFlags/Uknown.js +34 -0
- package/Selectbox/IconShow.d.ts +3 -0
- package/Selectbox/IconShow.js +9 -0
- package/Switch/SwitchAsterisk.d.ts +13 -0
- package/Switch/SwitchAsterisk.js +53 -0
- package/Switch/SwitchContainer.d.ts +26 -0
- package/Switch/SwitchContainer.js +52 -0
- package/Switch/SwitchDot.d.ts +17 -0
- package/Switch/SwitchDot.js +145 -0
- package/Switch/SwitchErrorText.d.ts +6 -0
- package/Switch/SwitchErrorText.js +76 -0
- package/Switch/SwitchTextWrapper.d.ts +4 -0
- package/Switch/SwitchTextWrapper.js +30 -0
- package/Switch/SwitchToggleWrapper.d.ts +4 -0
- package/Switch/SwitchToggleWrapper.js +57 -0
- package/Switch/SwitchTrack.d.ts +17 -0
- package/Switch/SwitchTrack.js +80 -0
- package/Switch/SwitchWrapper.d.ts +4 -0
- package/Switch/SwitchWrapper.js +31 -0
- package/Switch/index.d.ts +138 -0
- package/Switch/index.js +56 -0
- package/TextArea/TextAreaIconWrapper.d.ts +1 -1
- package/TextField/TextFieldIconWrapper.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SwitchContainerProps } from './SwitchContainer';
|
|
3
|
+
import { SwitchToggleWrapperProps } from './SwitchToggleWrapper';
|
|
4
|
+
import { SwitchTextWrapperProps } from './SwitchTextWrapper';
|
|
5
|
+
import { SwitchDotProps } from './SwitchDot';
|
|
6
|
+
import { SwitchTrackProps } from './SwitchTrack';
|
|
7
|
+
import { SwitchWrapperProps } from './SwitchWrapper';
|
|
8
|
+
import { SwitchErrorTextProps } from './SwitchErrorText';
|
|
9
|
+
import { SwitchAsteriskProps } from './SwitchAsterisk';
|
|
10
|
+
export type SwitchProps = Omit<SwitchToggleWrapperProps, 'checked' | 'onChange' | 'disabled'> & {
|
|
11
|
+
/**
|
|
12
|
+
* If true then `errorText` value will be displayed under the Switch element
|
|
13
|
+
*/
|
|
14
|
+
readonly error?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* If is true then the asterisk will be displayed in label\
|
|
17
|
+
* If is ReactNode then ReactNode will be displayed in label
|
|
18
|
+
*/
|
|
19
|
+
readonly requiredAsterisk?: boolean | React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Text or ReactNode to show in error element\
|
|
22
|
+
* Will be displaed only if `error` property is tru
|
|
23
|
+
*/
|
|
24
|
+
readonly errorText?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* This prop allows you to provide switch state and control it. This property overrides internal component state
|
|
27
|
+
* Default: undefined
|
|
28
|
+
*/
|
|
29
|
+
readonly checked?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* This prop allows you to control switch component. Function will be executed when user click a switch
|
|
32
|
+
* This prop overrides internal comonent control function
|
|
33
|
+
* Default: undefined
|
|
34
|
+
*/
|
|
35
|
+
readonly onChange?: React.InputHTMLAttributes<HTMLInputElement>['onChange'];
|
|
36
|
+
/**
|
|
37
|
+
* if `true` switch state can not be changed
|
|
38
|
+
* Default: false;
|
|
39
|
+
*/
|
|
40
|
+
readonly disabled?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* if `true` switch would be turned on by default
|
|
43
|
+
* Default: false;
|
|
44
|
+
*/
|
|
45
|
+
readonly defaultChecked?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* You can pass the primary, default, secondary name of the colors or your specified color value
|
|
48
|
+
*/
|
|
49
|
+
readonly color?: 'default' | 'primary' | 'secondary' | string;
|
|
50
|
+
/**
|
|
51
|
+
* This property changes position of switch and its label.
|
|
52
|
+
* Default: `end`
|
|
53
|
+
*/
|
|
54
|
+
readonly labelPosition?: 'start' | 'end' | 'top' | 'bottom';
|
|
55
|
+
readonly overrides?: SwitchOverrides;
|
|
56
|
+
};
|
|
57
|
+
export interface SwitchOverrides {
|
|
58
|
+
/**
|
|
59
|
+
* Element container
|
|
60
|
+
*/
|
|
61
|
+
readonly Container?: React.ForwardRefExoticComponent<SwitchContainerProps & React.RefAttributes<HTMLSpanElement>>;
|
|
62
|
+
/**
|
|
63
|
+
* Element toggle
|
|
64
|
+
*/
|
|
65
|
+
readonly ToggleWrapper?: React.ForwardRefExoticComponent<SwitchToggleWrapperProps & React.RefAttributes<HTMLSpanElement>>;
|
|
66
|
+
/**
|
|
67
|
+
* text wrapper
|
|
68
|
+
*/
|
|
69
|
+
readonly TextWrapper?: React.ForwardRefExoticComponent<SwitchTextWrapperProps & React.RefAttributes<HTMLSpanElement>>;
|
|
70
|
+
/**
|
|
71
|
+
* Dot wrapper
|
|
72
|
+
*/
|
|
73
|
+
readonly Dot?: React.ForwardRefExoticComponent<SwitchDotProps & React.RefAttributes<HTMLSpanElement>>;
|
|
74
|
+
/**
|
|
75
|
+
* Toggle track wrapper
|
|
76
|
+
*/
|
|
77
|
+
readonly Track?: React.ForwardRefExoticComponent<SwitchTrackProps & React.RefAttributes<HTMLSpanElement>>;
|
|
78
|
+
/**
|
|
79
|
+
* error text wrapper
|
|
80
|
+
*/
|
|
81
|
+
readonly ErrorText?: React.ForwardRefExoticComponent<SwitchErrorTextProps & React.RefAttributes<HTMLSpanElement>>;
|
|
82
|
+
/**
|
|
83
|
+
* error text wrapper
|
|
84
|
+
*/
|
|
85
|
+
readonly Asterisk?: React.ForwardRefExoticComponent<SwitchAsteriskProps & React.RefAttributes<HTMLSpanElement>>;
|
|
86
|
+
/**
|
|
87
|
+
* the main cwitch wrapper
|
|
88
|
+
*/
|
|
89
|
+
readonly Wrapper?: React.ForwardRefExoticComponent<SwitchWrapperProps & React.RefAttributes<HTMLSpanElement>>;
|
|
90
|
+
}
|
|
91
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<SwitchToggleWrapperProps, "onChange" | "disabled" | "checked"> & {
|
|
92
|
+
/**
|
|
93
|
+
* If true then `errorText` value will be displayed under the Switch element
|
|
94
|
+
*/
|
|
95
|
+
readonly error?: boolean | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* If is true then the asterisk will be displayed in label\
|
|
98
|
+
* If is ReactNode then ReactNode will be displayed in label
|
|
99
|
+
*/
|
|
100
|
+
readonly requiredAsterisk?: React.ReactNode;
|
|
101
|
+
/**
|
|
102
|
+
* Text or ReactNode to show in error element\
|
|
103
|
+
* Will be displaed only if `error` property is tru
|
|
104
|
+
*/
|
|
105
|
+
readonly errorText?: React.ReactNode;
|
|
106
|
+
/**
|
|
107
|
+
* This prop allows you to provide switch state and control it. This property overrides internal component state
|
|
108
|
+
* Default: undefined
|
|
109
|
+
*/
|
|
110
|
+
readonly checked?: boolean | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* This prop allows you to control switch component. Function will be executed when user click a switch
|
|
113
|
+
* This prop overrides internal comonent control function
|
|
114
|
+
* Default: undefined
|
|
115
|
+
*/
|
|
116
|
+
readonly onChange?: React.ChangeEventHandler<HTMLInputElement> | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* if `true` switch state can not be changed
|
|
119
|
+
* Default: false;
|
|
120
|
+
*/
|
|
121
|
+
readonly disabled?: boolean | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* if `true` switch would be turned on by default
|
|
124
|
+
* Default: false;
|
|
125
|
+
*/
|
|
126
|
+
readonly defaultChecked?: boolean | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* You can pass the primary, default, secondary name of the colors or your specified color value
|
|
129
|
+
*/
|
|
130
|
+
readonly color?: string | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* This property changes position of switch and its label.
|
|
133
|
+
* Default: `end`
|
|
134
|
+
*/
|
|
135
|
+
readonly labelPosition?: "bottom" | "top" | "start" | "end" | undefined;
|
|
136
|
+
readonly overrides?: SwitchOverrides | undefined;
|
|
137
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
138
|
+
export default _default;
|
package/Switch/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const SwitchContainer_1 = __importDefault(require("./SwitchContainer"));
|
|
19
|
+
const SwitchToggleWrapper_1 = __importDefault(require("./SwitchToggleWrapper"));
|
|
20
|
+
const SwitchTextWrapper_1 = __importDefault(require("./SwitchTextWrapper"));
|
|
21
|
+
const SwitchDot_1 = __importDefault(require("./SwitchDot"));
|
|
22
|
+
const SwitchTrack_1 = __importDefault(require("./SwitchTrack"));
|
|
23
|
+
const SwitchWrapper_1 = __importDefault(require("./SwitchWrapper"));
|
|
24
|
+
const SwitchErrorText_1 = __importDefault(require("./SwitchErrorText"));
|
|
25
|
+
const SwitchAsterisk_1 = __importDefault(require("./SwitchAsterisk"));
|
|
26
|
+
const Switch = (props, ref) => {
|
|
27
|
+
const { checked, onChange, defaultChecked, overrides, disabled, labelPosition, children, color, name, error, errorText, requiredAsterisk } = props, nativeProps = __rest(props, ["checked", "onChange", "defaultChecked", "overrides", "disabled", "labelPosition", "children", "color", "name", "error", "errorText", "requiredAsterisk"]);
|
|
28
|
+
const [internalChecked, setInternalChecked] = react_1.default.useState(typeof defaultChecked !== 'undefined' ? defaultChecked : false);
|
|
29
|
+
const overridesMap = react_1.default.useMemo(() => ({
|
|
30
|
+
TextWrapper: (overrides === null || overrides === void 0 ? void 0 : overrides.TextWrapper) || SwitchTextWrapper_1.default,
|
|
31
|
+
ToggleWrapper: (overrides === null || overrides === void 0 ? void 0 : overrides.ToggleWrapper) || SwitchToggleWrapper_1.default,
|
|
32
|
+
Container: (overrides === null || overrides === void 0 ? void 0 : overrides.Container) || SwitchContainer_1.default,
|
|
33
|
+
Track: (overrides === null || overrides === void 0 ? void 0 : overrides.Track) || SwitchTrack_1.default,
|
|
34
|
+
Dot: (overrides === null || overrides === void 0 ? void 0 : overrides.Dot) || SwitchDot_1.default,
|
|
35
|
+
ErrorText: (overrides === null || overrides === void 0 ? void 0 : overrides.ErrorText) || SwitchErrorText_1.default,
|
|
36
|
+
Asterisk: (overrides === null || overrides === void 0 ? void 0 : overrides.Asterisk) || SwitchAsterisk_1.default,
|
|
37
|
+
Wrapper: (overrides === null || overrides === void 0 ? void 0 : overrides.Wrapper) || SwitchWrapper_1.default,
|
|
38
|
+
}), [overrides]);
|
|
39
|
+
if (typeof checked !== 'undefined' && typeof onChange === 'undefined') {
|
|
40
|
+
console.error('The property «onChange» should be passed with prop «checked» to make component controlled');
|
|
41
|
+
}
|
|
42
|
+
return (react_1.default.createElement(overridesMap.Wrapper, null,
|
|
43
|
+
react_1.default.createElement(overridesMap.Container, { labelPosition: labelPosition, disabled: disabled },
|
|
44
|
+
react_1.default.createElement(overridesMap.ToggleWrapper, Object.assign({}, nativeProps, { disabled: disabled, onChange: typeof onChange !== 'undefined'
|
|
45
|
+
? onChange
|
|
46
|
+
: () => {
|
|
47
|
+
setInternalChecked(!internalChecked);
|
|
48
|
+
}, checked: typeof checked !== 'undefined' ? checked : defaultChecked ? true : undefined, name: name, ref: ref }),
|
|
49
|
+
react_1.default.createElement(overridesMap.Track, { color: color, checked: typeof checked !== 'undefined' ? checked : internalChecked }),
|
|
50
|
+
react_1.default.createElement(overridesMap.Dot, { color: color, checked: typeof checked !== 'undefined' ? checked : internalChecked })),
|
|
51
|
+
react_1.default.createElement(overridesMap.TextWrapper, null,
|
|
52
|
+
children,
|
|
53
|
+
typeof requiredAsterisk !== 'undefined' && requiredAsterisk !== null && (react_1.default.createElement(overridesMap.Asterisk, null, typeof requiredAsterisk === 'boolean' ? '*' : requiredAsterisk)))),
|
|
54
|
+
react_1.default.createElement(overridesMap.ErrorText, { error: error }, errorText)));
|
|
55
|
+
};
|
|
56
|
+
exports.default = react_1.default.forwardRef(Switch);
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { TextFieldIconWrapperProps } from '../TextField/TextFieldIconWrapper';
|
|
3
3
|
export type TextAreaIconWrapperProps = TextFieldIconWrapperProps;
|
|
4
4
|
declare const _default: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLDivElement> & {
|
|
5
|
-
readonly position: "
|
|
5
|
+
readonly position: "start" | "end";
|
|
6
6
|
readonly error?: boolean | undefined;
|
|
7
7
|
readonly focused?: boolean | undefined;
|
|
8
8
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -11,7 +11,7 @@ declare const _default: React.ForwardRefExoticComponent<React.InputHTMLAttribute
|
|
|
11
11
|
/**
|
|
12
12
|
* Icon position
|
|
13
13
|
*/
|
|
14
|
-
readonly position: "
|
|
14
|
+
readonly position: "start" | "end";
|
|
15
15
|
readonly error?: boolean | undefined;
|
|
16
16
|
readonly focused?: boolean | undefined;
|
|
17
17
|
} & React.RefAttributes<HTMLDivElement>>;
|