@dreamcommerce/aurora 3.0.0-254 → 3.0.0-255

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.
Files changed (43) hide show
  1. package/build/cjs/external/fast-equals/dist/esm/index.mjs.js +619 -0
  2. package/build/cjs/external/fast-equals/dist/esm/index.mjs.js.map +1 -0
  3. package/build/cjs/packages/aurora/src/components/controls/select_control/select_control.js +3 -3
  4. package/build/cjs/packages/aurora/src/components/select/components/select_content.js +33 -43
  5. package/build/cjs/packages/aurora/src/components/select/components/select_content.js.map +1 -1
  6. package/build/cjs/packages/aurora/src/components/select/components/select_group_label.js +3 -3
  7. package/build/cjs/packages/aurora/src/components/select/components/select_item.js +5 -7
  8. package/build/cjs/packages/aurora/src/components/select/components/select_item.js.map +1 -1
  9. package/build/cjs/packages/aurora/src/components/select/components/select_search.js +61 -0
  10. package/build/cjs/packages/aurora/src/components/select/components/select_search.js.map +1 -0
  11. package/build/cjs/packages/aurora/src/components/select/components/select_trigger.js +1 -1
  12. package/build/cjs/packages/aurora/src/components/select/select.js +43 -76
  13. package/build/cjs/packages/aurora/src/components/select/select.js.map +1 -1
  14. package/build/cjs/packages/aurora/src/components/select/select_utils.js +33 -0
  15. package/build/cjs/packages/aurora/src/components/select/select_utils.js.map +1 -0
  16. package/build/esm/external/fast-equals/dist/esm/index.mjs.js +606 -0
  17. package/build/esm/external/fast-equals/dist/esm/index.mjs.js.map +1 -0
  18. package/build/esm/packages/aurora/src/components/controls/select_control/select_control.js +3 -3
  19. package/build/esm/packages/aurora/src/components/select/components/select_content.js +37 -47
  20. package/build/esm/packages/aurora/src/components/select/components/select_content.js.map +1 -1
  21. package/build/esm/packages/aurora/src/components/select/components/select_group_label.d.ts +2 -2
  22. package/build/esm/packages/aurora/src/components/select/components/select_group_label.js +3 -3
  23. package/build/esm/packages/aurora/src/components/select/components/select_item.js +6 -8
  24. package/build/esm/packages/aurora/src/components/select/components/select_item.js.map +1 -1
  25. package/build/esm/packages/aurora/src/components/select/components/select_search.d.ts +3 -0
  26. package/build/esm/packages/aurora/src/components/select/components/select_search.js +53 -0
  27. package/build/esm/packages/aurora/src/components/select/components/select_search.js.map +1 -0
  28. package/build/esm/packages/aurora/src/components/select/components/select_trigger.js +1 -1
  29. package/build/esm/packages/aurora/src/components/select/select.d.ts +1 -1
  30. package/build/esm/packages/aurora/src/components/select/select.js +44 -77
  31. package/build/esm/packages/aurora/src/components/select/select.js.map +1 -1
  32. package/build/esm/packages/aurora/src/components/select/select_types.d.ts +14 -7
  33. package/build/esm/packages/aurora/src/components/select/select_types.js +1 -0
  34. package/build/esm/packages/aurora/src/components/select/select_types.js.map +1 -1
  35. package/build/esm/packages/aurora/src/components/select/select_utils.d.ts +5 -0
  36. package/build/esm/packages/aurora/src/components/select/select_utils.js +29 -0
  37. package/build/{cjs/packages/aurora/src/components/select/components/select_value.js.map → esm/packages/aurora/src/components/select/select_utils.js.map} +1 -1
  38. package/build/index.css +1 -1
  39. package/package.json +2 -1
  40. package/build/cjs/packages/aurora/src/components/select/components/select_value.js +0 -10
  41. package/build/esm/packages/aurora/src/components/select/components/select_value.d.ts +0 -3
  42. package/build/esm/packages/aurora/src/components/select/components/select_value.js +0 -6
  43. package/build/esm/packages/aurora/src/components/select/components/select_value.js.map +0 -1
@@ -1,89 +1,79 @@
1
- import React, { useRef, useState } from 'react';
2
- import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, defineProperty as _defineProperty } from '../../../../../../_virtual/_rollupPluginBabelHelpers.js';
1
+ import React from 'react';
2
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2, defineProperty as _defineProperty } from '../../../../../../_virtual/_rollupPluginBabelHelpers.js';
3
3
  import { cn } from '../../../utilities/cn.js';
