@ctlyst.id/internal-ui 1.0.4-canary.3 → 1.0.4-canary.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  import type { GroupBase } from 'react-select';
2
2
  import type { AsyncCreatableProps } from 'react-select/async-creatable';
3
- export declare type SelectAsyncCreatableProps<Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> = AsyncCreatableProps<Option, IsMulti, Group>;
4
- export default function SelectAsyncCreatable<Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ styles, ...rest }: SelectAsyncCreatableProps<Option, IsMulti, Group>): JSX.Element;
3
+ import type { ExtendedSelectProps } from './types/select.types';
4
+ export declare type SelectAsyncCreatableProps<Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> = AsyncCreatableProps<Option, IsMulti, Group> & ExtendedSelectProps;
5
+ export default function SelectAsyncCreatable<Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ styles, isError, ...rest }: SelectAsyncCreatableProps<Option, IsMulti, Group>): JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import type { GroupBase } from 'react-select';
2
2
  import type { AsyncPaginateProps } from 'react-select-async-paginate';
3
- export declare type SelectAsyncProps<OptionType = unknown, Group extends GroupBase<OptionType> = GroupBase<OptionType>, Additional = unknown, IsMulti extends boolean = false> = AsyncPaginateProps<OptionType, Group, Additional, IsMulti>;
4
- declare function SelectAsync<OptionType, Group extends GroupBase<OptionType>, Additional, IsMulti extends boolean = false>({ styles, ...rest }: SelectAsyncProps<OptionType, Group, Additional, IsMulti>): JSX.Element;
3
+ import type { ExtendedSelectProps } from './types/select.types';
4
+ export declare type SelectAsyncProps<OptionType = unknown, Group extends GroupBase<OptionType> = GroupBase<OptionType>, Additional = unknown, IsMulti extends boolean = false> = AsyncPaginateProps<OptionType, Group, Additional, IsMulti> & ExtendedSelectProps;
5
+ declare function SelectAsync<OptionType, Group extends GroupBase<OptionType>, Additional, IsMulti extends boolean = false>({ styles, isError, ...rest }: SelectAsyncProps<OptionType, Group, Additional, IsMulti>): JSX.Element;
5
6
  export default SelectAsync;
@@ -1,4 +1,5 @@
1
1
  import type { GroupBase } from 'react-select';
2
2
  import type { CreatableProps } from 'react-select/creatable';
3
- export declare type SelectCreatableProps<Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> = CreatableProps<Option, IsMulti, Group>;
4
- export default function SelectCreatable<Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ styles, ...rest }: SelectCreatableProps<Option, IsMulti, Group>): JSX.Element;
3
+ import type { ExtendedSelectProps } from './types/select.types';
4
+ export declare type SelectCreatableProps<Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> = CreatableProps<Option, IsMulti, Group> & ExtendedSelectProps;
5
+ export default function SelectCreatable<Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ styles, isError, ...rest }: SelectCreatableProps<Option, IsMulti, Group>): JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { FC, PropsWithChildren } from 'react';
2
+ interface SelectWrapperProps {
3
+ isError?: boolean;
4
+ }
5
+ declare const SelectWrapper: FC<PropsWithChildren<SelectWrapperProps>>;
6
+ export default SelectWrapper;
@@ -1,4 +1,5 @@
1
1
  import type { GroupBase, Props as ReactSelectProps } from 'react-select';
2
- export declare type SelectProps<Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>> = ReactSelectProps<Option, IsMulti, Group>;
3
- declare function Select<OptionType, Group extends GroupBase<OptionType>, IsMulti extends boolean = false>({ styles, ...rest }: SelectProps<OptionType, IsMulti, Group>): JSX.Element;
2
+ import type { ExtendedSelectProps } from './types/select.types';
3
+ export declare type SelectProps<Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>> = ReactSelectProps<Option, IsMulti, Group> & ExtendedSelectProps;
4
+ declare function Select<OptionType, Group extends GroupBase<OptionType>, IsMulti extends boolean = false>({ styles, isError, ...rest }: SelectProps<OptionType, IsMulti, Group>): JSX.Element;
4
5
  export default Select;
@@ -0,0 +1,3 @@
1
+ export declare type ExtendedSelectProps = {
2
+ isError?: boolean;
3
+ };
@@ -1,6 +1,6 @@
1
1
  import type { ColorMode } from '@chakra-ui/system';
2
2
  import type { GroupBase, StylesConfig, Theme } from 'react-select';
