@yamada-ui/autocomplete 0.0.0-dev-20230603042803
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.
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/autocomplete-create.d.ts +12 -0
- package/dist/autocomplete-create.js +183 -0
- package/dist/autocomplete-create.mjs +6 -0
- package/dist/autocomplete-empty.d.ts +12 -0
- package/dist/autocomplete-empty.js +182 -0
- package/dist/autocomplete-empty.mjs +6 -0
- package/dist/autocomplete-icon.d.ts +14 -0
- package/dist/autocomplete-icon.js +136 -0
- package/dist/autocomplete-icon.mjs +10 -0
- package/dist/autocomplete-list.d.ts +7 -0
- package/dist/autocomplete-list.js +129 -0
- package/dist/autocomplete-list.mjs +6 -0
- package/dist/autocomplete-option-group.d.ts +15 -0
- package/dist/autocomplete-option-group.js +148 -0
- package/dist/autocomplete-option-group.mjs +6 -0
- package/dist/autocomplete-option.d.ts +8 -0
- package/dist/autocomplete-option.js +286 -0
- package/dist/autocomplete-option.mjs +6 -0
- package/dist/autocomplete.d.ts +24 -0
- package/dist/autocomplete.js +1442 -0
- package/dist/autocomplete.mjs +6 -0
- package/dist/chunk-MG2KF34Q.mjs +1685 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +1661 -0
- package/dist/index.mjs +16 -0
- package/dist/multi-autocomplete.d.ts +34 -0
- package/dist/multi-autocomplete.js +1550 -0
- package/dist/multi-autocomplete.mjs +6 -0
- package/dist/use-autocomplete-f95f21d6.d.ts +4050 -0
- package/dist/use-autocomplete.d.ts +8 -0
- package/dist/use-autocomplete.js +1246 -0
- package/dist/use-autocomplete.mjs +30 -0
- package/package.json +84 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Hirotomo Yamada
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @yamada-ui/autocomplete
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
$ pnpm add @yamada-ui/autocomplete
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
or
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
$ yarn add @yamada-ui/autocomplete
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
or
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
$ npm install @yamada-ui/autocomplete
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Contribution
|
|
22
|
+
|
|
23
|
+
Wouldn't you like to contribute? That's amazing! We have prepared a [contribution guide](https://github.com/hirotomoyamada/yamada-ui/blob/main/CONTRIBUTING.md) to assist you.
|
|
24
|
+
|
|
25
|
+
## Licence
|
|
26
|
+
|
|
27
|
+
This package is licensed under the terms of the
|
|
28
|
+
[MIT license](https://github.com/hirotomoyamada/yamada-ui/blob/main/LICENSE).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
+
import { ReactElement } from 'react';
|
|
4
|
+
|
|
5
|
+
type AutocompleteCreateOptions = {
|
|
6
|
+
icon?: ReactElement;
|
|
7
|
+
children?: string | ((inputValue: string) => string);
|
|
8
|
+
};
|
|
9
|
+
type AutocompleteCreateProps = Omit<HTMLUIProps<'li'>, 'children'> & AutocompleteCreateOptions;
|
|
10
|
+
declare const AutocompleteCreate: _yamada_ui_core.Component<"li", AutocompleteCreateProps>;
|
|
11
|
+
|
|
12
|
+
export { AutocompleteCreate, AutocompleteCreateProps };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/autocomplete-create.tsx
|
|
21
|
+
var autocomplete_create_exports = {};
|
|
22
|
+
__export(autocomplete_create_exports, {
|
|
23
|
+
AutocompleteCreate: () => AutocompleteCreate
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(autocomplete_create_exports);
|
|
26
|
+
var import_core3 = require("@yamada-ui/core");
|
|
27
|
+
var import_utils3 = require("@yamada-ui/utils");
|
|
28
|
+
|
|
29
|
+
// src/autocomplete-icon.tsx
|
|
30
|
+
var import_core2 = require("@yamada-ui/core");
|
|
31
|
+
var import_icon = require("@yamada-ui/icon");
|
|
32
|
+
var import_use_clickable = require("@yamada-ui/use-clickable");
|
|
33
|
+
var import_utils2 = require("@yamada-ui/utils");
|
|
34
|
+
var import_react2 = require("react");
|
|
35
|
+
|
|
36
|
+
// src/use-autocomplete.tsx
|
|
37
|
+
var import_core = require("@yamada-ui/core");
|
|
38
|
+
var import_form_control = require("@yamada-ui/form-control");
|
|
39
|
+
var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
|
|
40
|
+
var import_use_descendant = require("@yamada-ui/use-descendant");
|
|
41
|
+
var import_use_outside_click = require("@yamada-ui/use-outside-click");
|
|
42
|
+
var import_utils = require("@yamada-ui/utils");
|
|
43
|
+
var import_react = require("react");
|
|
44
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
+
var {
|
|
46
|
+
DescendantsContextProvider: AutocompleteDescendantsContextProvider,
|
|
47
|
+
useDescendantsContext: useAutocompleteDescendantsContext,
|
|
48
|
+
useDescendants: useAutocompleteDescendants,
|
|
49
|
+
useDescendant: useAutocompleteDescendant
|
|
50
|
+
} = (0, import_use_descendant.createDescendant)();
|
|
51
|
+
var [AutocompleteProvider, useAutocompleteContext] = (0, import_utils.createContext)({
|
|
52
|
+
name: "AutocompleteContext",
|
|
53
|
+
errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in "<Autocomplete />" or "<MultiAutocomplete />"`
|
|
54
|
+
});
|
|
55
|
+
var useAutocompleteCreate = () => {
|
|
56
|
+
const { isHit, onCreate } = useAutocompleteContext();
|
|
57
|
+
const getCreateProps = (0, import_react.useCallback)(
|
|
58
|
+
(props = {}, ref = null) => {
|
|
59
|
+
const style = {
|
|
60
|
+
border: "0px",
|
|
61
|
+
clip: "rect(0px, 0px, 0px, 0px)",
|
|
62
|
+
height: "1px",
|
|
63
|
+
width: "1px",
|
|
64
|
+
margin: "-1px",
|
|
65
|
+
padding: "0px",
|
|
66
|
+
overflow: "hidden",
|
|
67
|
+
whiteSpace: "nowrap",
|
|
68
|
+
position: "absolute"
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
ref,
|
|
72
|
+
...props,
|
|
73
|
+
tabIndex: -1,
|
|
74
|
+
style: isHit ? style : void 0,
|
|
75
|
+
"data-focus": (0, import_utils.dataAttr)(!isHit),
|
|
76
|
+
onClick: (0, import_utils.handlerAll)(props.onClick, onCreate)
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
[isHit, onCreate]
|
|
80
|
+
);
|
|
81
|
+
return { getCreateProps };
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/autocomplete-icon.tsx
|
|
85
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
86
|
+
var AutocompleteIcon = (0, import_core2.forwardRef)(
|
|
87
|
+
({ className, children, __css, ...rest }, ref) => {
|
|
88
|
+
const { styles } = useAutocompleteContext();
|
|
89
|
+
const css = {
|
|
90
|
+
position: "absolute",
|
|
91
|
+
top: "50%",
|
|
92
|
+
transform: "translateY(-50%)",
|
|
93
|
+
display: "inline-flex",
|
|
94
|
+
alignItems: "center",
|
|
95
|
+
justifyContent: "center",
|
|
96
|
+
pointerEvents: "none",
|
|
97
|
+
cursor: "pointer",
|
|
98
|
+
...styles.icon,
|
|
99
|
+
...__css
|
|
100
|
+
};
|
|
101
|
+
const validChildren = (0, import_utils2.getValidChildren)(children);
|
|
102
|
+
const cloneChildren = validChildren.map(
|
|
103
|
+
(child) => (0, import_react2.cloneElement)(child, {
|
|
104
|
+
focusable: false,
|
|
105
|
+
"aria-hidden": true,
|
|
106
|
+
style: {
|
|
107
|
+
maxWidth: "1em",
|
|
108
|
+
maxHeight: "1em",
|
|
109
|
+
color: "currentColor"
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
);
|
|
113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.div, { ref, className: (0, import_utils2.cx)("ui-autocomplete-icon", className), __css: css, ...rest, children: (0, import_utils2.isValidElement)(children) ? cloneChildren : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icon.ChevronIcon, {}) });
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
var AutocompleteItemIcon = (0, import_core2.forwardRef)(
|
|
117
|
+
({ className, ...rest }, ref) => {
|
|
118
|
+
const { styles } = useAutocompleteContext();
|
|
119
|
+
const css = {
|
|
120
|
+
flexShrink: 0,
|
|
121
|
+
display: "inline-flex",
|
|
122
|
+
justifyContent: "center",
|
|
123
|
+
alignItems: "center",
|
|
124
|
+
fontSize: "0.85em",
|
|
125
|
+
...styles.itemIcon
|
|
126
|
+
};
|
|
127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
128
|
+
import_core2.ui.span,
|
|
129
|
+
{
|
|
130
|
+
ref,
|
|
131
|
+
className: (0, import_utils2.cx)("ui-autocomplete-item-icon", className),
|
|
132
|
+
__css: css,
|
|
133
|
+
...rest
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
// src/autocomplete-create.tsx
|
|
140
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
141
|
+
var AutocompleteCreate = (0, import_core3.forwardRef)(
|
|
142
|
+
({ className, icon, children, ...rest }, ref) => {
|
|
143
|
+
const { inputValue, styles } = useAutocompleteContext();
|
|
144
|
+
const { getCreateProps } = useAutocompleteCreate();
|
|
145
|
+
children != null ? children : children = inputValue;
|
|
146
|
+
const css = {
|
|
147
|
+
textDecoration: "none",
|
|
148
|
+
color: "inherit",
|
|
149
|
+
userSelect: "none",
|
|
150
|
+
display: "flex",
|
|
151
|
+
width: "100%",
|
|
152
|
+
alignItems: "center",
|
|
153
|
+
textAlign: "start",
|
|
154
|
+
flex: "0 0 auto",
|
|
155
|
+
outline: 0,
|
|
156
|
+
gap: "0.75rem",
|
|
157
|
+
...styles.item
|
|
158
|
+
};
|
|
159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
160
|
+
import_core3.ui.li,
|
|
161
|
+
{
|
|
162
|
+
className: (0, import_utils3.cx)("ui-autocomplete-create", className),
|
|
163
|
+
__css: css,
|
|
164
|
+
...getCreateProps(rest, ref),
|
|
165
|
+
children: [
|
|
166
|
+
icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AutocompleteItemIcon, { children: icon || /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PlusIcon, {}) }) : null,
|
|
167
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.span, { style: { pointerEvents: "none", flex: 1 }, noOfLines: 1, children: (0, import_utils3.runIfFunc)(children, inputValue) }) : (0, import_utils3.runIfFunc)(children, inputValue)
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
var PlusIcon = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { viewBox: "0 0 45.402 45.402", width: "1em", height: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
174
|
+
"path",
|
|
175
|
+
{
|
|
176
|
+
fill: "currentColor",
|
|
177
|
+
d: "M41.267,18.557H26.832V4.134C26.832,1.851,24.99,0,22.707,0c-2.283,0-4.124,1.851-4.124,4.135v14.432H4.141 c-2.283,0-4.139,1.851-4.138,4.135c-0.001,1.141,0.46,2.187,1.207,2.934c0.748,0.749,1.78,1.222,2.92,1.222h14.453V41.27 c0,1.142,0.453,2.176,1.201,2.922c0.748,0.748,1.777,1.211,2.919,1.211c2.282,0,4.129-1.851,4.129-4.133V26.857h14.435 c2.283,0,4.134-1.867,4.133-4.15C45.399,20.425,43.548,18.557,41.267,18.557z"
|
|
178
|
+
}
|
|
179
|
+
) });
|
|
180
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
181
|
+
0 && (module.exports = {
|
|
182
|
+
AutocompleteCreate
|
|
183
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
+
import { ReactElement } from 'react';
|
|
4
|
+
|
|
5
|
+
type AutocompleteEmptyOptions = {
|
|
6
|
+
icon?: ReactElement;
|
|
7
|
+
children?: string;
|
|
8
|
+
};
|
|
9
|
+
type AutocompleteEmptyProps = Omit<HTMLUIProps<'li'>, 'children'> & AutocompleteEmptyOptions;
|
|
10
|
+
declare const AutocompleteEmpty: _yamada_ui_core.Component<"li", AutocompleteEmptyProps>;
|
|
11
|
+
|
|
12
|
+
export { AutocompleteEmpty, AutocompleteEmptyProps };
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/autocomplete-empty.tsx
|
|
21
|
+
var autocomplete_empty_exports = {};
|
|
22
|
+
__export(autocomplete_empty_exports, {
|
|
23
|
+
AutocompleteEmpty: () => AutocompleteEmpty
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(autocomplete_empty_exports);
|
|
26
|
+
var import_core3 = require("@yamada-ui/core");
|
|
27
|
+
var import_utils3 = require("@yamada-ui/utils");
|
|
28
|
+
|
|
29
|
+
// src/autocomplete-icon.tsx
|
|
30
|
+
var import_core2 = require("@yamada-ui/core");
|
|
31
|
+
var import_icon = require("@yamada-ui/icon");
|
|
32
|
+
var import_use_clickable = require("@yamada-ui/use-clickable");
|
|
33
|
+
var import_utils2 = require("@yamada-ui/utils");
|
|
34
|
+
var import_react2 = require("react");
|
|
35
|
+
|
|
36
|
+
// src/use-autocomplete.tsx
|
|
37
|
+
var import_core = require("@yamada-ui/core");
|
|
38
|
+
var import_form_control = require("@yamada-ui/form-control");
|
|
39
|
+
var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
|
|
40
|
+
var import_use_descendant = require("@yamada-ui/use-descendant");
|
|
41
|
+
var import_use_outside_click = require("@yamada-ui/use-outside-click");
|
|
42
|
+
var import_utils = require("@yamada-ui/utils");
|
|
43
|
+
var import_react = require("react");
|
|
44
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
+
var {
|
|
46
|
+
DescendantsContextProvider: AutocompleteDescendantsContextProvider,
|
|
47
|
+
useDescendantsContext: useAutocompleteDescendantsContext,
|
|
48
|
+
useDescendants: useAutocompleteDescendants,
|
|
49
|
+
useDescendant: useAutocompleteDescendant
|
|
50
|
+
} = (0, import_use_descendant.createDescendant)();
|
|
51
|
+
var [AutocompleteProvider, useAutocompleteContext] = (0, import_utils.createContext)({
|
|
52
|
+
name: "AutocompleteContext",
|
|
53
|
+
errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in "<Autocomplete />" or "<MultiAutocomplete />"`
|
|
54
|
+
});
|
|
55
|
+
var useAutocompleteEmpty = () => {
|
|
56
|
+
const { isHit, isEmpty } = useAutocompleteContext();
|
|
57
|
+
const getEmptyProps = (0, import_react.useCallback)(
|
|
58
|
+
(props = {}, ref = null) => {
|
|
59
|
+
const style = {
|
|
60
|
+
border: "0px",
|
|
61
|
+
clip: "rect(0px, 0px, 0px, 0px)",
|
|
62
|
+
height: "1px",
|
|
63
|
+
width: "1px",
|
|
64
|
+
margin: "-1px",
|
|
65
|
+
padding: "0px",
|
|
66
|
+
overflow: "hidden",
|
|
67
|
+
whiteSpace: "nowrap",
|
|
68
|
+
position: "absolute"
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
ref,
|
|
72
|
+
...props,
|
|
73
|
+
tabIndex: -1,
|
|
74
|
+
style: isHit && !isEmpty ? style : void 0
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
[isHit, isEmpty]
|
|
78
|
+
);
|
|
79
|
+
return { getEmptyProps };
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// src/autocomplete-icon.tsx
|
|
83
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
84
|
+
var AutocompleteIcon = (0, import_core2.forwardRef)(
|
|
85
|
+
({ className, children, __css, ...rest }, ref) => {
|
|
86
|
+
const { styles } = useAutocompleteContext();
|
|
87
|
+
const css = {
|
|
88
|
+
position: "absolute",
|
|
89
|
+
top: "50%",
|
|
90
|
+
transform: "translateY(-50%)",
|
|
91
|
+
display: "inline-flex",
|
|
92
|
+
alignItems: "center",
|
|
93
|
+
justifyContent: "center",
|
|
94
|
+
pointerEvents: "none",
|
|
95
|
+
cursor: "pointer",
|
|
96
|
+
...styles.icon,
|
|
97
|
+
...__css
|
|
98
|
+
};
|
|
99
|
+
const validChildren = (0, import_utils2.getValidChildren)(children);
|
|
100
|
+
const cloneChildren = validChildren.map(
|
|
101
|
+
(child) => (0, import_react2.cloneElement)(child, {
|
|
102
|
+
focusable: false,
|
|
103
|
+
"aria-hidden": true,
|
|
104
|
+
style: {
|
|
105
|
+
maxWidth: "1em",
|
|
106
|
+
maxHeight: "1em",
|
|
107
|
+
color: "currentColor"
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.div, { ref, className: (0, import_utils2.cx)("ui-autocomplete-icon", className), __css: css, ...rest, children: (0, import_utils2.isValidElement)(children) ? cloneChildren : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icon.ChevronIcon, {}) });
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
var AutocompleteItemIcon = (0, import_core2.forwardRef)(
|
|
115
|
+
({ className, ...rest }, ref) => {
|
|
116
|
+
const { styles } = useAutocompleteContext();
|
|
117
|
+
const css = {
|
|
118
|
+
flexShrink: 0,
|
|
119
|
+
display: "inline-flex",
|
|
120
|
+
justifyContent: "center",
|
|
121
|
+
alignItems: "center",
|
|
122
|
+
fontSize: "0.85em",
|
|
123
|
+
...styles.itemIcon
|
|
124
|
+
};
|
|
125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
126
|
+
import_core2.ui.span,
|
|
127
|
+
{
|
|
128
|
+
ref,
|
|
129
|
+
className: (0, import_utils2.cx)("ui-autocomplete-item-icon", className),
|
|
130
|
+
__css: css,
|
|
131
|
+
...rest
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// src/autocomplete-empty.tsx
|
|
138
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
139
|
+
var AutocompleteEmpty = (0, import_core3.forwardRef)(
|
|
140
|
+
({ className, icon, children, ...rest }, ref) => {
|
|
141
|
+
const { emptyMessage, styles } = useAutocompleteContext();
|
|
142
|
+
const { getEmptyProps } = useAutocompleteEmpty();
|
|
143
|
+
children != null ? children : children = emptyMessage;
|
|
144
|
+
const css = {
|
|
145
|
+
textDecoration: "none",
|
|
146
|
+
color: "inherit",
|
|
147
|
+
userSelect: "none",
|
|
148
|
+
display: "flex",
|
|
149
|
+
width: "100%",
|
|
150
|
+
alignItems: "center",
|
|
151
|
+
textAlign: "start",
|
|
152
|
+
flex: "0 0 auto",
|
|
153
|
+
outline: 0,
|
|
154
|
+
gap: "0.75rem",
|
|
155
|
+
pointerEvents: "none",
|
|
156
|
+
...styles.item
|
|
157
|
+
};
|
|
158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
159
|
+
import_core3.ui.li,
|
|
160
|
+
{
|
|
161
|
+
className: (0, import_utils3.cx)("ui-autocomplete-empty", className),
|
|
162
|
+
__css: css,
|
|
163
|
+
...getEmptyProps(rest, ref),
|
|
164
|
+
children: [
|
|
165
|
+
icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AutocompleteItemIcon, { children: icon || /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MinusIcon, {}) }) : null,
|
|
166
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.span, { style: { pointerEvents: "none", flex: 1 }, noOfLines: 1, children }) : children
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
var MinusIcon = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { viewBox: "0 0 448 512", width: "1em", height: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
173
|
+
"path",
|
|
174
|
+
{
|
|
175
|
+
fill: "currentColor",
|
|
176
|
+
d: "M432 256c0 17.7-14.3 32-32 32L48 288c-17.7 0-32-14.3-32-32s14.3-32 32-32l352 0c17.7 0 32 14.3 32 32z"
|
|
177
|
+
}
|
|
178
|
+
) });
|
|
179
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
180
|
+
0 && (module.exports = {
|
|
181
|
+
AutocompleteEmpty
|
|
182
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
+
import { FC } from 'react';
|
|
4
|
+
|
|
5
|
+
type AutocompleteIconProps = HTMLUIProps<'div'>;
|
|
6
|
+
declare const AutocompleteIcon: _yamada_ui_core.Component<"div", AutocompleteIconProps>;
|
|
7
|
+
type AutocompleteClearIconProps = AutocompleteIconProps & {
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const AutocompleteClearIcon: FC<AutocompleteClearIconProps>;
|
|
11
|
+
type AutocompleteItemIconProps = HTMLUIProps<'span'>;
|
|
12
|
+
declare const AutocompleteItemIcon: _yamada_ui_core.Component<"span", AutocompleteItemIconProps>;
|
|
13
|
+
|
|
14
|
+
export { AutocompleteClearIcon, AutocompleteClearIconProps, AutocompleteIcon, AutocompleteIconProps, AutocompleteItemIcon, AutocompleteItemIconProps };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/autocomplete-icon.tsx
|
|
21
|
+
var autocomplete_icon_exports = {};
|
|
22
|
+
__export(autocomplete_icon_exports, {
|
|
23
|
+
AutocompleteClearIcon: () => AutocompleteClearIcon,
|
|
24
|
+
AutocompleteIcon: () => AutocompleteIcon,
|
|
25
|
+
AutocompleteItemIcon: () => AutocompleteItemIcon
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(autocomplete_icon_exports);
|
|
28
|
+
var import_core2 = require("@yamada-ui/core");
|
|
29
|
+
var import_icon = require("@yamada-ui/icon");
|
|
30
|
+
var import_use_clickable = require("@yamada-ui/use-clickable");
|
|
31
|
+
var import_utils2 = require("@yamada-ui/utils");
|
|
32
|
+
var import_react2 = require("react");
|
|
33
|
+
|
|
34
|
+
// src/use-autocomplete.tsx
|
|
35
|
+
var import_core = require("@yamada-ui/core");
|
|
36
|
+
var import_form_control = require("@yamada-ui/form-control");
|
|
37
|
+
var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
|
|
38
|
+
var import_use_descendant = require("@yamada-ui/use-descendant");
|
|
39
|
+
var import_use_outside_click = require("@yamada-ui/use-outside-click");
|
|
40
|
+
var import_utils = require("@yamada-ui/utils");
|
|
41
|
+
var import_react = require("react");
|
|
42
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
+
var {
|
|
44
|
+
DescendantsContextProvider: AutocompleteDescendantsContextProvider,
|
|
45
|
+
useDescendantsContext: useAutocompleteDescendantsContext,
|
|
46
|
+
useDescendants: useAutocompleteDescendants,
|
|
47
|
+
useDescendant: useAutocompleteDescendant
|
|
48
|
+
} = (0, import_use_descendant.createDescendant)();
|
|
49
|
+
var [AutocompleteProvider, useAutocompleteContext] = (0, import_utils.createContext)({
|
|
50
|
+
name: "AutocompleteContext",
|
|
51
|
+
errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in "<Autocomplete />" or "<MultiAutocomplete />"`
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// src/autocomplete-icon.tsx
|
|
55
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
56
|
+
var AutocompleteIcon = (0, import_core2.forwardRef)(
|
|
57
|
+
({ className, children, __css, ...rest }, ref) => {
|
|
58
|
+
const { styles } = useAutocompleteContext();
|
|
59
|
+
const css = {
|
|
60
|
+
position: "absolute",
|
|
61
|
+
top: "50%",
|
|
62
|
+
transform: "translateY(-50%)",
|
|
63
|
+
display: "inline-flex",
|
|
64
|
+
alignItems: "center",
|
|
65
|
+
justifyContent: "center",
|
|
66
|
+
pointerEvents: "none",
|
|
67
|
+
cursor: "pointer",
|
|
68
|
+
...styles.icon,
|
|
69
|
+
...__css
|
|
70
|
+
};
|
|
71
|
+
const validChildren = (0, import_utils2.getValidChildren)(children);
|
|
72
|
+
const cloneChildren = validChildren.map(
|
|
73
|
+
(child) => (0, import_react2.cloneElement)(child, {
|
|
74
|
+
focusable: false,
|
|
75
|
+
"aria-hidden": true,
|
|
76
|
+
style: {
|
|
77
|
+
maxWidth: "1em",
|
|
78
|
+
maxHeight: "1em",
|
|
79
|
+
color: "currentColor"
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.div, { ref, className: (0, import_utils2.cx)("ui-autocomplete-icon", className), __css: css, ...rest, children: (0, import_utils2.isValidElement)(children) ? cloneChildren : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icon.ChevronIcon, {}) });
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
var AutocompleteClearIcon = ({
|
|
87
|
+
className,
|
|
88
|
+
children,
|
|
89
|
+
...props
|
|
90
|
+
}) => {
|
|
91
|
+
const ref = (0, import_react2.useRef)(null);
|
|
92
|
+
const { styles } = useAutocompleteContext();
|
|
93
|
+
const isDisabled = props.disabled;
|
|
94
|
+
const rest = (0, import_use_clickable.useClickable)({
|
|
95
|
+
ref,
|
|
96
|
+
isDisabled,
|
|
97
|
+
...props
|
|
98
|
+
});
|
|
99
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
100
|
+
AutocompleteIcon,
|
|
101
|
+
{
|
|
102
|
+
className: (0, import_utils2.cx)("ui-autocomplete-clear-icon", className),
|
|
103
|
+
__css: styles.clearIcon,
|
|
104
|
+
...rest,
|
|
105
|
+
children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icon.CloseIcon, { w: "0.5em", h: "0.5em" })
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
var AutocompleteItemIcon = (0, import_core2.forwardRef)(
|
|
110
|
+
({ className, ...rest }, ref) => {
|
|
111
|
+
const { styles } = useAutocompleteContext();
|
|
112
|
+
const css = {
|
|
113
|
+
flexShrink: 0,
|
|
114
|
+
display: "inline-flex",
|
|
115
|
+
justifyContent: "center",
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
fontSize: "0.85em",
|
|
118
|
+
...styles.itemIcon
|
|
119
|
+
};
|
|
120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
121
|
+
import_core2.ui.span,
|
|
122
|
+
{
|
|
123
|
+
ref,
|
|
124
|
+
className: (0, import_utils2.cx)("ui-autocomplete-item-icon", className),
|
|
125
|
+
__css: css,
|
|
126
|
+
...rest
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
132
|
+
0 && (module.exports = {
|
|
133
|
+
AutocompleteClearIcon,
|
|
134
|
+
AutocompleteIcon,
|
|
135
|
+
AutocompleteItemIcon
|
|
136
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
+
|
|
4
|
+
type AutocompleteListProps = HTMLUIProps<'ul'>;
|
|
5
|
+
declare const AutocompleteList: _yamada_ui_core.Component<"ul", AutocompleteListProps>;
|
|
6
|
+
|
|
7
|
+
export { AutocompleteList, AutocompleteListProps };
|