@tedi-design-system/react 14.4.0-rc.8 → 14.4.0-rc.9
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/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),r=require("../../../../../external/classnames/index.cjs.js"),y=require("react"),N=require("../../buttons/button/button.cjs.js"),j=require("../textfield/textfield.cjs.js"),t=require("./search.module.scss.cjs.js"),v=require("../../../providers/label-provider/use-labels.cjs.js"),u=y.forwardRef(({placeholder:c,isClearable:d=!0,searchIcon:n="search",onSearch:a,onChange:o,button:e,ariaLabel:f,...s},h)=>{const{getLabel:l}=v.useLabels(),m=q=>{q.key==="Enter"&&(a==null||a(s.value))},_=()=>{a==null||a(s.value)},x={...s,ref:h,inputClassName:r.default(t.default["tedi-search__input"],e&&t.default["tedi-search__input--has-button"]),placeholder:c,isClearable:d,onKeyDown:m,onChange:o,...e?{}:{icon:n}},b=c||l("search"),p=f??b;return i.jsxs("div",{className:r.default(t.default["tedi-search__wrapper"],s.className),role:"search","aria-label":p,children:[i.jsx(j.TextField,{...x}),e&&i.jsx(N.Button,{...e,onClick:_,className:r.default(t.default["tedi-search__button"],e.className),"aria-label":e.children?void 0:l("search"),children:e.children??l("search")})]})});u.displayName="Search";exports.Search=u;
|
|
@@ -15,5 +15,10 @@ export interface SearchProps extends Omit<TextFieldProps, 'isTextArea' | 'icon'
|
|
|
15
15
|
* Optional button properties.
|
|
16
16
|
*/
|
|
17
17
|
button?: Partial<ButtonProps>;
|
|
18
|
+
/**
|
|
19
|
+
* For accessibility: search field name (accessible name). Recommended to always set.
|
|
20
|
+
* E.g., "Search products" or "Search site".
|
|
21
|
+
*/
|
|
22
|
+
ariaLabel?: string;
|
|
18
23
|
}
|
|
19
24
|
export declare const Search: React.ForwardRefExoticComponent<SearchProps & React.RefAttributes<TextFieldForwardRef>>;
|
|
@@ -1,40 +1,42 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { Button as
|
|
5
|
-
import { TextField as
|
|
1
|
+
import { jsxs as y, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import l from "../../../../../external/classnames/index.es.js";
|
|
3
|
+
import { forwardRef as v } from "react";
|
|
4
|
+
import { Button as w } from "../../buttons/button/button.es.js";
|
|
5
|
+
import { TextField as L } from "../textfield/textfield.es.js";
|
|
6
6
|
import r from "./search.module.scss.es.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
import { useLabels as k } from "../../../providers/label-provider/use-labels.es.js";
|
|
8
|
+
const C = v(
|
|
9
|
+
({ placeholder: t, isClearable: m = !0, searchIcon: o = "search", onSearch: s, onChange: d, button: e, ariaLabel: p, ...a }, n) => {
|
|
10
|
+
const { getLabel: i } = k(), f = (x) => {
|
|
11
|
+
x.key === "Enter" && (s == null || s(a.value));
|
|
12
|
+
}, h = () => {
|
|
13
|
+
s == null || s(a.value);
|
|
13
14
|
}, _ = {
|
|
14
|
-
...
|
|
15
|
-
ref:
|
|
16
|
-
inputClassName:
|
|
17
|
-
placeholder:
|
|
15
|
+
...a,
|
|
16
|
+
ref: n,
|
|
17
|
+
inputClassName: l(r["tedi-search__input"], e && r["tedi-search__input--has-button"]),
|
|
18
|
+
placeholder: t,
|
|
18
19
|
isClearable: m,
|
|
19
|
-
|
|
20
|
-
onChange:
|
|
21
|
-
...e ? {} : { icon:
|
|
22
|
-
};
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
-
e && /* @__PURE__ */
|
|
26
|
-
|
|
20
|
+
onKeyDown: f,
|
|
21
|
+
onChange: d,
|
|
22
|
+
...e ? {} : { icon: o }
|
|
23
|
+
}, u = t || i("search"), N = p ?? u;
|
|
24
|
+
return /* @__PURE__ */ y("div", { className: l(r["tedi-search__wrapper"], a.className), role: "search", "aria-label": N, children: [
|
|
25
|
+
/* @__PURE__ */ c(L, { ..._ }),
|
|
26
|
+
e && /* @__PURE__ */ c(
|
|
27
|
+
w,
|
|
27
28
|
{
|
|
28
29
|
...e,
|
|
29
|
-
onClick:
|
|
30
|
-
className:
|
|
31
|
-
|
|
30
|
+
onClick: h,
|
|
31
|
+
className: l(r["tedi-search__button"], e.className),
|
|
32
|
+
"aria-label": e.children ? void 0 : i("search"),
|
|
33
|
+
children: e.children ?? i("search")
|
|
32
34
|
}
|
|
33
35
|
)
|
|
34
36
|
] });
|
|
35
37
|
}
|
|
36
38
|
);
|
|
37
|
-
|
|
39
|
+
C.displayName = "Search";
|
|
38
40
|
export {
|
|
39
|
-
|
|
41
|
+
C as Search
|
|
40
42
|
};
|