@bwp-web/components 1.0.1 → 1.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.
- package/README.md +237 -0
- package/dist/BiampGlobalSearch/BiampGlobalSearch.d.ts +21 -0
- package/dist/BiampGlobalSearch/BiampGlobalSearch.d.ts.map +1 -0
- package/dist/BiampGlobalSearch/index.d.ts +3 -0
- package/dist/BiampGlobalSearch/index.d.ts.map +1 -0
- package/dist/index.cjs +348 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +355 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1954,6 +1954,360 @@ function SegmentedButtonGroup({ children, sx, ...props }) {
|
|
|
1954
1954
|
}
|
|
1955
1955
|
);
|
|
1956
1956
|
}
|
|
1957
|
+
|
|
1958
|
+
// src/BiampGlobalSearch/BiampGlobalSearch.tsx
|
|
1959
|
+
import { createContext, forwardRef, useContext } from "react";
|
|
1960
|
+
import {
|
|
1961
|
+
Autocomplete,
|
|
1962
|
+
Box as Box11,
|
|
1963
|
+
Chip,
|
|
1964
|
+
InputAdornment as InputAdornment3,
|
|
1965
|
+
Paper,
|
|
1966
|
+
TextField as TextField3,
|
|
1967
|
+
Typography as Typography6
|
|
1968
|
+
} from "@mui/material";
|
|
1969
|
+
import { KeyArrowDownIcon, KeyArrowUpIcon, SearchIcon as SearchIcon3 } from "@bwp-web/assets";
|
|
1970
|
+
import { Fragment as Fragment4, jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1971
|
+
var SearchContext = createContext({
|
|
1972
|
+
hasOptions: true,
|
|
1973
|
+
loading: false,
|
|
1974
|
+
noResultsText: "No results found",
|
|
1975
|
+
query: ""
|
|
1976
|
+
});
|
|
1977
|
+
function KeyCap({
|
|
1978
|
+
children,
|
|
1979
|
+
variant = "icon"
|
|
1980
|
+
}) {
|
|
1981
|
+
return /* @__PURE__ */ jsx23(
|
|
1982
|
+
Box11,
|
|
1983
|
+
{
|
|
1984
|
+
component: "kbd",
|
|
1985
|
+
sx: {
|
|
1986
|
+
display: "inline-flex",
|
|
1987
|
+
alignItems: "center",
|
|
1988
|
+
justifyContent: "center",
|
|
1989
|
+
minWidth: 20,
|
|
1990
|
+
height: 20,
|
|
1991
|
+
px: variant === "text" ? "8px" : 0.5,
|
|
1992
|
+
borderRadius: "4px",
|
|
1993
|
+
bgcolor: "grey.100",
|
|
1994
|
+
color: "grey.400",
|
|
1995
|
+
fontFamily: "inherit",
|
|
1996
|
+
fontSize: "caption.fontSize",
|
|
1997
|
+
fontStyle: "normal",
|
|
1998
|
+
fontWeight: (theme) => theme.typography.fontWeightMedium,
|
|
1999
|
+
border: "none",
|
|
2000
|
+
"& svg": { width: 12, height: 12 }
|
|
2001
|
+
},
|
|
2002
|
+
children
|
|
2003
|
+
}
|
|
2004
|
+
);
|
|
2005
|
+
}
|
|
2006
|
+
var BiampGlobalSearchPaper = forwardRef(
|
|
2007
|
+
function BiampGlobalSearchPaper2({ children, ...props }, ref) {
|
|
2008
|
+
const { hasOptions, loading, noResultsText } = useContext(SearchContext);
|
|
2009
|
+
return /* @__PURE__ */ jsxs10(Paper, { ref, ...props, children: [
|
|
2010
|
+
hasOptions || loading ? children : /* @__PURE__ */ jsx23(
|
|
2011
|
+
Typography6,
|
|
2012
|
+
{
|
|
2013
|
+
variant: "body2",
|
|
2014
|
+
color: "text.secondary",
|
|
2015
|
+
sx: { px: 2, py: 1.5 },
|
|
2016
|
+
children: noResultsText
|
|
2017
|
+
}
|
|
2018
|
+
),
|
|
2019
|
+
hasOptions && /* @__PURE__ */ jsxs10(
|
|
2020
|
+
Box11,
|
|
2021
|
+
{
|
|
2022
|
+
sx: {
|
|
2023
|
+
borderTop: ({ palette }) => `0.6px solid ${palette.dividers.secondary}`,
|
|
2024
|
+
display: "flex",
|
|
2025
|
+
alignItems: "center",
|
|
2026
|
+
gap: 1,
|
|
2027
|
+
p: 1.5
|
|
2028
|
+
},
|
|
2029
|
+
children: [
|
|
2030
|
+
/* @__PURE__ */ jsxs10(Box11, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
2031
|
+
/* @__PURE__ */ jsxs10(Box11, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
|
|
2032
|
+
/* @__PURE__ */ jsx23(KeyCap, { children: /* @__PURE__ */ jsx23(KeyArrowDownIcon, {}) }),
|
|
2033
|
+
/* @__PURE__ */ jsx23(KeyCap, { children: /* @__PURE__ */ jsx23(KeyArrowUpIcon, {}) })
|
|
2034
|
+
] }),
|
|
2035
|
+
/* @__PURE__ */ jsx23(
|
|
2036
|
+
Typography6,
|
|
2037
|
+
{
|
|
2038
|
+
variant: "caption",
|
|
2039
|
+
fontWeight: (theme) => theme.typography.fontWeightMedium,
|
|
2040
|
+
color: "text.secondary",
|
|
2041
|
+
children: "Select"
|
|
2042
|
+
}
|
|
2043
|
+
)
|
|
2044
|
+
] }),
|
|
2045
|
+
/* @__PURE__ */ jsxs10(Box11, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
2046
|
+
/* @__PURE__ */ jsx23(KeyCap, { variant: "text", children: "Enter" }),
|
|
2047
|
+
/* @__PURE__ */ jsx23(
|
|
2048
|
+
Typography6,
|
|
2049
|
+
{
|
|
2050
|
+
variant: "caption",
|
|
2051
|
+
fontWeight: (theme) => theme.typography.fontWeightMedium,
|
|
2052
|
+
color: "text.secondary",
|
|
2053
|
+
children: "Open"
|
|
2054
|
+
}
|
|
2055
|
+
)
|
|
2056
|
+
] })
|
|
2057
|
+
]
|
|
2058
|
+
}
|
|
2059
|
+
)
|
|
2060
|
+
] });
|
|
2061
|
+
}
|
|
2062
|
+
);
|
|
2063
|
+
function HighlightText({ text, query }) {
|
|
2064
|
+
if (!query) return /* @__PURE__ */ jsx23(Fragment4, { children: text });
|
|
2065
|
+
const index = text.toLowerCase().indexOf(query.toLowerCase());
|
|
2066
|
+
if (index === -1) return /* @__PURE__ */ jsx23(Fragment4, { children: text });
|
|
2067
|
+
const before = text.slice(0, index);
|
|
2068
|
+
const match = text.slice(index, index + query.length);
|
|
2069
|
+
const after = text.slice(index + query.length);
|
|
2070
|
+
return /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
2071
|
+
before,
|
|
2072
|
+
/* @__PURE__ */ jsx23(
|
|
2073
|
+
Box11,
|
|
2074
|
+
{
|
|
2075
|
+
component: "span",
|
|
2076
|
+
sx: {
|
|
2077
|
+
bgcolor: "background.info",
|
|
2078
|
+
borderRadius: "4px",
|
|
2079
|
+
color: "info.main",
|
|
2080
|
+
paddingTop: "2px",
|
|
2081
|
+
paddingBottom: "2px"
|
|
2082
|
+
},
|
|
2083
|
+
children: match
|
|
2084
|
+
}
|
|
2085
|
+
),
|
|
2086
|
+
after
|
|
2087
|
+
] });
|
|
2088
|
+
}
|
|
2089
|
+
function BiampGlobalSearchListItem({
|
|
2090
|
+
option,
|
|
2091
|
+
props: liProps
|
|
2092
|
+
}) {
|
|
2093
|
+
const { query } = useContext(SearchContext);
|
|
2094
|
+
const { key, ...rest } = liProps;
|
|
2095
|
+
const maxChips = 3;
|
|
2096
|
+
const chips = option.associatedItems?.slice(0, maxChips) ?? [];
|
|
2097
|
+
const overflow = (option.associatedItems?.length ?? 0) - maxChips;
|
|
2098
|
+
return /* @__PURE__ */ jsxs10(
|
|
2099
|
+
"li",
|
|
2100
|
+
{
|
|
2101
|
+
...rest,
|
|
2102
|
+
style: {
|
|
2103
|
+
display: "flex",
|
|
2104
|
+
alignItems: "center",
|
|
2105
|
+
width: "100%",
|
|
2106
|
+
gap: 8,
|
|
2107
|
+
...rest.style
|
|
2108
|
+
},
|
|
2109
|
+
children: [
|
|
2110
|
+
option.icon && /* @__PURE__ */ jsx23(
|
|
2111
|
+
Box11,
|
|
2112
|
+
{
|
|
2113
|
+
sx: {
|
|
2114
|
+
width: 24,
|
|
2115
|
+
height: 24,
|
|
2116
|
+
flexShrink: 0,
|
|
2117
|
+
display: "flex",
|
|
2118
|
+
alignItems: "center",
|
|
2119
|
+
justifyContent: "center"
|
|
2120
|
+
},
|
|
2121
|
+
children: option.icon
|
|
2122
|
+
}
|
|
2123
|
+
),
|
|
2124
|
+
/* @__PURE__ */ jsx23(Typography6, { variant: "body2", noWrap: true, sx: { flexShrink: 0 }, children: /* @__PURE__ */ jsx23(HighlightText, { text: option.title, query }) }),
|
|
2125
|
+
option.subtitle && /* @__PURE__ */ jsx23(
|
|
2126
|
+
Typography6,
|
|
2127
|
+
{
|
|
2128
|
+
className: "hoverContent",
|
|
2129
|
+
variant: "body2",
|
|
2130
|
+
color: "text.secondary",
|
|
2131
|
+
noWrap: true,
|
|
2132
|
+
sx: { flexShrink: 1, minWidth: 0, display: "none" },
|
|
2133
|
+
children: option.subtitle
|
|
2134
|
+
}
|
|
2135
|
+
),
|
|
2136
|
+
chips.length > 0 && /* @__PURE__ */ jsxs10(
|
|
2137
|
+
Box11,
|
|
2138
|
+
{
|
|
2139
|
+
className: "hoverContent",
|
|
2140
|
+
sx: {
|
|
2141
|
+
display: "none",
|
|
2142
|
+
alignItems: "center",
|
|
2143
|
+
gap: 1,
|
|
2144
|
+
ml: "auto",
|
|
2145
|
+
flexShrink: 0,
|
|
2146
|
+
px: 2
|
|
2147
|
+
},
|
|
2148
|
+
children: [
|
|
2149
|
+
chips.map((item, i) => /* @__PURE__ */ jsx23(
|
|
2150
|
+
Chip,
|
|
2151
|
+
{
|
|
2152
|
+
size: "small",
|
|
2153
|
+
label: item.label,
|
|
2154
|
+
sx: {
|
|
2155
|
+
bgcolor: "background.info",
|
|
2156
|
+
borderRadius: "2px",
|
|
2157
|
+
borderColor: ({ palette }) => palette.dividers.primary,
|
|
2158
|
+
padding: "0px 6px",
|
|
2159
|
+
"& .MuiChip-label": {
|
|
2160
|
+
typography: "caption",
|
|
2161
|
+
fontWeight: (theme) => theme.typography.fontWeightMedium
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
},
|
|
2165
|
+
i
|
|
2166
|
+
)),
|
|
2167
|
+
overflow > 0 && /* @__PURE__ */ jsx23(
|
|
2168
|
+
Chip,
|
|
2169
|
+
{
|
|
2170
|
+
size: "small",
|
|
2171
|
+
label: `+${overflow}`,
|
|
2172
|
+
sx: {
|
|
2173
|
+
bgcolor: "background.info",
|
|
2174
|
+
borderRadius: "2px",
|
|
2175
|
+
borderColor: ({ palette }) => palette.dividers.primary,
|
|
2176
|
+
padding: "0px 6px",
|
|
2177
|
+
"& .MuiChip-label": {
|
|
2178
|
+
typography: "caption",
|
|
2179
|
+
fontWeight: (theme) => theme.typography.fontWeightMedium
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
)
|
|
2184
|
+
]
|
|
2185
|
+
}
|
|
2186
|
+
),
|
|
2187
|
+
option.endIcon && /* @__PURE__ */ jsx23(
|
|
2188
|
+
Box11,
|
|
2189
|
+
{
|
|
2190
|
+
className: "endIcon",
|
|
2191
|
+
sx: {
|
|
2192
|
+
width: 48,
|
|
2193
|
+
height: 48,
|
|
2194
|
+
flexShrink: 0,
|
|
2195
|
+
display: "flex",
|
|
2196
|
+
alignItems: "center",
|
|
2197
|
+
justifyContent: "center",
|
|
2198
|
+
ml: chips.length > 0 ? 0 : "auto",
|
|
2199
|
+
visibility: "hidden",
|
|
2200
|
+
"& .MuiSvgIcon-root": { fontSize: 14 }
|
|
2201
|
+
},
|
|
2202
|
+
children: option.endIcon
|
|
2203
|
+
}
|
|
2204
|
+
)
|
|
2205
|
+
]
|
|
2206
|
+
},
|
|
2207
|
+
key
|
|
2208
|
+
);
|
|
2209
|
+
}
|
|
2210
|
+
function BiampGlobalSearch({
|
|
2211
|
+
placeholder = "Search...",
|
|
2212
|
+
noResultsText = "No results found",
|
|
2213
|
+
options = [],
|
|
2214
|
+
inputValue: inputValueProp,
|
|
2215
|
+
loading = false,
|
|
2216
|
+
clearOnSelect = true,
|
|
2217
|
+
onChange,
|
|
2218
|
+
onInputChange,
|
|
2219
|
+
...props
|
|
2220
|
+
}) {
|
|
2221
|
+
const hasOptions = options.length > 0;
|
|
2222
|
+
const handleChange = (event, value, reason, details) => {
|
|
2223
|
+
if (value && typeof value !== "string" && value.onClick) {
|
|
2224
|
+
value.onClick();
|
|
2225
|
+
}
|
|
2226
|
+
onChange?.(event, value, reason, details);
|
|
2227
|
+
};
|
|
2228
|
+
const handleInputChange = (event, value, reason) => {
|
|
2229
|
+
if (clearOnSelect && (reason === "selectOption" || reason === "reset")) {
|
|
2230
|
+
onInputChange?.(event, "", reason);
|
|
2231
|
+
return;
|
|
2232
|
+
}
|
|
2233
|
+
onInputChange?.(event, value, reason);
|
|
2234
|
+
};
|
|
2235
|
+
return /* @__PURE__ */ jsx23(
|
|
2236
|
+
SearchContext.Provider,
|
|
2237
|
+
{
|
|
2238
|
+
value: {
|
|
2239
|
+
hasOptions,
|
|
2240
|
+
loading,
|
|
2241
|
+
noResultsText,
|
|
2242
|
+
query: inputValueProp ?? ""
|
|
2243
|
+
},
|
|
2244
|
+
children: /* @__PURE__ */ jsx23(
|
|
2245
|
+
Autocomplete,
|
|
2246
|
+
{
|
|
2247
|
+
options,
|
|
2248
|
+
inputValue: inputValueProp,
|
|
2249
|
+
loading,
|
|
2250
|
+
onChange: handleChange,
|
|
2251
|
+
onInputChange: handleInputChange,
|
|
2252
|
+
loadingText: /* @__PURE__ */ jsx23(Typography6, { variant: "body2", color: "text.secondary", children: "Loading\u2026" }),
|
|
2253
|
+
freeSolo: true,
|
|
2254
|
+
filterOptions: (x) => x,
|
|
2255
|
+
getOptionLabel: (option) => typeof option === "string" ? option : option.title,
|
|
2256
|
+
noOptionsText: noResultsText,
|
|
2257
|
+
slots: { paper: BiampGlobalSearchPaper },
|
|
2258
|
+
slotProps: {
|
|
2259
|
+
listbox: {
|
|
2260
|
+
sx: {
|
|
2261
|
+
"& .MuiAutocomplete-option": {
|
|
2262
|
+
paddingRight: "0px !important"
|
|
2263
|
+
},
|
|
2264
|
+
"& li:hover .hoverContent, & li.Mui-focused .hoverContent": {
|
|
2265
|
+
display: "flex"
|
|
2266
|
+
},
|
|
2267
|
+
"& li:hover p.hoverContent, & li.Mui-focused p.hoverContent": {
|
|
2268
|
+
display: "block"
|
|
2269
|
+
},
|
|
2270
|
+
"& li:hover .endIcon, & li.Mui-focused .endIcon": {
|
|
2271
|
+
visibility: "visible"
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
},
|
|
2276
|
+
renderInput: (params) => /* @__PURE__ */ jsx23(
|
|
2277
|
+
TextField3,
|
|
2278
|
+
{
|
|
2279
|
+
...params,
|
|
2280
|
+
placeholder,
|
|
2281
|
+
fullWidth: true,
|
|
2282
|
+
sx: {
|
|
2283
|
+
"& .MuiOutlinedInput-root": { padding: "0px !important" },
|
|
2284
|
+
"& .MuiInputBase-input": { paddingLeft: "8px !important" }
|
|
2285
|
+
},
|
|
2286
|
+
slotProps: {
|
|
2287
|
+
input: {
|
|
2288
|
+
...params.InputProps,
|
|
2289
|
+
startAdornment: /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
2290
|
+
/* @__PURE__ */ jsx23(InputAdornment3, { position: "start", children: /* @__PURE__ */ jsx23(SearchIcon3, {}) }),
|
|
2291
|
+
params.InputProps.startAdornment
|
|
2292
|
+
] })
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
),
|
|
2297
|
+
renderOption: (optionProps, option) => /* @__PURE__ */ jsx23(
|
|
2298
|
+
BiampGlobalSearchListItem,
|
|
2299
|
+
{
|
|
2300
|
+
option,
|
|
2301
|
+
props: optionProps
|
|
2302
|
+
},
|
|
2303
|
+
optionProps.key
|
|
2304
|
+
),
|
|
2305
|
+
...props
|
|
2306
|
+
}
|
|
2307
|
+
)
|
|
2308
|
+
}
|
|
2309
|
+
);
|
|
2310
|
+
}
|
|
1957
2311
|
export {
|
|
1958
2312
|
BIAMP_TABLE_DEBOUNCE_DELAY,
|
|
1959
2313
|
BiampAppDialog,
|
|
@@ -1963,6 +2317,7 @@ export {
|
|
|
1963
2317
|
BiampBannerActions,
|
|
1964
2318
|
BiampBannerContent,
|
|
1965
2319
|
BiampBannerIcon,
|
|
2320
|
+
BiampGlobalSearch,
|
|
1966
2321
|
BiampHeader,
|
|
1967
2322
|
BiampHeaderActions,
|
|
1968
2323
|
BiampHeaderButton,
|