4
- import { Input } from '../../input/input.js';
5
- import { Portal, Content, Viewport } from '@radix-ui/react-select';
6
- import { Root, Viewport as Viewport$1, Scrollbar, Thumb } from '../../../../../../external/@radix-ui/react-scroll-area/dist/index.mjs.js';
7
- import { SearchLineIcon } from '../../../assets/icons/search_icon.js';
4
+ import { Portal, Content, Viewport as Viewport$1 } from '@radix-ui/react-select';
5
+ import { Root, Viewport, Scrollbar, Thumb } from '../../../../../../external/@radix-ui/react-scroll-area/dist/index.mjs.js';
8
6
  import { SelectGroupLabel } from './select_group_label.js';
9
7
  import { SelectItem } from './select_item.js';
8
+ import { SelectSearch } from './select_search.js';
9
+ import { SelectUtils } from '../select_utils.js';
10
10
 
11
- var _excluded = ["className", "options", "selectedValue", "hasSearch", "searchPlaceholder", "filterTerm", "setFilterTerm", "innerAdditionalContent", "triggerWidth", "position", "onScroll"];
11
+ var _excluded = ["className", "options", "hasSearch", "searchPlaceholder", "search", "onSearch", "innerAdditionalContent", "position", "onScroll", "enableLocalSearch", "localSearchNotFoundContent"];
12
12
  var SelectContent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
13
13
  var className = _ref.className,
14
14
  options = _ref.options,
15
- selectedValue = _ref.selectedValue,
16
15
  hasSearch = _ref.hasSearch,
17
16
  searchPlaceholder = _ref.searchPlaceholder,
18
- filterTerm = _ref.filterTerm,
19
- setFilterTerm = _ref.setFilterTerm,
17
+ search = _ref.search,
18
+ onSearch = _ref.onSearch,
20
19
  innerAdditionalContent = _ref.innerAdditionalContent,
21
- triggerWidth = _ref.triggerWidth,
22
20
  _ref$position = _ref.position,
23
21
  position = _ref$position === void 0 ? 'popper' : _ref$position,
24
22
  onScroll = _ref.onScroll,
23
+ enableLocalSearch = _ref.enableLocalSearch,
24
+ localSearchNotFoundContent = _ref.localSearchNotFoundContent,
25
25
  props = _objectWithoutProperties(_ref, _excluded);
