@dreamcommerce/aurora 3.0.0-41 → 3.0.0-43

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 (54) hide show
  1. package/build/cjs/packages/aurora/src/components/drawer/components/drawer_content.js +3 -4
  2. package/build/cjs/packages/aurora/src/components/drawer/components/drawer_content.js.map +1 -1
  3. package/build/cjs/packages/aurora/src/components/drawer/drawer_variants.js +2 -2
  4. package/build/cjs/packages/aurora/src/components/label/label.js +5 -5
  5. package/build/cjs/packages/aurora/src/hooks/search/use_search.js +28 -0
  6. package/build/cjs/packages/aurora/src/hooks/search/use_search.js.map +1 -0
  7. package/build/cjs/packages/aurora/src/index.js +2 -0
  8. package/build/cjs/packages/aurora/src/index.js.map +1 -1
  9. package/build/cjs/packages/aurora/src/utilities/fuzzy_search.js +65 -0
  10. package/build/cjs/packages/aurora/src/utilities/fuzzy_search.js.map +1 -0
  11. package/build/esm/packages/aurora/src/components/control/control.d.ts +3 -0
  12. package/build/esm/packages/aurora/src/components/control/control.js +5 -0
  13. package/build/esm/packages/aurora/src/components/control/control.js.map +1 -0
  14. package/build/esm/packages/aurora/src/components/control/control_types.d.ts +5 -0
  15. package/build/esm/packages/aurora/src/components/control/control_types.js +2 -0
  16. package/build/esm/packages/aurora/src/components/control/control_types.js.map +1 -0
  17. package/build/esm/packages/aurora/src/components/controls/switch_control/switch_control.d.ts +3 -0
  18. package/build/esm/packages/aurora/src/components/controls/switch_control/switch_control.js +14 -0
  19. package/build/esm/packages/aurora/src/components/controls/switch_control/switch_control.js.map +1 -0
  20. package/build/esm/packages/aurora/src/components/controls/switch_control/switch_control_types.d.ts +8 -0
  21. package/build/esm/packages/aurora/src/components/controls/switch_control/switch_control_types.js +3 -0
  22. package/build/esm/packages/aurora/src/components/controls/switch_control/switch_control_types.js.map +1 -0
  23. package/build/esm/packages/aurora/src/components/drawer/components/drawer_content.js +3 -4
  24. package/build/esm/packages/aurora/src/components/drawer/components/drawer_content.js.map +1 -1
  25. package/build/esm/packages/aurora/src/components/drawer/drawer_variants.js +2 -2
  26. package/build/esm/packages/aurora/src/components/label/label.js +5 -5
  27. package/build/esm/packages/aurora/src/components/label/label_types.d.ts +2 -2
  28. package/build/esm/packages/aurora/src/components/switch/components/switch_thumb.d.ts +3 -0
  29. package/build/esm/packages/aurora/src/components/switch/components/switch_thumb.js +3 -0
  30. package/build/esm/packages/aurora/src/components/switch/components/switch_thumb.js.map +1 -0
  31. package/build/esm/packages/aurora/src/components/switch/switch.d.ts +3 -0
  32. package/build/esm/packages/aurora/src/components/switch/switch.js +11 -0
  33. package/build/esm/packages/aurora/src/components/switch/switch.js.map +1 -0
  34. package/build/esm/packages/aurora/src/components/switch/switch_types.d.ts +5 -0
  35. package/build/esm/packages/aurora/src/components/switch/switch_types.js +2 -0
  36. package/build/esm/packages/aurora/src/components/switch/switch_types.js.map +1 -0
  37. package/build/esm/packages/aurora/src/components/tag/tag.js +1 -1
  38. package/build/esm/packages/aurora/src/components/tag/tag.js.map +1 -1
  39. package/build/esm/packages/aurora/src/components/tag/tag_variants.js +1 -1
  40. package/build/esm/packages/aurora/src/components/tag/tag_variants.js.map +1 -1
  41. package/build/esm/packages/aurora/src/hooks/search/use_search.d.ts +2 -0
  42. package/build/esm/packages/aurora/src/hooks/search/use_search.js +24 -0
  43. package/build/esm/packages/aurora/src/hooks/search/use_search.js.map +1 -0
  44. package/build/esm/packages/aurora/src/hooks/search/use_search_types.d.ts +10 -0
  45. package/build/esm/packages/aurora/src/hooks/search/use_search_types.js +2 -0
  46. package/build/esm/packages/aurora/src/hooks/search/use_search_types.js.map +1 -0
  47. package/build/esm/packages/aurora/src/index.d.ts +1 -0
  48. package/build/esm/packages/aurora/src/index.js +1 -0
  49. package/build/esm/packages/aurora/src/index.js.map +1 -1
  50. package/build/esm/packages/aurora/src/utilities/fuzzy_search.d.ts +17 -0
  51. package/build/esm/packages/aurora/src/utilities/fuzzy_search.js +57 -0
  52. package/build/esm/packages/aurora/src/utilities/fuzzy_search.js.map +1 -0
  53. package/build/index.css +1 -1
  54. package/package.json +3 -1
