@cloudtower/eagle 481.0.2 → 481.0.3

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 (30) hide show
  1. package/dist/cjs/core/Cascader/cascader.widget.js +12 -12
  2. package/dist/cjs/core/SearchInput/SearchInput.hook.js +124 -0
  3. package/dist/cjs/core/SearchInput/SearchInput.js +253 -0
  4. package/dist/cjs/core/SearchInput/SearchInput.style.js +13 -0
  5. package/dist/cjs/core/index.js +6 -6
  6. package/dist/cjs/index.js +172 -172
  7. package/dist/cjs/legacy-antd.js +89 -89
  8. package/dist/cjs/stats1.html +1 -1
  9. package/dist/components.css +2240 -2217
  10. package/dist/esm/core/Cascader/cascader.widget.js +1 -1
  11. package/dist/esm/core/SearchInput/SearchInput.hook.js +117 -0
  12. package/dist/esm/core/SearchInput/SearchInput.js +247 -0
  13. package/dist/esm/core/SearchInput/SearchInput.style.js +7 -0
  14. package/dist/esm/index.js +1 -1
  15. package/dist/esm/legacy-antd.js +1 -1
  16. package/dist/esm/stats1.html +1 -1
  17. package/dist/linaria.merged.scss +2372 -2343
  18. package/dist/src/core/Cascader/cascader.type.d.ts +1 -1
  19. package/dist/src/core/SearchInput/SearchInput.d.ts +2 -0
  20. package/dist/src/core/SearchInput/SearchInput.hook.d.ts +9 -0
  21. package/dist/src/core/SearchInput/SearchInput.style.d.ts +5 -0
  22. package/dist/src/core/SearchInput/{searchInput.type.d.ts → SearchInput.type.d.ts} +18 -2
  23. package/dist/src/core/SearchInput/__test__/SearchInput.hook.test.d.ts +1 -0
  24. package/dist/src/core/SearchInput/index.d.ts +2 -4
  25. package/dist/src/core/index.d.ts +0 -1
  26. package/dist/stories/docs/core/SearchInput.stories.d.ts +6 -1
  27. package/dist/style.css +2240 -2217
  28. package/package.json +4 -4
  29. package/dist/cjs/core/SearchInput/index.js +0 -164
  30. package/dist/esm/core/SearchInput/index.js +0 -157
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudtower/eagle",
3
- "version": "481.0.2",
3
+ "version": "481.0.3",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -26,8 +26,8 @@
26
26
  "sync:color": "node tools/fetch-figma-color.js"
27
27
  },
28
28
  "dependencies": {
29
- "@cloudtower/icons-react": "^481.0.2",
30
- "@cloudtower/parrot": "^481.0.2",
29
+ "@cloudtower/icons-react": "^481.0.3",
30
+ "@cloudtower/parrot": "^481.0.3",
31
31
  "@cloudtower/rc-notification": "^4.6.1",
32
32
  "@linaria/core": "^4.2.2",
33
33
  "@linaria/react": "^4.3.0",
@@ -113,5 +113,5 @@
113
113
  "vite": "^4.5.1",
114
114
  "vitest": "^3.1.1"
115
115
  },
116
- "gitHead": "64d20c8d9b02a6cb6f22011d482e828dae287e5f"
116
+ "gitHead": "1fadb3cb15ff61a7918d925e0dbb67709b5404f6"
117
117
  }