26
- var inputRef = useRef(null);
27
- var _useState = useState(false),
28
- _useState2 = _slicedToArray(_useState, 2),
29
- isHovered = _useState2[0],
30
- setIsHovered = _useState2[1];
26
+ var localSearchVisibleItems = 0;
31
27
  return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(Content, _objectSpread2({
32
28
  ref: ref,
33
- style: {
34
- width: triggerWidth ? "".concat(triggerWidth, "px") : 'auto'
35
- },
36
- className: cn('aurora-relative aurora-z-[1000] aurora-max-h-96 aurora-min-w-[fit-content] aurora-overflow-y-hidden aurora-rounded-8 aurora-border aurora-bg-neutral-0 aurora-text-s aurora-shadow-m data-[state=open]:aurora-animate-in data-[state=closed]:aurora-animate-out data-[state=closed]:aurora-fade-out-0 data-[state=open]:aurora-fade-in-0 data-[state=closed]:aurora-zoom-out-95 data-[state=open]:aurora-zoom-in-95 data-[side=bottom]:aurora-slide-in-from-top-2 data-[side=left]:aurora-slide-in-from-right-2 data-[side=right]:aurora-slide-in-from-left-2 data-[side=top]:aurora-slide-in-from-bottom-2 aurora-p-1 js__aurora-select-dropdown', position === 'popper' && 'data-[side=bottom]:aurora-translate-y-1 data-[side=left]:-aurora-translate-x-1 data-[side=right]:aurora-translate-x-1 data-[side=top]:-aurora-translate-y-1', className),
37
- position: position,
38
- onMouseEnter: function onMouseEnter() {
39
- return setIsHovered(true);
40
- },
41
- onMouseLeave: function onMouseLeave() {
42
- return setIsHovered(false);
43
- }
29
+ className: cn('aurora-w-[--radix-select-trigger-width] aurora-relative aurora-z-[1000] aurora-max-h-96 aurora-min-w-[fit-content] aurora-overflow-y-hidden aurora-rounded-8 aurora-border aurora-bg-neutral-0 aurora-text-s aurora-shadow-m data-[state=open]:aurora-animate-in data-[state=closed]:aurora-animate-out data-[state=closed]:aurora-fade-out-0 data-[state=open]:aurora-fade-in-0 data-[state=closed]:aurora-zoom-out-95 data-[state=open]:aurora-zoom-in-95 data-[side=bottom]:aurora-slide-in-from-top-2 data-[side=left]:aurora-slide-in-from-right-2 data-[side=right]:aurora-slide-in-from-left-2 data-[side=top]:aurora-slide-in-from-bottom-2 aurora-p-1 js__aurora-select-dropdown aurora-group', position === 'popper' && 'data-[side=bottom]:aurora-translate-y-1 data-[side=left]:-aurora-translate-x-1 data-[side=right]:aurora-translate-x-1 data-[side=top]:-aurora-translate-y-1', className),
30
+ position: position
44
31
  }, props), /*#__PURE__*/React.createElement(Root, {
45
32
  type: "auto",
46
33
  className: "aurora-w-full aurora-max-h-60 relative"
47
34
  }, /*#__PURE__*/React.createElement(Viewport, {
48
- asChild: true
49
- }, /*#__PURE__*/React.createElement(Viewport$1, {
50
35
  className: cn('aurora-p-1 aurora-max-h-60 aurora-w-full'),
51
36
  onScroll: onScroll
52
37
  }, hasSearch && (/*#__PURE__*/React.createElement("div", {
53
38
  className: "aurora-p-2"
54
- }, /*#__PURE__*/React.createElement(Input, {
55
- type: "text",
56
- preElement: /*#__PURE__*/React.createElement(SearchLineIcon, {
57
- className: "aurora-h-4 aurora-w-4 aurora-text-inverse-subtle-light"
58
- }),
59
- value: filterTerm,
60
- tabIndex: 0,
39
+ }, /*#__PURE__*/React.createElement(SelectSearch, {
40
+ value: search,
61
41
  onChange: function onChange(e) {
62
42
  e.stopPropagation();
63
- setFilterTerm === null || setFilterTerm === void 0 ? void 0 : setFilterTerm(e.target.value);
43
+ onSearch === null || onSearch === void 0 ? void 0 : onSearch(e.target.value);
64
44
  },
65
45
  onKeyDown: function onKeyDown(e) {
66
46
  e.stopPropagation();
67
47
  },
68
48
  placeholder: searchPlaceholder,
69
- ref: inputRef
70
- }))), options === null || options === void 0 ? void 0 : options.map(function (option, index) {
71
- var isSelected = selectedValue ? option.value === selectedValue : false;
49
+ options: options
50
+ }))), /*#__PURE__*/React.createElement(Viewport$1, null, options === null || options === void 0 ? void 0 : options.map(function (option, index) {
51
+ var visible = true;
52
+ if (enableLocalSearch && hasSearch && search && !option.isHeader) {
53
+ visible = SelectUtils.localSearchIsOptionVisible(option, search);
54
+ if (visible) localSearchVisibleItems++;
55
+ }
56
+ if (enableLocalSearch && hasSearch && search && option.isHeader) {
57
+ visible = SelectUtils.localSearchIsHeaderVisible(search, options, index);
58
+ }
72
59
  return option.isHeader ? (/*#__PURE__*/React.createElement(SelectGroupLabel, {
73
- key: "select-label-".concat(option.text, "-").concat(index)
60
+ key: "select-label-".concat(option.text, "-").concat(index),
61
+ className: cn(!visible && 'aurora-hidden')
74
62
  }, option.text)) : (/*#__PURE__*/React.createElement(SelectItem, {
75
63
  key: "select-item-".concat(option.value, "-").concat(index),
76
- value: "".concat(option.value, "-").concat(index),
77
- isSelected: isSelected,
64
+ value: option.value,
78
65
  isDisabled: option.isDisabled,
79
66
  isReadonly: option.isReadonly,
80
- additionalInfo: option.additionalInfo
67
+ additionalInfo: option.additionalInfo,
68
+ className: cn(!visible && 'aurora-hidden')
81
69
  }, option.text));
82
- }), innerAdditionalContent && /*#__PURE__*/React.createElement("div", {
70
+ })), enableLocalSearch && !!localSearchNotFoundContent && !!search && !localSearchVisibleItems && (/*#__PURE__*/React.createElement("div", {
71
+ className: "aurora-p-2"
72
+ }, localSearchNotFoundContent)), innerAdditionalContent && /*#__PURE__*/React.createElement("div", {
83
73
  className: "aurora-p-2"
84
- }, innerAdditionalContent))), /*#__PURE__*/React.createElement(Scrollbar, {
74
+ }, innerAdditionalContent)), /*#__PURE__*/React.createElement(Scrollbar, {
85
75
  orientation: "vertical",
86
- className: cn('aurora-w-2 aurora-absolute aurora-right-0 aurora-top-0 aurora-bottom-0 aurora-py-1 aurora-pr-[2px] aurora-transition-opacity aurora-duration-200', _defineProperty(_defineProperty(_defineProperty({}, 'aurora-pt-16', hasSearch), 'aurora-opacity-75', isHovered), 'aurora-opacity-0', !isHovered))
76
+ className: cn('aurora-w-2 aurora-absolute aurora-right-0 aurora-top-0 aurora-bottom-0 aurora-py-1 aurora-pr-[2px] aurora-transition-opacity aurora-duration-200 aurora-opacity-0 group-hover:aurora-opacity-75', _defineProperty({}, 'aurora-pt-16', hasSearch))
87
77
  }, /*#__PURE__*/React.createElement(Thumb, {
88
78
  className: "aurora-bg-neutral-700 aurora-rounded-full"
89
79
  })))));
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,+DAA+D,0EAA8E;AAC7I;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,iDAAiD,0EAA8E;AAC/H;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,6 +1,6 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
- import { TDividerProps } from "../../divider/divider_types";
2
+ import { TBoxProps } from "../../box/box_types";
3
3
  export declare const SelectGroupLabel: {
4
- ({ children, ...props }: PropsWithChildren<TDividerProps>): React.JSX.Element;
4
+ ({ children, ...props }: PropsWithChildren<TBoxProps>): React.JSX.Element;
5
5
  displayName: string;
6
6
  };