3
- export declare function selectStyles<OptionType = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<OptionType> = GroupBase<OptionType>>(colorMode?: ColorMode): StylesConfig<OptionType, IsMulti, Group> | undefined;
3
+ export declare function selectStyles<OptionType = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<OptionType> = GroupBase<OptionType>>(colorMode: ColorMode, isError: boolean): StylesConfig<OptionType, IsMulti, Group> | undefined;
4
4
  export declare const themeSelect: (theme: Theme) => {
5
5
  colors: {
6
6
  primary: string;
@@ -2366,23 +2366,46 @@ PaginationFilter.defaultProps = {
2366
2366
  label: undefined
2367
2367
  };
2368
2368
 
2369
+ const SelectWrapper = ({
2370
+ children,
2371
+ isError = false
2372
+ }) => {
2373
+ return /*#__PURE__*/React__default.createElement(react.Box, {
2374
+ css: react$1.css`
2375
+ .react-select__control {
2376
+ border-color: ${isError ? colors.danger['500'] : colors.neutral['400']} !important;
2377
+ }
2378
+
2379
+ .react-select__control:hover {
2380
+ border-color: ${isError ? colors.danger['500'] : colors.primary['500']} !important;
2381
+ }
2382
+ `
2383
+ }, children);
2384
+ };
2385
+ SelectWrapper.defaultProps = {
2386
+ isError: false
2387
+ };
2388
+
2369
2389
  const styleMd = textStyles.text.sm;
2370
2390
  const selectStyle = {
2371
2391
  fontSize: styleMd.fontSize,
2372
2392
  lineHeight: styleMd.lineHeight,
2373
2393
  letterSpacing: 0
2374
2394
  };
2375
- function selectStyles(colorMode) {
2395
+ function selectStyles(colorMode, isError) {
2396
+ const boxShadowStyle = isError ? `0 0 0 1px ${colors.danger['500']}` : `0 0 0 1px ${colors.primary['500']}`;
2376
2397
  return {
2377
- control: base => colorMode === 'dark' ? {
2398
+ control: (base, state) => colorMode === 'dark' ? {
2378
2399
  ...base,
2379
2400
  ...selectStyle,
2380
2401
  background: 'transparent',
2381
2402
  color: colors.primary['300'],
2382
- borderColor: colors.secondary['500']
2403
+ borderColor: colors.secondary['500'],
2404
+ boxShadow: state.isFocused ? boxShadowStyle : `inherit`
2383
2405
  } : {
2384
2406
  ...base,
2385
- ...selectStyle
2407
+ ...selectStyle,
2408
+ boxShadow: state.isFocused ? boxShadowStyle : colors.neutral['500']
2386
2409
  },
2387
2410
  option: (base, {
2388
2411
  isSelected
@@ -2452,68 +2475,88 @@ const themeSelect = theme => {
2452
2475
  };
2453
2476
  };
2454
2477
 
2478
+ /* eslint-disable react/require-default-props */
2455
2479
  function Select({
2456
2480
  styles,
2481
+ isError = false,
2457
2482
  ...rest
2458
2483
  }) {
2459
2484
  const {
2460
2485
  colorMode
2461
2486
  } = system.useColorMode();
2462
- return /*#__PURE__*/React__default.createElement(ReactSelect, Object.assign({}, rest, {
2487
+ return /*#__PURE__*/React__default.createElement(SelectWrapper, {
2488
+ isError: isError
2489
+ }, /*#__PURE__*/React__default.createElement(ReactSelect, Object.assign({
2490
+ classNamePrefix: "react-select"
2491
+ }, rest, {
2463
2492
  styles: {
2464
- ...selectStyles(colorMode),
2465
- ...styles
2493
+ ...selectStyles(colorMode, isError)
2466
2494
  },
2467
2495
  theme: themeSelect
2468
- }));
2496
+ })));
2469
2497
  }
2470
2498
 
2471
2499
  function SelectAsync({
2472
2500
  styles,
2501
+ isError = false,
2473
2502
  ...rest
2474
2503
  }) {
2475
2504
  const {
2476
2505
  colorMode
2477
2506
  } = system.useColorMode();
2478
- return /*#__PURE__*/React__default.createElement(reactSelectAsyncPaginate.AsyncPaginate, Object.assign({}, rest, {
2507
+ return /*#__PURE__*/React__default.createElement(SelectWrapper, {
2508
+ isError: isError
2509
+ }, /*#__PURE__*/React__default.createElement(reactSelectAsyncPaginate.AsyncPaginate, Object.assign({
2510
+ classNamePrefix: "react-select"
2511
+ }, rest, {
2479
2512
  styles: {
2480
- ...selectStyles(colorMode),
2513
+ ...selectStyles(colorMode, isError),
2481
2514
  ...styles
2482
2515
  },
2483
2516
  theme: themeSelect
2484
- }));
2517
+ })));
2485
2518
  }
2486
2519
 
2487
2520
  function SelectAsyncCreatable({
2488
2521
  styles,
2522
+ isError = false,
2489
2523
  ...rest
2490
2524
  }) {
2491
2525
  const {
2492
2526
  colorMode
2493
2527
  } = system.useColorMode();
2494
- return /*#__PURE__*/React__default.createElement(ReactSelectAsyncCreatable, Object.assign({}, rest, {
2528
+ return /*#__PURE__*/React__default.createElement(SelectWrapper, {
2529
+ isError: isError
2530
+ }, /*#__PURE__*/React__default.createElement(ReactSelectAsyncCreatable, Object.assign({
2531
+ classNamePrefix: "react-select"
2532
+ }, rest, {
2495
2533
  styles: {
2496
- ...selectStyles(colorMode),
2534
+ ...selectStyles(colorMode, isError),
2497
2535
  ...styles
2498
2536
  },
2499
2537
  theme: themeSelect
2500
- }));
2538
+ })));
2501
2539
  }
2502
2540
 
2503
2541
  function SelectCreatable({
2504
2542
  styles,
2543
+ isError = false,
2505
2544
  ...rest
2506
2545
  }) {
2507
2546
  const {
2508
2547
  colorMode
2509
2548
  } = system.useColorMode();
2510
- return /*#__PURE__*/React__default.createElement(ReactSelectCreatable, Object.assign({}, rest, {
2549
+ return /*#__PURE__*/React__default.createElement(SelectWrapper, {
2550
+ isError: isError
2551
+ }, /*#__PURE__*/React__default.createElement(ReactSelectCreatable, Object.assign({
2552
+ classNamePrefix: "react-select"
2553
+ }, rest, {
2511
2554
  styles: {
2512
- ...selectStyles(colorMode),
2555
+ ...selectStyles(colorMode, isError),
2513
2556
  ...styles
2514
2557
  },
2515
2558
  theme: themeSelect
2516
- }));
2559
+ })));
2517
2560
  }
2518
2561
 
2519
2562
  const Tab = /*#__PURE__*/react.forwardRef((props, ref) => {