@@ -10,16 +10,15 @@ var drawer_variants = require('../drawer_variants.js');
10
10
  var drawer_context = require('../context/drawer_context.js');
11
11
  var drawer_portal = require('./drawer_portal.js');
12
12
 
13
- var _excluded = ["offset", "className", "children"];
13
+ var _excluded = ["className", "children"];
14
14
  var DrawerContent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
15
- var offset = _ref.offset,
16
- className = _ref.className,
15
+ var className = _ref.className,
17
16
  children = _ref.children,
18
17
  props = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
19
18
  var drawerContext = React.useContext(drawer_context.DrawerContext);
20
19
  return /*#__PURE__*/React.createElement(drawer_portal.DrawerPortal, null, /*#__PURE__*/React.createElement(vaul.Drawer.Content, _rollupPluginBabelHelpers.objectSpread2({
21
20
  ref: ref,
22
- className: cn.cn('aurora-fixed aurora-bg aurora-z-50 aurora-flex aurora-flex-col', drawer_variants.drawerVariants({
21
+ className: cn.cn('aurora-fixed aurora--z-1 aurora-flex aurora-flex-col aurora-bg', drawer_variants.drawerVariants({
23
22
  direction: drawerContext.direction
24
23
  }), className)
25
24
  }, props), children));
@@ -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;"}
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;"}
@@ -9,8 +9,8 @@ var drawerVariants = index.cva('', {
9
9
  direction: {
10
10
  left: 'aurora-left-0 aurora-top-0',
11
11
  right: 'aurora-right-0 aurora-top-0',
12
- top: 'aurora-top-0',
13
- bottom: 'aurora-bottom-0'
12
+ top: 'aurora-top-0 aurora-left-0',
13
+ bottom: 'aurora-bottom-0 aurora-left-0'
14
14
  }
15
15
  },
16
16
  defaultVariants: {
@@ -14,19 +14,19 @@ var LabelPrimitive = require('@radix-ui/react-label');
14
14
  var label_content = require('./components/label_content.js');
15
15
  var label_variants = require('./label_variants.js');
16
16
 
17
- var _excluded = ["className", "tooltip", "isRequired", "isDisabled", "children"];
17
+ var _excluded = ["className", "tooltip", "required", "disabled", "children"];
18
18
  var Label = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
19
19
  var className = _ref.className,
20
20
  tooltip$1 = _ref.tooltip,
21
- isRequired = _ref.isRequired,
22
- isDisabled = _ref.isDisabled,
21
+ required = _ref.required,
22
+ disabled = _ref.disabled,
23
23
  children = _ref.children,
24
24
  props = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
25
25
  var content = /*#__PURE__*/React.createElement(box.Box, {
26
26
  align: "center",
27
27
  spacing: "0.5",
28
- className: cn.cn(label_variants.labelVariants(), "".concat(isDisabled ? 'aurora-cursor-not-allowed aurora-text-subtle-light' : '', " ").concat(className))
29
- }, isRequired && /*#__PURE__*/React.createElement("span", {
28
+ className: cn.cn(label_variants.labelVariants(), "".concat(disabled ? 'aurora-cursor-not-allowed aurora-text-subtle-light' : '', " ").concat(className))
29
+ }, required && /*#__PURE__*/React.createElement("span", {
30
30
  className: "aurora-text-interactive"
31
31
  }, "*"), children);
32
32
  if (tooltip$1) {
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var _rollupPluginBabelHelpers = require('../../../../../_virtual/_rollupPluginBabelHelpers.js');
7
+ var fuzzy_search = require('../../utilities/fuzzy_search.js');
8
+
9
+ var useSearch = function useSearch(_ref) {
10
+ var items = _ref.items,
11
+ searchKey = _ref.searchKey,
12
+ _ref$searchStrategy = _ref.searchStrategy,
13
+ searchStrategy = _ref$searchStrategy === void 0 ? fuzzy_search.fuzzySearch : _ref$searchStrategy;
14
+ var _useState = React.useState(items),
15
+ _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
16
+ _items = _useState2[0],
17
+ setItems = _useState2[1];
18
+ var search = function search(query) {
19
+ setItems(searchStrategy(query, items, searchKey));
20
+ };
21
+ return {
22
+ search: search,
23
+ items: _items
24
+ };
25
+ };
26
+
27
+ exports.useSearch = useSearch;
28
+ //# sourceMappingURL=use_search.js.map
@@ -0,0 +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;"}
@@ -82,6 +82,7 @@ var drawer_trigger = require('./components/drawer/components/drawer_trigger.js')
82
82
  var drawer_content = require('./components/drawer/components/drawer_content.js');
83
83
  var drawer_close = require('./components/drawer/components/drawer_close.js');
84
84
  var drawer_title = require('./components/drawer/components/drawer_title.js');
85
+ var use_search = require('./hooks/search/use_search.js');
85
86
 
86
87
 
87
88
 
@@ -182,4 +183,5 @@ exports.DrawerTrigger = drawer_trigger.DrawerTrigger;
182
183
  exports.DrawerContent = drawer_content.DrawerContent;
183
184
  exports.DrawerClose = drawer_close.DrawerClose;
184
185
  exports.DrawerTitle = drawer_title.DrawerTitle;
186
+ exports.useSearch = use_search.useSearch;
185
187
  //# sourceMappingURL=index.js.map
@@ -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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,65 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../../../../_virtual/_rollupPluginBabelHelpers.js');
6
+ var union = require('lodash/union');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var union__default = /*#__PURE__*/_interopDefaultLegacy(union);
11
+
12
+ /**
13
+ * searches within array of objects by given key, returns filtered array of objects using fuzzy algorithm
14
+ * @param {string} query - the phrase by which it searches
15
+ * @param {Array<Object>} arrayToFilter - array which will be searched
16
+ * @param {string} key - key of object within arrayToFilter where search should be used
17
+ * @example
18
+ * // returns [{id: 1, text: 'polish'}, {id: 2, text: 'portugal'}]
19
+ * fuzzySearch('pol', [
20
+ * {id: 1, text: 'polish'},
21
+ * {id: 2, text: 'portugal'},
22
+ * {id: 3, text: 'english'}
23
+ * ], 'text')
24
+ * @returns {Array} - filtered array
25
+ */
26
+ function fuzzySearch(query, arrayToFilter, key) {
27
+ if (query !== '' && query.search(/[-[\]/{}()*+?.\\^$|]/g) === -1) {
28
+ var exactSearch = new RegExp('^' + query + '$', 'i');
29
+ var firstSearch = new RegExp('^' + query, 'i');
30
+ var looseSearch = new RegExp('.*' + query + '.*', 'i');
31
+ var _fuzzySearch = new RegExp('(^' + query + ')|(' + query + ')|(' + query.replace(/\s+/g, '').split('').join('.*') + ')', 'i');
32
+ var exact = [];
33
+ var first = [];
34
+ var loose = [];
35
+ var fuzzy = [];
36
+ console.log('arrayToFilter', arrayToFilter);
37
+ console.log('key', key);
38
+ arrayToFilter.forEach(function (option) {
39
+ var searchBy = !key ? option.toString() : option[key].toString();
40
+ var textWithoutPolishSigns = searchBy.replace(/ę/gi, 'e').replace(/ó/gi, 'o').replace(/ą/gi, 'a').replace(/ś/gi, 's').replace(/ł/gi, 'l').replace(/ż/gi, 'z').replace(/ź/gi, 'z').replace(/ć/gi, 'c').replace(/ń/gi, 'n');
41
+ if (searchBy.match(exactSearch) || textWithoutPolishSigns.match(exactSearch)) {
42
+ exact.push(option);
43
+ return;
44
+ }
45
+ if (searchBy.match(firstSearch) || textWithoutPolishSigns.match(firstSearch)) {
46
+ first.push(option);
47
+ return;
48
+ }
49
+ if (searchBy.match(looseSearch) || textWithoutPolishSigns.match(looseSearch)) {
50
+ loose.push(option);
51
+ return;
52
+ }
53
+ if (searchBy.match(_fuzzySearch) || textWithoutPolishSigns.match(_fuzzySearch)) {
54
+ fuzzy.push(option);
55
+ return;
56
+ }
57
+ });
58
+ return union__default['default'](exact, first, loose, fuzzy);
59
+ } else {
60
+ return _rollupPluginBabelHelpers.toConsumableArray(arrayToFilter);
61
+ }
62
+ }
63
+
64
+ exports.fuzzySearch = fuzzySearch;
65
+ //# sourceMappingURL=fuzzy_search.js.map
@@ -0,0 +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;"}
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { IControlProps } from './control_types';
3
+ export declare const Control: React.FC<IControlProps>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import './control_types';
3
+ import classnames from 'classnames';
4
+ export const Control = ({ children, classname }) => (React.createElement("div", { className: classnames(`aurora-flex aurora-gap-3`, classname) }, children));
5
+ //# sourceMappingURL=control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.js","sourceRoot":"","sources":["../../../../../../../src/components/control/control.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAA8B,iBAAiB,CAAC;AAChD,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,MAAM,CAAC,MAAM,OAAO,GAA4B,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CACzE,6BAAK,SAAS,EAAE,UAAU,CAAC,0BAA0B,EAAE,SAAS,CAAC,IAAG,QAAQ,CAAO,CACtF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ export interface IControlProps {
3
+ children: React.ReactNode;
4
+ classname?: string;
5
+ }
@@ -0,0 +1,2 @@
1
+ import "react";
2
+ //# sourceMappingURL=control_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control_types.js","sourceRoot":"","sources":["../../../../../../../src/components/control/control_types.ts"],"names":[],"mappings":"AAAA,OAAkB,OAAO,CAAC"}
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { TSwitchControlProps } from './switch_control_types';
3
+ export declare const SwitchControl: React.FC<TSwitchControlProps>;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { Switch } from '@auroraComponents/switch/switch';
3
+ import './switch_control_types';
4
+ import { Control } from '@auroraComponents/control/control';
5
+ import { Label } from '@auroraComponents/label/label';
6
+ import { HelperText } from '@auroraComponents/helper_text/helper_text';
7
+ import { ErrorList } from '@auroraComponents/error_list/error_list';
8
+ export const SwitchControl = ({ id, name, errors, label, value, tooltip, helperText, checked = false, defaultChecked = false, disabled = false, required = false, onCheckedChange, ...rest }) => (React.createElement(Control, null,
9
+ React.createElement(Switch, { id: id, name: name, value: value, defaultChecked: defaultChecked, checked: checked, disabled: disabled, onCheckedChange: onCheckedChange, errors: errors, ...rest }),
10
+ React.createElement("div", { className: "aurora-mt-1 aurora-flex aurora-flex-col aurora-gap-1" },
11
+ label && (React.createElement(Label, { required: required, tooltip: tooltip }, label)),
12
+ helperText && React.createElement(HelperText, null, helperText),
13
+ errors && React.createElement(ErrorList, { errors: errors }))));
14
+ //# sourceMappingURL=switch_control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch_control.js","sourceRoot":"","sources":["../../../../../../../../src/components/controls/switch_control/switch_control.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAoC,wBAAwB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,MAAM,CAAC,MAAM,aAAa,GAAkC,CAAC,EACzD,EAAE,EACF,IAAI,EACJ,MAAM,EACN,KAAK,EACL,KAAK,EACL,OAAO,EACP,UAAU,EACV,OAAO,GAAG,KAAK,EACf,cAAc,GAAG,KAAK,EACtB,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,KAAK,EAChB,eAAe,EACf,GAAG,IAAI,EACV,EAAE,EAAE,CAAC,CACF,oBAAC,OAAO;IACJ,oBAAC,MAAM,IACH,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,KACV,IAAI,GACV;IACF,6BAAK,SAAS,EAAC,sDAAsD;QAChE,KAAK,IAAI,CACN,oBAAC,KAAK,IAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,IACtC,KAAK,CACF,CACX;QACA,UAAU,IAAI,oBAAC,UAAU,QAAE,UAAU,CAAc;QACnD,MAAM,IAAI,oBAAC,SAAS,IAAC,MAAM,EAAE,MAAM,GAAI,CACtC,CACA,CACb,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { TSwitchProps } from "../../switch/switch_types";
2
+ import React from "react";
3
+ export declare type TSwitchControlProps = TSwitchProps & {
4
+ label?: string | React.ReactNode;
5
+ tooltip?: string | React.ReactNode;
6
+ helperText?: string | React.ReactNode;
7
+ errors?: string | string[];
8
+ };
@@ -0,0 +1,3 @@
1
+ import "@auroraComponents/switch/switch_types";
2
+ import "react";
3
+ //# sourceMappingURL=switch_control_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch_control_types.js","sourceRoot":"","sources":["../../../../../../../../src/components/controls/switch_control/switch_control_types.ts"],"names":[],"mappings":"AAAA,OAA6B,uCAAuC,CAAC;AACrE,OAAkB,OAAO,CAAC"}
@@ -6,16 +6,15 @@ import { drawerVariants } from '../drawer_variants.js';
6
6
  import { DrawerContext } from '../context/drawer_context.js';
7
7
  import { DrawerPortal } from './drawer_portal.js';
8
8
 
9
- var _excluded = ["offset", "className", "children"];
9
+ var _excluded = ["className", "children"];
10
10
  var DrawerContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
11
- var offset = _ref.offset,
12
- className = _ref.className,
11
+ var className = _ref.className,
13
12
  children = _ref.children,
14
13
  props = _objectWithoutProperties(_ref, _excluded);
15
14
  var drawerContext = useContext(DrawerContext);
16
15
  return /*#__PURE__*/createElement(DrawerPortal, null, /*#__PURE__*/createElement(Drawer.Content, _objectSpread2({
17
16
  ref: ref,
18
- className: cn('aurora-fixed aurora-bg aurora-z-50 aurora-flex aurora-flex-col', drawerVariants({
17
+ className: cn('aurora-fixed aurora--z-1 aurora-flex aurora-flex-col aurora-bg', drawerVariants({
19
18
  direction: drawerContext.direction
20
19
  }), className)
21
20
  }, props), children));
@@ -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;"}
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;"}
@@ -5,8 +5,8 @@ var drawerVariants = cva('', {
5
5
  direction: {
6
6
  left: 'aurora-left-0 aurora-top-0',
7
7
  right: 'aurora-right-0 aurora-top-0',
8
- top: 'aurora-top-0',
9
- bottom: 'aurora-bottom-0'
8
+ top: 'aurora-top-0 aurora-left-0',
9
+ bottom: 'aurora-bottom-0 aurora-left-0'
10
10
  }
11
11
  },
12
12
  defaultVariants: {
@@ -10,19 +10,19 @@ import { Root } from '@radix-ui/react-label';
10
10
  import { LabelContent } from './components/label_content.js';
11
11
  import { labelVariants } from './label_variants.js';
12
12
 
13
- var _excluded = ["className", "tooltip", "isRequired", "isDisabled", "children"];
13
+ var _excluded = ["className", "tooltip", "required", "disabled", "children"];
14
14
  var Label = /*#__PURE__*/forwardRef(function (_ref, ref) {
15
15
  var className = _ref.className,
16
16
  tooltip = _ref.tooltip,
17
- isRequired = _ref.isRequired,
18
- isDisabled = _ref.isDisabled,
17
+ required = _ref.required,
18
+ disabled = _ref.disabled,
19
19
  children = _ref.children,
20
20
  props = _objectWithoutProperties(_ref, _excluded);
21
21
  var content = /*#__PURE__*/createElement(Box, {
22
22
  align: "center",
23
23
  spacing: "0.5",
24
- className: cn(labelVariants(), "".concat(isDisabled ? 'aurora-cursor-not-allowed aurora-text-subtle-light' : '', " ").concat(className))
25
- }, isRequired && /*#__PURE__*/createElement("span", {
24
+ className: cn(labelVariants(), "".concat(disabled ? 'aurora-cursor-not-allowed aurora-text-subtle-light' : '', " ").concat(className))
25
+ }, required && /*#__PURE__*/createElement("span", {
26
26
  className: "aurora-text-interactive"
27
27
  }, "*"), children);
28
28
  if (tooltip) {
@@ -4,6 +4,6 @@ import { labelVariants } from './label_variants';
4
4
  import { ReactNode } from 'react';
5
5
  export interface LabelProps extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>, VariantProps<typeof labelVariants> {
6
6
  tooltip?: string | ReactNode;
7
- isRequired?: boolean;
8
- isDisabled?: boolean;
7
+ required?: boolean;
8
+ disabled?: boolean;
9
9
  }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import * as SwitchPrimitive from "@radix-ui/react-switch";
3
+ export declare const SwitchThumb: import("react").ForwardRefExoticComponent<SwitchPrimitive.SwitchThumbProps & import("react").RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,3 @@
1
+ import * as SwitchPrimitive from "@radix-ui/react-switch";
2
+ export const SwitchThumb = SwitchPrimitive.SwitchThumb;
3
+ //# sourceMappingURL=switch_thumb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch_thumb.js","sourceRoot":"","sources":["../../../../../../../../src/components/switch/components/switch_thumb.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAE1D,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { TSwitchProps } from './switch_types';
3
+ export declare const Switch: React.ForwardRefExoticComponent<TSwitchProps & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,11 @@
1
+ import * as SwitchPrimitive from '@radix-ui/react-switch';
2
+ import React from 'react';
3
+ import classnames from 'classnames';
4
+ import './switch_types';
5
+ export const Switch = React.forwardRef(({ id, name, value, className, disabled, checked, defaultChecked, errors = [], onCheckedChange, ...props }, ref) => {
6
+ return (React.createElement(SwitchPrimitive.Root, { id: id, name: name, value: value, ref: ref, className: classnames('aurora-inline-flex aurora-items-center aurora-relative aurora-w-11 aurora-h-6 aurora-rounded-full aurora-bg-active hover:aurora-ring-2 hover:aurora-ring-subtle focus:aurora-ring-2 focus:aurora-ring-primary focus:aurora-outline-none focus:aurora-ring-offset aurora-cursor-pointer aurora-transition-all data-[state=checked]:aurora-bg-primary', disabled &&
7
+ 'aurora-cursor-not-allowed aurora-pointer-events-none aurora-bg-neutral-300 data-[state=checked]:!aurora-bg-active', errors && errors.length > 0 && 'aurora-ring-danger aurora-ring-2', className), disabled: disabled, defaultChecked: defaultChecked, checked: checked, onCheckedChange: onCheckedChange, ...props },
8
+ React.createElement(SwitchPrimitive.SwitchThumb, { className: classnames('aurora-block aurora-w-5 aurora-h-5 aurora-rounded-full aurora-transition-transform', disabled ? 'aurora-bg-subtle' : 'aurora-bg', 'data-[state=checked]:aurora-translate-x-[22px] aurora-translate-x-[2px]') })));
9
+ });
10
+ Switch.displayName = SwitchPrimitive.Root.displayName;
11
+ //# sourceMappingURL=switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../../../../../src/components/switch/switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAA6B,gBAAgB,CAAC;AAE9C,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAClC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,EAAE,EAAE,eAAe,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IAC/G,OAAO,CACH,oBAAC,eAAe,CAAC,IAAI,IACjB,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,UAAU,CACjB,qVAAqV,EACrV,QAAQ;YACJ,mHAAmH,EACvH,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,kCAAkC,EACjE,SAAS,CACZ,EACD,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,eAAe,KAC5B,KAAK;QAET,oBAAC,eAAe,CAAC,WAAW,IACxB,SAAS,EAAE,UAAU,CACjB,oFAAoF,EACpF,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,WAAW,EAC3C,yEAAyE,CAC5E,GACH,CACiB,CAC1B,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,MAAM,CAAC,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import * as SwitchPrimitive from '@radix-ui/react-switch';
3
+ export interface TSwitchProps extends React.ComponentPropsWithoutRef<typeof SwitchPrimitive.Root> {
4
+ errors?: string | string[];
5
+ }
@@ -0,0 +1,2 @@
1
+ import '@radix-ui/react-switch';
2
+ //# sourceMappingURL=switch_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch_types.js","sourceRoot":"","sources":["../../../../../../../src/components/switch/switch_types.ts"],"names":[],"mappings":"AAAA,OAAiC,wBAAwB,CAAC"}
@@ -8,7 +8,7 @@ export const Tag = ({ className, label, variant = 'default', disabled = false, o
8
8
  'aurora-pointer-events-none': disabled,
9
9
  }), ...props, "aria-disabled": disabled },
10
10
  React.createElement("span", null, label),
11
- variant === 'deletable' && (React.createElement("button", { className: "aurora-bg-transparent hover:aurora-bg-active aurora-rounded-2 focus:aurora-ring-2 focus:aurora-ring-focus focus-visible:aurora-ring-2 focus-visible:aurora-ring-focus focus:outline-none", onClick: (e) => {
11
+ variant === 'deletable' && (React.createElement("button", { className: "aurora-bg-transparent hover:aurora-bg-active aurora-rounded-2 focus", onClick: (e) => {
12
12
  e.stopPropagation();
13
13
  onDelete?.();
14
14
  } },
@@ -1 +1 @@
1
- {"version":3,"file":"tag.js","sourceRoot":"","sources":["../../../../../../../src/components/tag/tag.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AACzC,OAA0B,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,MAAM,CAAC,MAAM,GAAG,GAAwB,CAAC,EACrC,SAAS,EACT,KAAK,EACL,OAAO,GAAG,SAAS,EACnB,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,EAAE,CAAC,CACE,6BACI,SAAS,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE;QACzD,4BAA4B,EAAE,QAAQ;KACzC,CAAC,KACE,KAAK,mBACM,QAAQ;IAEvB,kCAAO,KAAK,CAAQ;IACnB,OAAO,KAAK,WAAW,IAAI,CACxB,gCACI,SAAS,EAAC,0LAA0L,EACpM,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACX,CAAC,CAAC,eAAe,EAAE,CAAC;YACpB,QAAQ,EAAE,EAAE,CAAC;QACjB,CAAC;QAED,oBAAC,aAAa,IAAC,SAAS,EAAE,UAAU,CAAC,4DAA4D,EAAE,QAAQ,IAAI,sBAAsB,CAAC,GAAI,CACrI,CACZ,CACC,CACT,CAAC"}
1
+ {"version":3,"file":"tag.js","sourceRoot":"","sources":["../../../../../../../src/components/tag/tag.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AACzC,OAA0B,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,MAAM,CAAC,MAAM,GAAG,GAAwB,CAAC,EACrC,SAAS,EACT,KAAK,EACL,OAAO,GAAG,SAAS,EACnB,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,EAAE,CAAC,CACE,6BACI,SAAS,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE;QACzD,4BAA4B,EAAE,QAAQ;KACzC,CAAC,KACE,KAAK,mBACM,QAAQ;IAEvB,kCAAO,KAAK,CAAQ;IACnB,OAAO,KAAK,WAAW,IAAI,CACxB,gCACI,SAAS,EAAC,qEAAqE,EAC/E,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACX,CAAC,CAAC,eAAe,EAAE,CAAC;YACpB,QAAQ,EAAE,EAAE,CAAC;QACjB,CAAC;QAED,oBAAC,aAAa,IAAC,SAAS,EAAE,UAAU,CAAC,4DAA4D,EAAE,QAAQ,IAAI,sBAAsB,CAAC,GAAI,CACrI,CACZ,CACC,CACT,CAAC"}
@@ -4,7 +4,7 @@ export const tagVariants = cva('aurora-inline-flex aurora-gap-1 aurora-items-cen
4
4
  variants: {
5
5
  variant: {
6
6
  [TAG_VARIANTS.default]: 'aurora-bg-subtle aurora-text-primary aurora-pr-2 aurora-pl-2',
7
- [TAG_VARIANTS.clickable]: 'aurora-bg-subtle aurora-cursor-pointer aurora-pr-2 aurora-pl-2 hover:aurora-bg-active focus:aurora-ring-2 focus:aurora-ring-focus focus:aurora-outline-none',
7
+ [TAG_VARIANTS.clickable]: 'aurora-bg-subtle aurora-cursor-pointer aurora-pr-2 aurora-pl-2 hover:aurora-bg-active focus',
8
8
  [TAG_VARIANTS.deletable]: 'aurora-bg-subtle',
9
9
  },
10
10
  disabled: {
@@ -1 +1 @@
1
- {"version":3,"file":"tag_variants.js","sourceRoot":"","sources":["../../../../../../../src/components/tag/tag_variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAC1B,uJAAuJ,EACvJ;IACI,QAAQ,EAAE;QACN,OAAO,EAAE;YACL,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,8DAA8D;YACtF,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,6JAA6J;YACvL,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,kBAAkB;SAC/C;QACD,QAAQ,EAAE;YACN,IAAI,EAAE,8FAA8F;YACpG,KAAK,EAAE,EAAE;SACZ;KACJ;IACD,eAAe,EAAE;QACb,OAAO,EAAE,YAAY,CAAC,OAAO;KAChC;CACJ,CACJ,CAAC"}
1
+ {"version":3,"file":"tag_variants.js","sourceRoot":"","sources":["../../../../../../../src/components/tag/tag_variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAC1B,uJAAuJ,EACvJ;IACI,QAAQ,EAAE;QACN,OAAO,EAAE;YACL,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,8DAA8D;YACtF,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,6FAA6F;YACvH,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,kBAAkB;SAC/C;QACD,QAAQ,EAAE;YACN,IAAI,EAAE,8FAA8F;YACpG,KAAK,EAAE,EAAE;SACZ;KACJ;IACD,eAAe,EAAE;QACb,OAAO,EAAE,YAAY,CAAC,OAAO;KAChC;CACJ,CACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { TSearchItem, TUseSearchApi, TUseSearchProps } from "./use_search_types";
2
+ export declare const useSearch: <T extends TSearchItem = TSearchItem>({ items, searchKey, searchStrategy }: TUseSearchProps<T>) => TUseSearchApi<T>;
@@ -0,0 +1,24 @@
1
+ import { useState } from 'react';
2
+ import { slicedToArray as _slicedToArray } from '../../../../../_virtual/_rollupPluginBabelHelpers.js';
3
+ import { fuzzySearch } from '../../utilities/fuzzy_search.js';
4
+
5
+ var useSearch = function useSearch(_ref) {
6
+ var items = _ref.items,
7
+ searchKey = _ref.searchKey,
8
+ _ref$searchStrategy = _ref.searchStrategy,
9
+ searchStrategy = _ref$searchStrategy === void 0 ? fuzzySearch : _ref$searchStrategy;
10
+ var _useState = useState(items),
11
+ _useState2 = _slicedToArray(_useState, 2),
12
+ _items = _useState2[0],
13
+ setItems = _useState2[1];
14
+ var search = function search(query) {
15
+ setItems(searchStrategy(query, items, searchKey));
16
+ };
17
+ return {
18
+ search: search,
19
+ items: _items
20
+ };
21
+ };
22
+
23
+ export { useSearch };
24
+ //# sourceMappingURL=use_search.js.map
@@ -0,0 +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;"}
@@ -0,0 +1,10 @@
1
+ export declare type TSearchItem = Record<string, any> | string;
2
+ export declare type TUseSearchProps<T extends TSearchItem = TSearchItem> = {
3
+ items: T[];
4
+ searchStrategy?: (query: string, items: T[], key?: string) => T[];
5
+ searchKey?: string;
6
+ };
7
+ export declare type TUseSearchApi<T extends TSearchItem = TSearchItem> = {
8
+ search(query: string): void;
9
+ items: T[];
10
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=use_search_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_search_types.js","sourceRoot":"","sources":["../../../../../../../src/hooks/search/use_search_types.ts"],"names":[],"mappings":""}
@@ -81,3 +81,4 @@ export { DrawerContent } from "./components/drawer/components/drawer_content";
81
81
  export { DrawerTitle } from "./components/drawer/components/drawer_title";
82
82
  export { DrawerClose } from "./components/drawer/components/drawer_close";
83
83
  export { DRAWER_DIRECTIONS } from "./components/drawer/drawer_constants";
84
+ export { useSearch } from "./hooks/search/use_search";
@@ -78,4 +78,5 @@ export { DrawerTrigger } from './components/drawer/components/drawer_trigger.js'
78
78
  export { DrawerContent } from './components/drawer/components/drawer_content.js';
79
79
  export { DrawerClose } from './components/drawer/components/drawer_close.js';
80
80
  export { DrawerTitle } from './components/drawer/components/drawer_title.js';
81
+ export { useSearch } from './hooks/search/use_search.js';
81
82
  //# sourceMappingURL=index.js.map
@@ -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;"}
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;"}
@@ -0,0 +1,17 @@
1
+ declare type TSearchItem = Record<string, any> | string;
2
+ /**
3
+ * searches within array of objects by given key, returns filtered array of objects using fuzzy algorithm
4
+ * @param {string} query - the phrase by which it searches
5
+ * @param {Array<Object>} arrayToFilter - array which will be searched
6
+ * @param {string} key - key of object within arrayToFilter where search should be used
7
+ * @example
8
+ * // returns [{id: 1, text: 'polish'}, {id: 2, text: 'portugal'}]
9
+ * fuzzySearch('pol', [
10
+ * {id: 1, text: 'polish'},
11
+ * {id: 2, text: 'portugal'},
12
+ * {id: 3, text: 'english'}
13
+ * ], 'text')
14
+ * @returns {Array} - filtered array
15
+ */
16
+ export declare function fuzzySearch<T extends TSearchItem = TSearchItem>(query: string, arrayToFilter: T[], key?: string): T[];
17
+ export {};
@@ -0,0 +1,57 @@
1
+ import { toConsumableArray as _toConsumableArray } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import union from 'lodash/union';
3
+
4
+ /**
5
+ * searches within array of objects by given key, returns filtered array of objects using fuzzy algorithm
6
+ * @param {string} query - the phrase by which it searches
7
+ * @param {Array<Object>} arrayToFilter - array which will be searched
8
+ * @param {string} key - key of object within arrayToFilter where search should be used
9
+ * @example
10
+ * // returns [{id: 1, text: 'polish'}, {id: 2, text: 'portugal'}]
11
+ * fuzzySearch('pol', [
12
+ * {id: 1, text: 'polish'},
13
+ * {id: 2, text: 'portugal'},
14
+ * {id: 3, text: 'english'}
15
+ * ], 'text')
16
+ * @returns {Array} - filtered array
17
+ */
18
+ function fuzzySearch(query, arrayToFilter, key) {
19
+ if (query !== '' && query.search(/[-[\]/{}()*+?.\\^$|]/g) === -1) {
20
+ var exactSearch = new RegExp('^' + query + '$', 'i');
21
+ var firstSearch = new RegExp('^' + query, 'i');
22
+ var looseSearch = new RegExp('.*' + query + '.*', 'i');
23
+ var _fuzzySearch = new RegExp('(^' + query + ')|(' + query + ')|(' + query.replace(/\s+/g, '').split('').join('.*') + ')', 'i');
24
+ var exact = [];
25
+ var first = [];
26
+ var loose = [];
27
+ var fuzzy = [];
28
+ console.log('arrayToFilter', arrayToFilter);
29
+ console.log('key', key);
30
+ arrayToFilter.forEach(function (option) {
31
+ var searchBy = !key ? option.toString() : option[key].toString();
32
+ var textWithoutPolishSigns = searchBy.replace(/ę/gi, 'e').replace(/ó/gi, 'o').replace(/ą/gi, 'a').replace(/ś/gi, 's').replace(/ł/gi, 'l').replace(/ż/gi, 'z').replace(/ź/gi, 'z').replace(/ć/gi, 'c').replace(/ń/gi, 'n');
33
+ if (searchBy.match(exactSearch) || textWithoutPolishSigns.match(exactSearch)) {
34
+ exact.push(option);
35
+ return;
36
+ }
37
+ if (searchBy.match(firstSearch) || textWithoutPolishSigns.match(firstSearch)) {
38
+ first.push(option);
39
+ return;
40
+ }
41
+ if (searchBy.match(looseSearch) || textWithoutPolishSigns.match(looseSearch)) {
42
+ loose.push(option);
43
+ return;
44
+ }
45
+ if (searchBy.match(_fuzzySearch) || textWithoutPolishSigns.match(_fuzzySearch)) {
46
+ fuzzy.push(option);
47
+ return;
48
+ }
49
+ });
50
+ return union(exact, first, loose, fuzzy);
51
+ } else {
52
+ return _toConsumableArray(arrayToFilter);
53
+ }
54
+ }
55
+
56
+ export { fuzzySearch };
57
+ //# sourceMappingURL=fuzzy_search.js.map
@@ -0,0 +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;"}