@@ -9,14 +9,14 @@ var _excluded = ["children"];
9
9
  var SelectGroupLabel = function SelectGroupLabel(_ref) {
10
10
  var children = _ref.children,
11
11
  props = _objectWithoutProperties(_ref, _excluded);
12
- return /*#__PURE__*/React.createElement(Box, {
12
+ return /*#__PURE__*/React.createElement(Box, _objectSpread2({
13
13
  paddings: {
14
14
  pl: '2',
15
15
  pt: '2',
16
16
  pb: '2',
17
17
  pr: '0'
18
18
  }
19
- }, /*#__PURE__*/React.createElement(Stack, {
19
+ }, props), /*#__PURE__*/React.createElement(Stack, {
20
20
  align: "center",
21
21
  spacing: "2.5"
22
22
  }, /*#__PURE__*/React.createElement(Typography, {
@@ -24,7 +24,7 @@ var SelectGroupLabel = function SelectGroupLabel(_ref) {
24
24
  size: "s",
25
25
  color: "subtle",
26
26
  weight: "bold"
27
- }, children), /*#__PURE__*/React.createElement(Divider, _objectSpread2({}, props))));
27
+ }, children), /*#__PURE__*/React.createElement(Divider, null)));
28
28
  };
29
29
  SelectGroupLabel.displayName = 'SelectGroupLabel';
30
30
 
@@ -2,28 +2,26 @@ import React from 'react';
2
2
  import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../../../../../_virtual/_rollupPluginBabelHelpers.js';
3
3
  import { cn } from '../../../utilities/cn.js';
4
4
  import { CheckLineIcon } from '../../../assets/icons/check_icon.js';
5
- import { Item, ItemText } from '@radix-ui/react-select';
5
+ import { Item, ItemIndicator, ItemText } from '@radix-ui/react-select';
6
6
 
7
- var _excluded = ["children", "className", "isDisabled", "isReadonly", "isSelected", "additionalInfo"];
7
+ var _excluded = ["children", "className", "isDisabled", "isReadonly", "additionalInfo"];
8
8
  var SelectItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
9
9
  var children = _ref.children,
10
10
  className = _ref.className,
11
11
  isDisabled = _ref.isDisabled,
12
12
  isReadonly = _ref.isReadonly,
13
- isSelected = _ref.isSelected,
14
13
  additionalInfo = _ref.additionalInfo,
15
14
  props = _objectWithoutProperties(_ref, _excluded);