@@ -1,164 +0,0 @@
1
- 'use strict';
2
-
3
- var icons = require('@ant-design/icons');
4
- var iconsReact = require('@cloudtower/icons-react');
5
- var core = require('@linaria/core');
6
- var index$1 = require('../Icon/index.js');
7
- var index$3 = require('../Input/index.js');
8
- var index$2 = require('../Tooltip/index.js');
9
- var index = require('../Typo/index.js');
10
- var useParrotTranslation = require('../../hooks/useParrotTranslation.js');
11
- var _ = require('lodash');
12
- var React = require('react');
13
-
14
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
-
16
- var ___default = /*#__PURE__*/_interopDefault(_);
17
- var React__default = /*#__PURE__*/_interopDefault(React);
18
-
19
- var __defProp = Object.defineProperty;
20
- var __defProps = Object.defineProperties;
21
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
22
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
23
- var __hasOwnProp = Object.prototype.hasOwnProperty;
24
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
25
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value
30
- }) : obj[key] = value;
31
- var __spreadValues = (a, b) => {
32
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
33
- if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
34
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
35
- }
36
- return a;
37
- };
38
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
39
- var __objRest = (source, exclude) => {
40
- var target = {};
41
- for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop];
42
- if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) {
43
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop];
44
- }
45
- return target;
46
- };
47
- const InputStyle = "E_i11gg7mj";
48
- const CountTextStyle = "E_cc368xp";
49
- const IconContainerStyle = "E_i11o6xqj";
50
- const DisabledIconStyle = "E_d19ruhdj";
51
- const SearchInput = props => {
52
- const _a = props,
53
- {
54
- onChange,
55
- debounceWait = 300,
56
- total = 0,
57
- onSearchNext,
58
- onSearchPrev,
59
- prefixHoverIcon,
60
- nextHoverIcon,
61
- clearHoverIcon,
62
- prefixIcon,
63
- nextIcon,
64
- clearIcon,
65
- width,
66
- searchIcon,
67
- current: externalCurrent
68
- } = _a,
69
- restProps = __objRest(_a, ["onChange", "debounceWait", "total", "onSearchNext", "onSearchPrev", "prefixHoverIcon", "nextHoverIcon", "clearHoverIcon", "prefixIcon", "nextIcon", "clearIcon", "width", "searchIcon", "current"]);
70
- const [internalCurrent, setInternalCurrent] = React.useState(0);
71
- const [value, setValue] = React.useState(props.value || "");
72
- const {
73
- t
74
- } = useParrotTranslation();
75
- const onSearch = ___default.default.debounce(onChange, debounceWait);
76
- const isNoMatch = total === 0;
77
- const current = externalCurrent !== void 0 ? externalCurrent : internalCurrent;
78
- const setCurrent = React.useCallback(newCurrent => {
79
- if (externalCurrent === void 0) {
80
- setInternalCurrent(newCurrent);
81
- }
82
- }, [externalCurrent]);
83
- const next = React.useCallback(() => {
84
- if (total) {
85
- const nextCurrent = current + 1 > total ? 1 : current + 1;
86
- onSearchNext == null ? void 0 : onSearchNext(value, nextCurrent);
87
- setCurrent(nextCurrent);
88
- }
89
- }, [onSearchNext, current, total, value, setCurrent]);
90
- const prev = React.useCallback(() => {
91
- if (total) {
92
- const prevCurrent = current - 1 < 1 ? total : current - 1;
93
- onSearchPrev == null ? void 0 : onSearchPrev(value, prevCurrent);
94
- setCurrent(prevCurrent);
95
- }
96
- }, [onSearchPrev, current, total, value, setCurrent]);
97
- const suffix = onSearchNext && onSearchPrev && value ? /* @__PURE__ */React__default.default.createElement(React__default.default.Fragment, null, typeof total === "number" ? /* @__PURE__ */React__default.default.createElement("span", {
98
- className: core.cx(index.Typo.Label.l4_regular, "counter-text", CountTextStyle)
99
- }, current, "/", total) : null, /* @__PURE__ */React__default.default.createElement("span", {
100
- className: IconContainerStyle
101
- }, isNoMatch ? /* @__PURE__ */React__default.default.createElement(index$1, {
102
- className: DisabledIconStyle,
103
- src: iconsReact.ArrowChevronUp16SecondaryIcon,
104
- style: {
105
- opacity: 0.5
106
- }
107
- }) : /* @__PURE__ */React__default.default.createElement(index$2, {
108
- title: t("components.prev")
109
- }, /* @__PURE__ */React__default.default.createElement(index$1, {
110
- src: prefixIcon != null ? prefixIcon : iconsReact.ArrowChevronUp16SecondaryIcon,
111
- hoverSrc: prefixHoverIcon != null ? prefixHoverIcon : iconsReact.ArrowChevronUp16BlueIcon,
112
- onClick: prev
113
- })), isNoMatch ? /* @__PURE__ */React__default.default.createElement(index$1, {
114
- className: DisabledIconStyle,
115
- src: iconsReact.ArrowChevronDown16SecondaryIcon,
116
- style: {
117
- opacity: 0.5
118
- }
119
- }) : /* @__PURE__ */React__default.default.createElement(index$2, {
120
- title: t("components.next")
121
- }, /* @__PURE__ */React__default.default.createElement(index$1, {
122
- src: nextIcon != null ? nextIcon : iconsReact.ArrowChevronDown16SecondaryIcon,
123
- hoverSrc: nextHoverIcon != null ? nextHoverIcon : iconsReact.ArrowChevronDown16BlueIcon,
124
- onClick: next
125
- })), /* @__PURE__ */React__default.default.createElement(index$2, {
126
- title: t("components.clear")
127
- }, /* @__PURE__ */React__default.default.createElement(index$1, {
128
- src: clearIcon != null ? clearIcon : iconsReact.XmarkCloseCircleFill16TertiaryIcon,
129
- hoverSrc: clearHoverIcon != null ? clearHoverIcon : iconsReact.XmarkCloseCircleFill16SecondaryIcon,
130
- onClick: () => {
131
- onSearch("");
132
- setValue("");
133
- }
134
- })))) : null;
135
- React.useEffect(() => {
136
- setValue(props.value || "");
137
- }, [props.value]);
138
- React.useEffect(() => {
139
- if (externalCurrent === void 0) {
140
- setCurrent(total ? 1 : 0);
141
- }
142
- }, [value, total, externalCurrent, setCurrent]);
143
- return /* @__PURE__ */React__default.default.createElement(index$3, __spreadProps(__spreadValues({
144
- style: {
145
- width: width != null ? width : 276
146
- },
147
- prefix: searchIcon ? /* @__PURE__ */React__default.default.createElement(index$1, {
148
- src: searchIcon
149
- }) : /* @__PURE__ */React__default.default.createElement(icons.SearchOutlined, null),
150
- suffix,
151
- onChange: e => {
152
- const newValue = e.target.value;
153
- onSearch(newValue);
154
- setValue(newValue);
155
- },
156
- onPressEnter: next,
157
- value
158
- }, restProps), {
159
- className: core.cx(InputStyle, restProps.className)
160
- }));
161
- };
162
- var SearchInput$1 = SearchInput;
163
-
164
- module.exports = SearchInput$1;
@@ -1,157 +0,0 @@
1
- import { SearchOutlined } from '@ant-design/icons';
2
- import { ArrowChevronUp16SecondaryIcon, ArrowChevronUp16BlueIcon, ArrowChevronDown16SecondaryIcon, ArrowChevronDown16BlueIcon, XmarkCloseCircleFill16TertiaryIcon, XmarkCloseCircleFill16SecondaryIcon } from '@cloudtower/icons-react';
3
- import { cx } from '@linaria/core';
4
- import Icon from '../Icon/index.js';
5
- import Input from '../Input/index.js';
6
- import Tooltip from '../Tooltip/index.js';
7
- import { Typo } from '../Typo/index.js';
8
- import useParrotTranslation from '../../hooks/useParrotTranslation.js';
9
- import _ from 'lodash';
10
- import React__default, { useState, useCallback, useEffect } from 'react';
11
-
12
- var __defProp = Object.defineProperty;
13
- var __defProps = Object.defineProperties;
14
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
15
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
16
- var __hasOwnProp = Object.prototype.hasOwnProperty;
17
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
18
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
19
- enumerable: true,
20
- configurable: true,
21
- writable: true,
22
- value
23
- }) : obj[key] = value;
24
- var __spreadValues = (a, b) => {
25
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
26
- if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
27
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
28
- }
29
- return a;
30
- };
31
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
32
- var __objRest = (source, exclude) => {
33
- var target = {};
34
- for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop];
35
- if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) {
36
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop];
37
- }
38
- return target;
39
- };
40
- const InputStyle = "E_i11gg7mj";
41
- const CountTextStyle = "E_cc368xp";
42
- const IconContainerStyle = "E_i11o6xqj";
43
- const DisabledIconStyle = "E_d19ruhdj";
44
- const SearchInput = props => {
45
- const _a = props,
46
- {
47
- onChange,
48
- debounceWait = 300,
49
- total = 0,
50
- onSearchNext,
51
- onSearchPrev,
52
- prefixHoverIcon,
53
- nextHoverIcon,
54
- clearHoverIcon,
55
- prefixIcon,
56
- nextIcon,
57
- clearIcon,
58
- width,
59
- searchIcon,
60
- current: externalCurrent
61
- } = _a,
62
- restProps = __objRest(_a, ["onChange", "debounceWait", "total", "onSearchNext", "onSearchPrev", "prefixHoverIcon", "nextHoverIcon", "clearHoverIcon", "prefixIcon", "nextIcon", "clearIcon", "width", "searchIcon", "current"]);
63
- const [internalCurrent, setInternalCurrent] = useState(0);
64
- const [value, setValue] = useState(props.value || "");
65
- const {
66
- t
67
- } = useParrotTranslation();
68
- const onSearch = _.debounce(onChange, debounceWait);
69
- const isNoMatch = total === 0;
70
- const current = externalCurrent !== void 0 ? externalCurrent : internalCurrent;
71
- const setCurrent = useCallback(newCurrent => {
72
- if (externalCurrent === void 0) {
73
- setInternalCurrent(newCurrent);
74
- }
75
- }, [externalCurrent]);
76
- const next = useCallback(() => {
77
- if (total) {
78
- const nextCurrent = current + 1 > total ? 1 : current + 1;
79
- onSearchNext == null ? void 0 : onSearchNext(value, nextCurrent);
80
- setCurrent(nextCurrent);
81
- }
82
- }, [onSearchNext, current, total, value, setCurrent]);
83
- const prev = useCallback(() => {
84
- if (total) {
85
- const prevCurrent = current - 1 < 1 ? total : current - 1;
86
- onSearchPrev == null ? void 0 : onSearchPrev(value, prevCurrent);
87
- setCurrent(prevCurrent);
88
- }
89
- }, [onSearchPrev, current, total, value, setCurrent]);
90
- const suffix = onSearchNext && onSearchPrev && value ? /* @__PURE__ */React__default.createElement(React__default.Fragment, null, typeof total === "number" ? /* @__PURE__ */React__default.createElement("span", {
91
- className: cx(Typo.Label.l4_regular, "counter-text", CountTextStyle)
92
- }, current, "/", total) : null, /* @__PURE__ */React__default.createElement("span", {
93
- className: IconContainerStyle
94
- }, isNoMatch ? /* @__PURE__ */React__default.createElement(Icon, {
95
- className: DisabledIconStyle,
96
- src: ArrowChevronUp16SecondaryIcon,
97
- style: {
98
- opacity: 0.5
99
- }
100
- }) : /* @__PURE__ */React__default.createElement(Tooltip, {
101
- title: t("components.prev")
102
- }, /* @__PURE__ */React__default.createElement(Icon, {
103
- src: prefixIcon != null ? prefixIcon : ArrowChevronUp16SecondaryIcon,
104
- hoverSrc: prefixHoverIcon != null ? prefixHoverIcon : ArrowChevronUp16BlueIcon,
105
- onClick: prev
106
- })), isNoMatch ? /* @__PURE__ */React__default.createElement(Icon, {
107
- className: DisabledIconStyle,
108
- src: ArrowChevronDown16SecondaryIcon,
109
- style: {
110
- opacity: 0.5
111
- }
112
- }) : /* @__PURE__ */React__default.createElement(Tooltip, {
113
- title: t("components.next")
114
- }, /* @__PURE__ */React__default.createElement(Icon, {
115
- src: nextIcon != null ? nextIcon : ArrowChevronDown16SecondaryIcon,
116
- hoverSrc: nextHoverIcon != null ? nextHoverIcon : ArrowChevronDown16BlueIcon,
117
- onClick: next
118
- })), /* @__PURE__ */React__default.createElement(Tooltip, {
119
- title: t("components.clear")
120
- }, /* @__PURE__ */React__default.createElement(Icon, {
121
- src: clearIcon != null ? clearIcon : XmarkCloseCircleFill16TertiaryIcon,
122
- hoverSrc: clearHoverIcon != null ? clearHoverIcon : XmarkCloseCircleFill16SecondaryIcon,
123
- onClick: () => {
124
- onSearch("");
125
- setValue("");
126
- }
127
- })))) : null;
128
- useEffect(() => {
129
- setValue(props.value || "");
130
- }, [props.value]);
131
- useEffect(() => {
132
- if (externalCurrent === void 0) {
133
- setCurrent(total ? 1 : 0);
134
- }
135
- }, [value, total, externalCurrent, setCurrent]);
136
- return /* @__PURE__ */React__default.createElement(Input, __spreadProps(__spreadValues({
137
- style: {
138
- width: width != null ? width : 276
139
- },
140
- prefix: searchIcon ? /* @__PURE__ */React__default.createElement(Icon, {
141
- src: searchIcon
142
- }) : /* @__PURE__ */React__default.createElement(SearchOutlined, null),
143
- suffix,
144
- onChange: e => {
145
- const newValue = e.target.value;
146
- onSearch(newValue);
147
- setValue(newValue);
148
- },
149
- onPressEnter: next,
150
- value
151
- }, restProps), {
152
- className: cx(InputStyle, restProps.className)
153
- }));
154
- };
155
- var SearchInput$1 = SearchInput;
156
-
157
- export { SearchInput$1 as default };