@ctlyst.id/internal-ui 2.0.2 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/field/components/field.d.ts +2 -0
- package/dist/components/form/__stories__/input.stories.d.ts +1 -0
- package/dist/components/form/components/input-element.d.ts +2 -0
- package/dist/components/form/components/input-field.d.ts +0 -2
- package/dist/components/form/index.d.ts +2 -0
- package/dist/internal-ui.cjs.development.js +66 -54
- package/dist/internal-ui.cjs.development.js.map +1 -1
- package/dist/internal-ui.cjs.production.min.js +9 -9
- package/dist/internal-ui.cjs.production.min.js.map +1 -1
- package/dist/internal-ui.esm.js +55 -57
- package/dist/internal-ui.esm.js.map +1 -1
- package/package.json +2 -2
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { FormControlProps } from '@chakra-ui/react';
|
1
2
|
import type { FC, PropsWithChildren, ReactNode } from 'react';
|
2
3
|
export interface Props {
|
3
4
|
label?: string | ReactNode;
|
@@ -7,6 +8,7 @@ export interface Props {
|
|
7
8
|
leftHelperText?: string | ReactNode;
|
8
9
|
rightHelperText?: string | ReactNode;
|
9
10
|
isRequired?: boolean;
|
11
|
+
boxProps?: FormControlProps;
|
10
12
|
}
|
11
13
|
export declare type FieldProps<T = unknown> = Props & T;
|
12
14
|
declare const Field: FC<PropsWithChildren<Props>>;
|
@@ -11,4 +11,5 @@ export declare const Default: () => JSX.Element;
|
|
11
11
|
export declare const Variant: () => JSX.Element;
|
12
12
|
export declare const PasswordField: () => JSX.Element;
|
13
13
|
export declare const WithClear: () => JSX.Element;
|
14
|
+
export declare const WithElement: () => JSX.Element;
|
14
15
|
export declare const WithAddOn: () => JSX.Element;
|
@@ -5,8 +5,6 @@ import type { FieldProps } from '../../field/components/field';
|
|
5
5
|
export interface InputFieldProps extends ChakraInputProps, FieldProps {
|
6
6
|
addOnLeft?: ReactNode;
|
7
7
|
addOnRight?: ReactNode;
|
8
|
-
elementLeft?: ReactNode;
|
9
|
-
elementRight?: ReactNode;
|
10
8
|
withClear?: boolean;
|
11
9
|
isLoading?: boolean;
|
12
10
|
onClear?: () => void;
|
@@ -229,7 +229,6 @@ CheckboxComponent.defaultProps = {
|
|
229
229
|
errorText: ''
|
230
230
|
};
|
231
231
|
|
232
|
-
/* eslint-disable no-nested-ternary */
|
233
232
|
const Field = props => {
|
234
233
|
const {
|
235
234
|
label,
|
@@ -239,7 +238,8 @@ const Field = props => {
|
|
239
238
|
rightHelperText,
|
240
239
|
isRequired,
|
241
240
|
children,
|
242
|
-
isSuccess
|
241
|
+
isSuccess,
|
242
|
+
boxProps = {}
|
243
243
|
} = props;
|
244
244
|
const getHelperColor = () => {
|
245
245
|
if (isError) return 'danger.500';
|
@@ -252,9 +252,9 @@ const Field = props => {
|
|
252
252
|
};
|
253
253
|
const helperColor = getHelperColor();
|
254
254
|
const justifyHelper = getJustifyContentHelper();
|
255
|
-
return /*#__PURE__*/React__default.createElement(react.FormControl, {
|
255
|
+
return /*#__PURE__*/React__default.createElement(react.FormControl, Object.assign({
|
256
256
|
isInvalid: isError
|
257
|
-
}, label && (typeof label === 'string' ? /*#__PURE__*/React__default.createElement(react.FormLabel, {
|
257
|
+
}, boxProps), label && (typeof label === 'string' ? /*#__PURE__*/React__default.createElement(react.FormLabel, {
|
258
258
|
mb: 1,
|
259
259
|
fontSize: "text.sm",
|
260
260
|
requiredIndicator: undefined
|
@@ -267,19 +267,19 @@ const Field = props => {
|
|
267
267
|
display: "flex",
|
268
268
|
width: "full",
|
269
269
|
justifyContent: justifyHelper
|
270
|
-
}, !isError ? leftHelperText && /*#__PURE__*/React__default.createElement(react.FormHelperText, {
|
270
|
+
}, !isError ? leftHelperText && (typeof leftHelperText === 'string' ? /*#__PURE__*/React__default.createElement(react.FormHelperText, {
|
271
271
|
fontSize: "text.xs",
|
272
272
|
color: helperColor,
|
273
273
|
mt: 1
|
274
|
-
}, leftHelperText) : typeof errorMessage === 'string' ? /*#__PURE__*/React__default.createElement(react.FormErrorMessage, {
|
274
|
+
}, leftHelperText) : leftHelperText) : typeof errorMessage === 'string' ? /*#__PURE__*/React__default.createElement(react.FormErrorMessage, {
|
275
275
|
fontSize: "text.xs",
|
276
276
|
color: "danger.500",
|
277
277
|
mt: 1
|
278
|
-
}, errorMessage) : errorMessage, rightHelperText && /*#__PURE__*/React__default.createElement(react.FormHelperText, {
|
278
|
+
}, errorMessage) : errorMessage, rightHelperText && (typeof rightHelperText === 'string' ? /*#__PURE__*/React__default.createElement(react.FormHelperText, {
|
279
279
|
fontSize: "text.xs",
|
280
280
|
color: helperColor,
|
281
281
|
mt: 1
|
282
|
-
}, rightHelperText)));
|
282
|
+
}, rightHelperText) : rightHelperText)));
|
283
283
|
};
|
284
284
|
Field.defaultProps = {
|
285
285
|
label: '',
|
@@ -288,7 +288,8 @@ Field.defaultProps = {
|
|
288
288
|
errorMessage: undefined,
|
289
289
|
leftHelperText: undefined,
|
290
290
|
rightHelperText: undefined,
|
291
|
-
isRequired: false
|
291
|
+
isRequired: false,
|
292
|
+
boxProps: {}
|
292
293
|
};
|
293
294
|
|
294
295
|
function CheckboxGroupComponent(props) {
|
@@ -480,6 +481,41 @@ DataTable.defaultProps = {
|
|
480
481
|
sortingState: []
|
481
482
|
};
|
482
483
|
|
484
|
+
const getProperties = props => {
|
485
|
+
const {
|
486
|
+
isError,
|
487
|
+
isDisabled,
|
488
|
+
isSuccess
|
489
|
+
} = props;
|
490
|
+
let outlineColor = 'neutral.400';
|
491
|
+
let focusColor = 'primary.500';
|
492
|
+
if (isError || isDisabled || isSuccess) {
|
493
|
+
if (isError) outlineColor = 'danger.500';else if (isSuccess) outlineColor = 'success.500';
|
494
|
+
focusColor = outlineColor;
|
495
|
+
}
|
496
|
+
return {
|
497
|
+
outlineColor,
|
498
|
+
focusColor
|
499
|
+
};
|
500
|
+
};
|
501
|
+
const getWrapperStyle = props => {
|
502
|
+
const {
|
503
|
+
outlineColor,
|
504
|
+
focusColor
|
505
|
+
} = getProperties(props);
|
506
|
+
const style = {
|
507
|
+
border: '1px solid',
|
508
|
+
borderColor: outlineColor,
|
509
|
+
borderRadius: 'md',
|
510
|
+
transition: 'all 0.15s',
|
511
|
+
boxShadow: 'none',
|
512
|
+
_focusWithin: {
|
513
|
+
borderColor: focusColor
|
514
|
+
}
|
515
|
+
};
|
516
|
+
return react.defineStyle(style);
|
517
|
+
};
|
518
|
+
|
483
519
|
const Styles = () => {
|
484
520
|
const {
|
485
521
|
colorMode
|
@@ -1351,6 +1387,7 @@ const Datepicker = ({
|
|
1351
1387
|
var _props$dateFormat;
|
1352
1388
|
const selected = value ? new Date(value) : undefined;
|
1353
1389
|
const dateFormat = ((_props$dateFormat = props.dateFormat) !== null && _props$dateFormat !== void 0 ? _props$dateFormat : withTime) ? 'yyyy-MM-dd HH:mm' : 'yyyy-MM-dd';
|
1390
|
+
const wrapperStyle = getWrapperStyle({});
|
1354
1391
|
const getTimeProps = () => {
|
1355
1392
|
if (!withTime) return {};
|
1356
1393
|
return {
|
@@ -1363,9 +1400,9 @@ const Datepicker = ({
|
|
1363
1400
|
id: id,
|
1364
1401
|
name: name,
|
1365
1402
|
selected: selected,
|
1366
|
-
customInput: /*#__PURE__*/React__default.createElement(react.Input, {
|
1403
|
+
customInput: /*#__PURE__*/React__default.createElement(react.Input, Object.assign({
|
1367
1404
|
autoComplete: "off"
|
1368
|
-
}),
|
1405
|
+
}, wrapperStyle)),
|
1369
1406
|
dateFormat: dateFormat,
|
1370
1407
|
showPopperArrow: false,
|
1371
1408
|
calendarClassName: classnames({
|
@@ -1914,45 +1951,10 @@ MultiDatePickerMonth.defaultProps = {
|
|
1914
1951
|
isError: false
|
1915
1952
|
};
|
1916
1953
|
|
1917
|
-
const getProperties = props => {
|
1918
|
-
const {
|
1919
|
-
isError,
|
1920
|
-
isDisabled,
|
1921
|
-
isSuccess
|
1922
|
-
} = props;
|
1923
|
-
let outlineColor = 'neutral.400';
|
1924
|
-
let focusColor = 'primary.500';
|
1925
|
-
if (isError || isDisabled || isSuccess) {
|
1926
|
-
if (isError) outlineColor = 'danger.500';else if (isSuccess) outlineColor = 'success.500';
|
1927
|
-
focusColor = outlineColor;
|
1928
|
-
}
|
1929
|
-
return {
|
1930
|
-
outlineColor,
|
1931
|
-
focusColor
|
1932
|
-
};
|
1933
|
-
};
|
1934
|
-
const getWrapperStyle = props => {
|
1935
|
-
const {
|
1936
|
-
outlineColor,
|
1937
|
-
focusColor
|
1938
|
-
} = getProperties(props);
|
1939
|
-
const style = {
|
1940
|
-
border: '1px solid',
|
1941
|
-
borderColor: outlineColor,
|
1942
|
-
borderRadius: 'md',
|
1943
|
-
transition: 'all 0.15s',
|
1944
|
-
boxShadow: 'none',
|
1945
|
-
_focusWithin: {
|
1946
|
-
borderColor: focusColor
|
1947
|
-
}
|
1948
|
-
};
|
1949
|
-
return react.defineStyle(style);
|
1950
|
-
};
|
1951
|
-
|
1952
1954
|
const InputAddonLeft = ({
|
1953
1955
|
children
|
1954
1956
|
}) => {
|
1955
|
-
return /*#__PURE__*/React__default.createElement(react.
|
1957
|
+
return /*#__PURE__*/React__default.createElement(react.InputLeftAddon, {
|
1956
1958
|
borderLeftRadius: "md",
|
1957
1959
|
backgroundColor: "neutral.200",
|
1958
1960
|
px: 3,
|
@@ -1962,7 +1964,7 @@ const InputAddonLeft = ({
|
|
1962
1964
|
const InputAddonRight = ({
|
1963
1965
|
children
|
1964
1966
|
}) => {
|
1965
|
-
return /*#__PURE__*/React__default.createElement(react.
|
1967
|
+
return /*#__PURE__*/React__default.createElement(react.InputRightAddon, {
|
1966
1968
|
borderRightRadius: "md",
|
1967
1969
|
backgroundColor: "neutral.200",
|
1968
1970
|
px: 3,
|
@@ -1976,8 +1978,6 @@ const InputField = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
1976
1978
|
type,
|
1977
1979
|
addOnLeft,
|
1978
1980
|
addOnRight,
|
1979
|
-
elementLeft,
|
1980
|
-
elementRight,
|
1981
1981
|
size,
|
1982
1982
|
isRequired,
|
1983
1983
|
label,
|
@@ -2021,7 +2021,7 @@ const InputField = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
2021
2021
|
borderRadius: "md",
|
2022
2022
|
backgroundColor: isDisabled ? 'neutral.300' : 'white.high',
|
2023
2023
|
cursor: isDisabled ? 'not-allowed' : 'default'
|
2024
|
-
}, addOnLeft
|
2024
|
+
}, addOnLeft, /*#__PURE__*/React__default.createElement(react.Input, Object.assign({
|
2025
2025
|
ref: ref,
|
2026
2026
|
type: inputType,
|
2027
2027
|
value: value,
|
@@ -2068,13 +2068,11 @@ const InputField = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
2068
2068
|
color: iconColor
|
2069
2069
|
})), isLoading && /*#__PURE__*/React__default.createElement(Loader, {
|
2070
2070
|
size: "sm"
|
2071
|
-
})),
|
2071
|
+
})), addOnRight)));
|
2072
2072
|
});
|
2073
2073
|
InputField.defaultProps = {
|
2074
2074
|
addOnLeft: undefined,
|
2075
2075
|
addOnRight: undefined,
|
2076
|
-
elementLeft: undefined,
|
2077
|
-
elementRight: undefined,
|
2078
2076
|
withClear: undefined,
|
2079
2077
|
isLoading: undefined,
|
2080
2078
|
onClear: undefined
|
@@ -4386,6 +4384,18 @@ Object.defineProperty(exports, 'DrawerOverlay', {
|
|
4386
4384
|
return react.ModalOverlay;
|
4387
4385
|
}
|
4388
4386
|
});
|
4387
|
+
Object.defineProperty(exports, 'InputElementLeft', {
|
4388
|
+
enumerable: true,
|
4389
|
+
get: function () {
|
4390
|
+
return react.InputLeftElement;
|
4391
|
+
}
|
4392
|
+
});
|
4393
|
+
Object.defineProperty(exports, 'InputElementRight', {
|
4394
|
+
enumerable: true,
|
4395
|
+
get: function () {
|
4396
|
+
return react.InputRightElement;
|
4397
|
+
}
|
4398
|
+
});
|
4389
4399
|
Object.defineProperty(exports, 'Modal', {
|
4390
4400
|
enumerable: true,
|
4391
4401
|
get: function () {
|
@@ -4551,6 +4561,8 @@ exports.Field = Field;
|
|
4551
4561
|
exports.Flex = react.Flex;
|
4552
4562
|
exports.Grid = react.Grid;
|
4553
4563
|
exports.Header = Header;
|
4564
|
+
exports.InputAddonLeft = InputAddonLeft;
|
4565
|
+
exports.InputAddonRight = InputAddonRight;
|
4554
4566
|
exports.InputField = InputField;
|
4555
4567
|
exports.Loader = Loader;
|
4556
4568
|
exports.MainMenu = Navigation;
|