16
15
  return /*#__PURE__*/React.createElement(Item, _objectSpread2(_objectSpread2({
17
- className: cn('aurora-relative aurora-flex aurora-w-full aurora-rounded-6 aurora-cursor-default aurora-select-none aurora-items-center aurora-rounded-sm aurora-py-1.5 aurora-pl-9 aurora-pr-8 aurora-text-sm aurora-outline-none active:aurora-bg-active focus:aurora-bg-accent focus:aurora-text-accent-foreground data-[disabled]:aurora-pointer-events-none data-[disabled]:aurora-opacity-50 hover:aurora-bg-hover', {
18
- 'aurora-cursor-pointer active:aurora-bg-active': !isDisabled && !isReadonly,
19
- 'aurora-bg-hover aurora-font-semibold': isSelected
16
+ className: cn('aurora-relative aurora-flex aurora-w-full aurora-rounded-6 aurora-cursor-default aurora-select-none aurora-items-center aurora-rounded-sm aurora-py-1.5 aurora-pl-9 aurora-pr-8 aurora-text-sm aurora-outline-none active:aurora-bg-active focus:aurora-bg-hover focus:aurora-text-accent-foreground data-[disabled]:aurora-pointer-events-none data-[disabled]:aurora-opacity-50 hover:aurora-bg-hover data-[state=checked]:aurora-bg-hover data-[state=checked]:aurora-font-semibold', {
17
+ 'aurora-cursor-pointer active:aurora-bg-active': !isDisabled && !isReadonly
20
18
  }, className),
21
19
  disabled: isDisabled || isReadonly
22
20
  }, props), {}, {
23
21
  ref: ref
24
- }), isSelected && /*#__PURE__*/React.createElement(CheckLineIcon, {
22
+ }), /*#__PURE__*/React.createElement(ItemIndicator, null, /*#__PURE__*/React.createElement(CheckLineIcon, {
25
23
  className: "aurora-h-5 aurora-w-5 -aurora-ml-7 aurora-mr-2"
26
- }), /*#__PURE__*/React.createElement("div", {
24
+ })), /*#__PURE__*/React.createElement("div", {
27
25
  className: "aurora-flex aurora-flex-col"
28
26
  }, /*#__PURE__*/React.createElement(ItemText, null, children), !!additionalInfo && /*#__PURE__*/React.createElement("p", {
29
27
  className: "aurora-text-xs aurora-text-subtle-light"
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { TSelectSearchProps } from '../select_types';
3
+ export declare const SelectSearch: ({ options, ...props }: TSelectSearchProps) => React.JSX.Element;
@@ -0,0 +1,53 @@
1
+ import React, { useRef, useLayoutEffect } from 'react';
2
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../../../../../_virtual/_rollupPluginBabelHelpers.js';
3
+ import { Input } from '../../input/input.js';
4
+ import { SearchLineIcon } from '../../../assets/icons/search_icon.js';
5
+ import { deepEqual } from '../../../../../../external/fast-equals/dist/esm/index.mjs.js';
6
+
7
+ var _excluded = ["options"];
8
+ var BLUR_GUARD_TIMEOUT = 100;
9
+ var SelectSearch = function SelectSearch(_ref) {
10
+ var options = _ref.options,
11
+ props = _objectWithoutProperties(_ref, _excluded);
12
+ var inputRef = useRef(null);
13
+ // SHOPSVE-1360 (bardzo slaby hack)
14
+ // Radix w momencie usuniecia z dom aktualnie wybranego itemu przenosi focus na body
15
+ var blurGuardRef = useRef(false);
16
+ var handleBlur = function handleBlur() {
17
+ var _inputRef$current;
18
+ if (!blurGuardRef.current) return;
19
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
20
+ };
21
+ var optionsRef = useRef();
22
+ var timeoutRef = useRef();
23
+ // Uzycie useLayoutEffect ze wzgledu na to ze itemy na liscie moga sie zmienic po dluzszym czasie po wpisaniu w search
24
+ // np. moga byc wczytane z serwera
25
+ // Wiec nie mozemy sie podpiac pod onKeyDown i wtedy ustawiac timeout
26
+ useLayoutEffect(function () {
27
+ if (optionsRef.current === undefined) {
28
+ optionsRef.current = options;
29
+ return;
30
+ }
31
+ if (!deepEqual(optionsRef.current, options)) {
32
+ optionsRef.current = options;
33
+ blurGuardRef.current = true;
34
+ timeoutRef.current = setTimeout(function () {
35
+ blurGuardRef.current = false;
36
+ }, BLUR_GUARD_TIMEOUT);
37
+ }
38
+ return function () {
39
+ return timeoutRef.current && clearTimeout(timeoutRef.current);
40
+ };
41
+ }, [options]);
42
+ return /*#__PURE__*/React.createElement(Input, _objectSpread2({
43
+ ref: inputRef,
44
+ type: "text",
45
+ preElement: /*#__PURE__*/React.createElement(SearchLineIcon, {
46
+ className: "aurora-h-4 aurora-w-4 aurora-text-inverse-subtle-light"
47
+ }),
48
+ onBlur: handleBlur
49
+ }, props));
50
+ };
51
+
52
+ export { SelectSearch };
53
+ //# sourceMappingURL=select_search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,0BAA0B,8DAAkE;AAC5F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -12,7 +12,7 @@ var SelectTrigger = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
12
12
  props = _objectWithoutProperties(_ref, _excluded);
13
13
  return /*#__PURE__*/React.createElement(Trigger, _objectSpread2({
14
14
  ref: ref,
15
- className: cn('aurora-flex aurora-h-10 aurora-w-full aurora-items-center aurora-justify-between aurora-rounded-8 aurora-border aurora-border-input aurora-bg-neutral-0 aurora-px-3 aurora-py-2 aurora-text-s hover:aurora-border-strong focus:focus disabled:aurora-cursor-not-allowed disabled:aurora-bg-subtle disabled:aurora-text-subtle-light disabled:aurora-border-subtle [&>span]:aurora-line-clamp-1 focus:aurora-border-active focus:aurora-border-2 active:aurora-border-active active:aurora-border-2', {
15
+ className: cn('aurora-flex aurora-h-10 aurora-w-full aurora-items-center aurora-justify-between aurora-rounded-8 aurora-border aurora-border-input aurora-bg-neutral-0 aurora-px-3 aurora-py-2 aurora-text-s hover:aurora-border-strong focus-visible:focus disabled:aurora-cursor-not-allowed disabled:aurora-bg-subtle disabled:aurora-text-subtle-light disabled:aurora-border-subtle [&>span]:aurora-line-clamp-1 focus:aurora-border-active focus:aurora-border-2 active:aurora-border-active active:aurora-border-2', {
16
16
  '!aurora-border-danger aurora-border-2': hasError
17
17
  }, className)
18
18
  }, props), children, /*#__PURE__*/React.createElement(Icon, {
@@ -1,6 +1,6 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
2
  import { TSelectProps } from './select_types';
3
3
  export declare const Select: {
4
- ({ children, id, defaultValue, options, disabled, placeholder, hasSearch, searchPlaceholder, hasClearValueButton, innerAdditionalContent, errors, onValueChange, onScroll, ...props }: PropsWithChildren<TSelectProps>): React.JSX.Element;
4
+ ({ children, id, value, options, disabled, placeholder, hasSearch, searchPlaceholder, hasClearValueButton, innerAdditionalContent, enableLocalSearch, localSearchNotFoundContent, errors, onValueChange, onScroll, onSearch, onClose, ...props }: PropsWithChildren<TSelectProps>): React.JSX.Element;
5
5
  displayName: string | undefined;
6
6
  };
@@ -1,16 +1,16 @@
1
- import React, { useState, useRef, useEffect } from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2 } from '../../../../../_virtual/_rollupPluginBabelHelpers.js';
3
+ import { cn } from '../../utilities/cn.js';
3
4
  import { Root } from '@radix-ui/react-select';
4
5
  import { CloseCircleFillIcon } from '../../assets/icons/close_circle_fill_icon.js';
5
6
  import { SelectContent } from './components/select_content.js';
6
7
  import { SelectTrigger } from './components/select_trigger.js';
7
- import { SelectValue } from './components/select_value.js';
8
8
 
9
- var _excluded = ["children", "id", "defaultValue", "options", "disabled", "placeholder", "hasSearch", "searchPlaceholder", "hasClearValueButton", "innerAdditionalContent", "errors", "onValueChange", "onScroll"];
9
+ var _excluded = ["children", "id", "value", "options", "disabled", "placeholder", "hasSearch", "searchPlaceholder", "hasClearValueButton", "innerAdditionalContent", "enableLocalSearch", "localSearchNotFoundContent", "errors", "onValueChange", "onScroll", "onSearch", "onClose"];
10
10
  var Select = function Select(_ref) {
11
11
  var children = _ref.children,
12
12
  id = _ref.id,
13
- defaultValue = _ref.defaultValue,
13
+ value = _ref.value,
14
14
  options = _ref.options,
15
15
  disabled = _ref.disabled,
16
16
  placeholder = _ref.placeholder,
@@ -18,105 +18,72 @@ var Select = function Select(_ref) {
18
18
  searchPlaceholder = _ref.searchPlaceholder,
19
19
  hasClearValueButton = _ref.hasClearValueButton,
20
20
  innerAdditionalContent = _ref.innerAdditionalContent,
21
+ enableLocalSearch = _ref.enableLocalSearch,
22
+ localSearchNotFoundContent = _ref.localSearchNotFoundContent,
21
23
  errors = _ref.errors,
22
24
  onValueChange = _ref.onValueChange,
23
25
  onScroll = _ref.onScroll,
26
+ onSearch = _ref.onSearch,
27
+ onClose = _ref.onClose,
24
28
  props = _objectWithoutProperties(_ref, _excluded);
25
- var _useState = useState(''),
29
+ // Przechowanie aktualnie wybranej opcji w razie jakby przy wyszukiwaniu aktualna opcja zniknela z listy options
30
+ var _useState = useState(value ? options.find(function (opt) {
31
+ return opt.value === value;
32
+ }) : undefined),
26
33
  _useState2 = _slicedToArray(_useState, 2),
27
- filterTerm = _useState2[0],
28
- setFilterTerm = _useState2[1];
29
- var _useState3 = useState(defaultValue),
34
+ selectedOption = _useState2[0],
35
+ setSelectedOption = _useState2[1];
36
+ var _useState3 = useState(''),
30
37
  _useState4 = _slicedToArray(_useState3, 2),
31
- selectedValue = _useState4[0],
32
- setSelectedValue = _useState4[1];
33
- var triggerRef = useRef(null);
34
- var _useState5 = useState(null),
35
- _useState6 = _slicedToArray(_useState5, 2),
36
- triggerWidth = _useState6[0],
37
- setTriggerWidth = _useState6[1];
38
- var _useState7 = useState(false),
39
- _useState8 = _slicedToArray(_useState7, 2),
40
- open = _useState8[0],
41
- setOpen = _useState8[1];
42
- var _useState9 = useState(false),
43
- _useState10 = _slicedToArray(_useState9, 2),
44
- renderContent = _useState10[0],
45
- setRenderContent = _useState10[1];
46
- var clearFilterInputOnClose = function clearFilterInputOnClose(openState) {
47
- if (hasSearch && !openState) setFilterTerm('');
38
+ search = _useState4[0],
39
+ setSearch = _useState4[1];
40
+ var handleSearch = function handleSearch(str) {
41
+ setSearch(str);
42
+ onSearch === null || onSearch === void 0 ? void 0 : onSearch(str);
48
43
  };
49
- var filteredOptions = React.useMemo(function () {
50
- if (!hasSearch || !filterTerm) return options;
51
- return options.filter(function (opt) {
52
- return opt.text.toLowerCase().includes(filterTerm.toLowerCase()) || opt.isHeader;
44
+ var handleChange = function handleChange(val) {
45
+ var _option$value;
46
+ var option = options.find(function (opt) {
47
+ return opt.value === val;
53
48
  });
54
- }, [filterTerm, options]);
55
- useEffect(function () {
56
- onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(selectedValue !== null && selectedValue !== void 0 ? selectedValue : '');
57
- }, [selectedValue]);
58
- var getSelectedLabel = function getSelectedLabel(options, selectedValue) {
59
- var _options$find;
60
- return ((_options$find = options.find(function (opt) {
61
- return opt.value === selectedValue;
62
- })) === null || _options$find === void 0 ? void 0 : _options$find.text) || '';
49
+ setSelectedOption(option);
50
+ onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange((_option$value = option === null || option === void 0 ? void 0 : option.value) !== null && _option$value !== void 0 ? _option$value : '');
63
51
  };
64
- var handleChange = function handleChange(sufixedValue) {
65
- var cleanValue = sufixedValue.split('-')[0];
66
- setSelectedValue(cleanValue);
52
+ var handleOpenChange = function handleOpenChange(open) {
53
+ if (hasSearch && !open) setSearch('');
54
+ if (onClose && !open) onClose();
67
55
  };
68
- useEffect(function () {
69
- if (!open) {
70
- setRenderContent(false);
71
- return;
72
- }
73
- var timer = setTimeout(function () {
74
- return setRenderContent(true);
75
- }, 10);
76
- return function () {
77
- return clearTimeout(timer);
78
- };
79
- }, [open]);
80
- useEffect(function () {
81
- if (renderContent && triggerRef.current) {
82
- var rect = triggerRef.current.getBoundingClientRect();
83
- setTriggerWidth(rect.width);
84
- }
85
- }, [renderContent]);
56
+ var showPlaceholder = !selectedOption;
86
57
  return /*#__PURE__*/React.createElement(Root, _objectSpread2({
87
- defaultValue: defaultValue,
58
+ value: selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value,
88
59
  onValueChange: handleChange,
89
60
  disabled: disabled,
90
- onOpenChange: function onOpenChange(openState) {
91
- setOpen(openState);
92
- clearFilterInputOnClose(openState);
93
- }
61
+ onOpenChange: handleOpenChange
94
62
  }, props), /*#__PURE__*/React.createElement("div", {
95
63
  className: "aurora-relative aurora-flex aurora-items-center aurora-flex-col"
96
64
  }, /*#__PURE__*/React.createElement(SelectTrigger, {
97
- ref: triggerRef,
98
65
  id: id,
99
66
  hasError: !!(errors !== null && errors !== void 0 && errors.length)
100
- }, /*#__PURE__*/React.createElement(SelectValue, {
101
- placeholder: placeholder
102
- }, selectedValue ? getSelectedLabel(options, selectedValue) : placeholder !== null && placeholder !== void 0 ? placeholder : '')), selectedValue && hasClearValueButton && (/*#__PURE__*/React.createElement("div", {
67
+ }, /*#__PURE__*/React.createElement("span", {
68
+ className: cn('aurora-pointer-events-none', showPlaceholder && 'aurora-text-subtle')
69
+ }, !showPlaceholder ? selectedOption.text : placeholder)), value && hasClearValueButton && onValueChange && (/*#__PURE__*/React.createElement("div", {
103
70
  className: "aurora-absolute aurora-top-3 aurora-right-8 aurora-z-10",
104
71
  onClick: function onClick() {
105
- return setSelectedValue('');
72
+ return handleChange('');
106
73
  }
107
74
  }, /*#__PURE__*/React.createElement(CloseCircleFillIcon, {
108
75
  className: "aurora-h-4 aurora-w-4 aurora-cursor-pointer"
109
- })))), renderContent && (/*#__PURE__*/React.createElement(SelectContent, {
110
- options: filteredOptions,
111
- selectedValue: selectedValue,
76
+ })))), /*#__PURE__*/React.createElement(SelectContent, {
77
+ options: options,
112
78
  hasSearch: hasSearch,
113
79
  searchPlaceholder: searchPlaceholder,
114
80
  innerAdditionalContent: innerAdditionalContent,
115
- filterTerm: filterTerm,
116
- setFilterTerm: setFilterTerm,
117
- triggerWidth: triggerWidth,
118
- onScroll: onScroll
119
- })));
81
+ search: search,
82
+ onSearch: handleSearch,
83
+ onScroll: onScroll,
84
+ enableLocalSearch: enableLocalSearch,
85
+ localSearchNotFoundContent: localSearchNotFoundContent
86
+ }));
120
87
  };
121
88
  Select.displayName = Root.displayName;
122
89
 
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,5 +1,6 @@
1
1
  import * as SelectPrimitive from '@radix-ui/react-select';
2
- import { Dispatch, ReactNode, SetStateAction } from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { TInputProps } from "../input/input_types";
3
4
  export interface TSelectTriggerProps extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> {
4
5
  hasError?: boolean;
5
6
  }
@@ -11,23 +12,25 @@ export declare type TSelectOption = {
11
12
  isDisabled?: boolean;
12
13
  isReadonly?: boolean;
13
14
  };
15
+ export interface TSelectSearchProps extends TInputProps {
16
+ options: TSelectOption[];
17
+ }
14
18
  export interface TSelectContentProps extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> {
15
19
  options: TSelectOption[];
16
- selectedValue?: string;
17
20
  hasSearch?: boolean;
18
21
  searchPlaceholder?: string;
19
22
  innerAdditionalContent?: ReactNode;
20
- filterTerm: string;
21
- triggerWidth?: number | null;
22
- setFilterTerm?: Dispatch<SetStateAction<string>>;
23
+ search: string;
24
+ onSearch?: (str: string) => void;
25
+ enableLocalSearch?: boolean;
26
+ localSearchNotFoundContent?: ReactNode;
23
27
  }
24
28
  export interface TSelectItemProps extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> {
25
29
  isDisabled?: boolean;
26
30
  isReadonly?: boolean;
27
- isSelected?: boolean;
28
31
  additionalInfo?: string;
29
32
  }
30
- export interface TSelectProps extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Root> {
33
+ export interface TSelectProps extends Omit<React.ComponentPropsWithoutRef<typeof SelectPrimitive.Root>, 'defaultValue'> {
31
34
  id: string;
32
35
  options: TSelectOption[];
33
36
  placeholder?: string;
@@ -37,5 +40,9 @@ export interface TSelectProps extends React.ComponentPropsWithoutRef<typeof Sele
37
40
  hasClearValueButton?: boolean;
38
41
  errors?: string | string[];
39
42
  hasError?: boolean;
43
+ enableLocalSearch?: boolean;
44
+ localSearchNotFoundContent?: ReactNode;
40
45
  onScroll?: (event: React.UIEvent<HTMLElement>) => void;
46
+ onSearch?: (str: string) => void;
47
+ onClose?: () => void;
41
48
  }
@@ -1,3 +1,4 @@
1
1
  import '@radix-ui/react-select';
2
2
  import 'react';
3
+ import '@auroraComponents/input/input_types';
3
4
  //# sourceMappingURL=select_types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"select_types.js","sourceRoot":"","sources":["../../../../../../../src/components/select/select_types.ts"],"names":[],"mappings":"AAAA,OAAiC,wBAAwB,CAAC;AAE1D,OAAoD,OAAO,CAAC"}
1
+ {"version":3,"file":"select_types.js","sourceRoot":"","sources":["../../../../../../../src/components/select/select_types.ts"],"names":[],"mappings":"AAAA,OAAiC,wBAAwB,CAAC;AAE1D,OAA0B,OAAO,CAAC;AAClC,OAA4B,qCAAqC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { TSelectOption } from "./select_types";
2
+ export declare class SelectUtils {
3
+ static localSearchIsOptionVisible: (option: TSelectOption, search: string) => boolean;
4
+ static localSearchIsHeaderVisible: (search: string, options: TSelectOption[], index: number) => boolean;
5
+ }
@@ -0,0 +1,29 @@
1
+ import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from '../../../../../_virtual/_rollupPluginBabelHelpers.js';
2
+
3
+ var _SelectUtils;
4
+ var SelectUtils = /*#__PURE__*/_createClass(function SelectUtils() {
5
+ _classCallCheck(this, SelectUtils);
6
+ });
7
+ _SelectUtils = SelectUtils;
8
+ _defineProperty(SelectUtils, "localSearchIsOptionVisible", function (option, search) {
9
+ return option.text.toLocaleLowerCase().includes(search.toLocaleLowerCase());
10
+ });
11
+ _defineProperty(SelectUtils, "localSearchIsHeaderVisible", function (search, options, index) {
12
+ var visible = false;
13
+ var i = index + 1;
14
+ while (options[i]) {
15
+ var curr = options[i];
16
+ if (curr.isHeader) {
17
+ break;
18
+ }
19
+ if (_SelectUtils.localSearchIsOptionVisible(curr, search)) {
20
+ visible = true;
21
+ break;
22
+ }
23
+ i++;
24
+ }
25
+ return visible;
26
+ });
27
+
28
+ export { SelectUtils };
29
+ //# sourceMappingURL=select_utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}