ag-common 0.0.553 → 0.0.555

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 (42) hide show
  1. package/dist/ui/components/FlexColumn/index.js +5 -7
  2. package/dist/ui/components/FlexRow/index.js +2 -6
  3. package/dist/ui/components/Icon/index.js +6 -2
  4. package/dist/ui/components/RadioGroup/Base.d.ts +16 -0
  5. package/dist/ui/components/{TextEdit/RadioGroup.js → RadioGroup/Base.js} +36 -19
  6. package/dist/ui/components/RadioGroup/DarkMode.d.ts +13 -0
  7. package/dist/ui/components/RadioGroup/DarkMode.js +94 -0
  8. package/dist/ui/components/RadioGroup/index.d.ts +2 -0
  9. package/dist/ui/components/RadioGroup/index.js +18 -0
  10. package/dist/ui/components/RadioGroup/types.d.ts +5 -0
  11. package/dist/ui/components/RadioGroup/types.js +9 -0
  12. package/dist/ui/components/RowOrColumn/index.d.ts +3 -3
  13. package/dist/ui/components/RowOrColumn/index.js +11 -8
  14. package/dist/ui/components/Search/Inline.d.ts +2 -2
  15. package/dist/ui/components/Search/Inline.js +120 -3
  16. package/dist/ui/components/Search/Modal.js +2 -2
  17. package/dist/ui/components/Search/index.d.ts +1 -1
  18. package/dist/ui/components/Search/index.js +1 -1
  19. package/dist/ui/components/Search/types.d.ts +0 -1
  20. package/dist/ui/components/TextEdit/CheckboxEdit.js +1 -1
  21. package/dist/ui/components/TextEdit/index.d.ts +0 -1
  22. package/dist/ui/components/TextEdit/index.js +0 -1
  23. package/dist/ui/components/index.d.ts +1 -0
  24. package/dist/ui/components/index.js +1 -0
  25. package/dist/ui/helpers/cookie/get.js +2 -2
  26. package/dist/ui/helpers/cookie/set.js +1 -1
  27. package/dist/ui/helpers/cookie/use.js +6 -2
  28. package/dist/ui/icons/Checkmark.js +1 -1
  29. package/dist/ui/icons/Circle.js +1 -1
  30. package/dist/ui/icons/Computer.d.ts +8 -0
  31. package/dist/ui/icons/Computer.js +10 -0
  32. package/dist/ui/icons/Magnify.js +1 -1
  33. package/dist/ui/icons/Moon.d.ts +8 -0
  34. package/dist/ui/icons/Moon.js +10 -0
  35. package/dist/ui/icons/Sun.d.ts +6 -0
  36. package/dist/ui/icons/Sun.js +19 -0
  37. package/dist/ui/icons/index.d.ts +3 -0
  38. package/dist/ui/icons/index.js +3 -0
  39. package/package.json +1 -1
  40. package/dist/ui/components/Search/Base.d.ts +0 -5
  41. package/dist/ui/components/Search/Base.js +0 -127
  42. package/dist/ui/components/TextEdit/RadioGroup.d.ts +0 -14
@@ -12,21 +12,19 @@ const Base = styled_1.default.div `
12
12
  display: flex;
13
13
  flex-flow: column;
14
14
  flex-grow: 1;
15
+ width: 100%;
16
+ height: 100%;
15
17
  &[data-center='true'] {
16
18
  justify-content: center;
17
19
  align-items: center;
18
20
  }
19
21
  &[data-nogrow='true'] {
20
22
  flex-grow: 0;
21
- }
22
- overflow: visible;
23
- &[data-enableoverflow='false'] {
24
- overflow: hidden;
25
- max-width: 100%;
23
+ width: unset;
26
24
  }
27
25
  `;
28
26
  const FlexColumn = (props) => {
29
- var _a, _b, _c;
30
- return (react_1.default.createElement(Base, Object.assign({ title: props.title, "data-nogrow": (_a = props.noGrow) !== null && _a !== void 0 ? _a : false, "data-center": (_b = props.center) !== null && _b !== void 0 ? _b : false, "data-enableoverflow": (_c = props.enableOverflow) !== null && _c !== void 0 ? _c : false }, props), props.children));
27
+ var _a, _b;
28
+ return (react_1.default.createElement(Base, Object.assign({ "data-nogrow": (_a = props.noGrow) !== null && _a !== void 0 ? _a : false, "data-center": (_b = props.center) !== null && _b !== void 0 ? _b : false }, props), props.children));
31
29
  };
32
30
  exports.FlexColumn = FlexColumn;
@@ -30,13 +30,9 @@ const Base = styled_1.default.div `
30
30
  justify-content: center;
31
31
  align-items: center;
32
32
  }
33
-
34
- &[data-enableoverflow='true'] {
35
- overflow: visible;
36
- }
37
33
  `;
38
34
  const FlexRow = (props) => {
39
- var _a, _b, _c, _d;
40
- return (react_1.default.createElement(Base, Object.assign({ title: props.title, "data-nowrap": (_a = props.noWrap) !== null && _a !== void 0 ? _a : false, "data-nogrow": (_b = props.noGrow) !== null && _b !== void 0 ? _b : false, "data-center": (_c = props.center) !== null && _c !== void 0 ? _c : false, "data-enableoverflow": (_d = props.enableOverflow) !== null && _d !== void 0 ? _d : false }, props), props.children));
35
+ var _a, _b, _c;
36
+ return (react_1.default.createElement(Base, Object.assign({ "data-nowrap": (_a = props.noWrap) !== null && _a !== void 0 ? _a : false, "data-nogrow": (_b = props.noGrow) !== null && _b !== void 0 ? _b : false, "data-center": (_c = props.center) !== null && _c !== void 0 ? _c : false }, props), props.children));
41
37
  };
42
38
  exports.FlexRow = FlexRow;
@@ -16,6 +16,10 @@ exports.IconF = styled_1.default.span `
16
16
  align-items: center;
17
17
  font-size: 2rem;
18
18
  cursor: inherit;
19
+ width: 100%;
20
+ height: 100%;
21
+ padding: 0;
22
+ margin: unset;
19
23
  &[data-chnd='true'] {
20
24
  cursor: pointer;
21
25
  &:hover {
@@ -53,7 +57,7 @@ const Icon = (pr) => {
53
57
  var _a, _b, _c, _d, _e, _f, _g, _h;
54
58
  const { className, children, disabled, onClick } = pr;
55
59
  const CHND = pr.canHover && !pr.disabled;
56
- const style = (0, object_1.removeUndefValuesFromObject)(Object.assign(Object.assign({}, ((_a = pr === null || pr === void 0 ? void 0 : pr.style) !== null && _a !== void 0 ? _a : {})), { '--fill': (_c = (_b = pr.style) === null || _b === void 0 ? void 0 : _b.fill) !== null && _c !== void 0 ? _c : null, width: ((_d = pr.style) === null || _d === void 0 ? void 0 : _d.width) || '100%', height: ((_e = pr.style) === null || _e === void 0 ? void 0 : _e.height) || '100%', padding: ((_f = pr.style) === null || _f === void 0 ? void 0 : _f.padding) || '0', margin: ((_g = pr.style) === null || _g === void 0 ? void 0 : _g.margin) || 'unset', transform: !pr.rotate ? null : `rotate(${pr.rotate || 0}deg)`, filter: !pr.disabled ? null : 'grayscale(1)', '--outlinecolour': pr.outline || null }));
57
- return (react_1.default.createElement(exports.IconF, Object.assign({}, pr, { className: className, onClick: (e) => !disabled && (onClick === null || onClick === void 0 ? void 0 : onClick(e)), style: style, "data-chnd": CHND, "data-hasoutline": pr.outline, "data-hasfill": !!((_h = pr.style) === null || _h === void 0 ? void 0 : _h.fill) }), children));
60
+ const style = (0, object_1.removeUndefValuesFromObject)(Object.assign(Object.assign({}, ((_a = pr === null || pr === void 0 ? void 0 : pr.style) !== null && _a !== void 0 ? _a : {})), { '--fill': (_c = (_b = pr.style) === null || _b === void 0 ? void 0 : _b.fill) !== null && _c !== void 0 ? _c : null, width: (_d = pr.style) === null || _d === void 0 ? void 0 : _d.width, height: (_e = pr.style) === null || _e === void 0 ? void 0 : _e.height, padding: (_f = pr.style) === null || _f === void 0 ? void 0 : _f.padding, margin: (_g = pr.style) === null || _g === void 0 ? void 0 : _g.margin, transform: !pr.rotate ? null : `rotate(${pr.rotate || 0}deg)`, filter: !pr.disabled ? null : 'grayscale(1)', '--outlinecolour': pr.outline || null }));
61
+ return (react_1.default.createElement(exports.IconF, Object.assign({}, pr, { className: className, onClick: (e) => !disabled && (onClick === null || onClick === void 0 ? void 0 : onClick(e)), style: style, "data-chnd": CHND, "data-hasoutline": pr.outline, "data-hasfill": !!((_h = pr.style) === null || _h === void 0 ? void 0 : _h.fill), "data-type": "iconbox" }), children));
58
62
  };
59
63
  exports.Icon = Icon;
@@ -0,0 +1,16 @@
1
+ import type { CSSProperties } from 'react';
2
+ import React from 'react';
3
+ export interface IRadioGroup<T> {
4
+ /**
5
+ * can overload the render of the label. defaults to toString
6
+ */
7
+ renderLabel?: (a: T, selected: boolean) => JSX.Element;
8
+ defaultIndex: number;
9
+ onSubmit: (val: T, index: number) => void;
10
+ values: T[];
11
+ className?: string;
12
+ style?: CSSProperties;
13
+ /** default horiz */
14
+ mode?: 'vert' | 'horiz';
15
+ }
16
+ export declare const RadioGroup: <T>(p: IRadioGroup<T>) => React.JSX.Element;
@@ -31,25 +31,42 @@ exports.RadioGroup = void 0;
31
31
  const styled_1 = __importDefault(require("@emotion/styled"));
32
32
  const react_1 = __importStar(require("react"));
33
33
  const common_1 = require("../../styles/common");
34
- const FlexColumn_1 = require("../FlexColumn");
35
- const common_2 = require("./common");
36
- const Label = styled_1.default.label ``;
37
- const RadioGroup = ({ defaultValue, onSubmit, values,
38
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
- renderLabel = (e) => e.toString(),
40
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
- renderValue = (e) => e.toString(), }) => {
42
- const [value, setValue] = (0, react_1.useState)(renderValue(defaultValue));
43
- (0, react_1.useEffect)(() => {
44
- const rv = renderValue(defaultValue);
45
- if (value !== rv) {
46
- setValue(rv);
47
- }
48
- }, [defaultValue, renderValue, value]);
49
- return (react_1.default.createElement(common_2.ValueBox, Object.assign({}, common_1.noDrag), values.map((v) => (
34
+ const Base = styled_1.default.div `
35
+ display: flex;
36
+ flex-flow: row;
37
+ &[data-mode='vert'] {
38
+ flex-flow: column;
39
+ }
40
+ border-radius: 2rem;
41
+ overflow: hidden;
42
+ justify-content: space-between;
43
+ `;
44
+ const Label = styled_1.default.label `
45
+ text-align: center;
46
+ overflow: hidden;
47
+
48
+ &[data-selected='true'] {
49
+ cursor: default;
50
+ }
51
+ &[data-selected='false'] {
52
+ cursor: pointer;
53
+ }
54
+ `;
55
+ const RadioGroup = (p) => {
56
+ var _a, _b;
50
57
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
- react_1.default.createElement(FlexColumn_1.FlexColumn, { key: v.toString() },
52
- react_1.default.createElement(Label, null, renderLabel(v)),
53
- react_1.default.createElement("input", { type: "radio", key: renderValue(v), value: renderValue(v), checked: renderValue(v) === value, onChange: () => onSubmit(v) }))))));
58
+ const { renderLabel = (x) => x.toString() } = p;
59
+ const [index, setIndex] = (0, react_1.useState)((_a = p.defaultIndex) !== null && _a !== void 0 ? _a : 0);
60
+ return (react_1.default.createElement(Base, Object.assign({}, common_1.noDrag, { className: p.className, style: p.style, "data-mode": (_b = p.mode) !== null && _b !== void 0 ? _b : 'horiz' }), p.values.map((v, i) => (react_1.default.createElement(Label
61
+ // eslint-disable-next-line react/no-array-index-key
62
+ , {
63
+ // eslint-disable-next-line react/no-array-index-key
64
+ key: i.toString(), "data-selected": index === i, onClick: () => {
65
+ if (index === i) {
66
+ return;
67
+ }
68
+ setIndex(i);
69
+ p.onSubmit(v, i);
70
+ } }, renderLabel(v, index === i))))));
54
71
  };
55
72
  exports.RadioGroup = RadioGroup;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { TDarkMode } from './types';
3
+ export interface IDarkMode {
4
+ onSubmit?: (p: TDarkMode) => void;
5
+ /** default horiz */
6
+ mode?: 'vert' | 'horiz';
7
+ /** default 2.5rem */
8
+ iconSize?: string;
9
+ className?: string;
10
+ cookieDocument: string;
11
+ }
12
+ /** shows darkmode toggle. Persists to cookie, and modifies html classList with either dark-mode or light-mode */
13
+ export declare const DarkMode: (p: IDarkMode) => React.JSX.Element;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DarkMode = void 0;
8
+ const styled_1 = __importDefault(require("@emotion/styled"));
9
+ const react_1 = __importDefault(require("react"));
10
+ const use_1 = require("../../helpers/cookie/use");
11
+ const icons_1 = require("../../icons");
12
+ const FlexColumn_1 = require("../FlexColumn");
13
+ const Icon_1 = require("../Icon");
14
+ const Base_1 = require("./Base");
15
+ const types_1 = require("./types");
16
+ const IconStyled = (0, styled_1.default)(Icon_1.Icon) `
17
+ > svg {
18
+ height: 60%;
19
+ }
20
+ `;
21
+ const Label = (0, styled_1.default)(FlexColumn_1.FlexColumn) `
22
+ border-radius: 50%;
23
+ overflow: hidden;
24
+ &[data-selected='true'] {
25
+ background-color: white;
26
+ }
27
+ `;
28
+ const getColours = (p, vert) => {
29
+ const deg = vert ? '180deg' : '90deg';
30
+ switch (p) {
31
+ case types_1.TDarkMode.dark: {
32
+ const d1 = 'rgba(173,128,227,1)';
33
+ const d2 = 'rgba(106,44,181,1)';
34
+ return [d1, `linear-gradient(${deg}, ${d1} 0%, ${d2} 76%)`];
35
+ }
36
+ case types_1.TDarkMode.light: {
37
+ const l1 = 'rgba(255,169,54,1)';
38
+ const l2 = 'rgba(255,189,100,1)';
39
+ return [l1, `linear-gradient(${deg}, ${l1} 0%, ${l2} 76%)`];
40
+ }
41
+ case types_1.TDarkMode.system: {
42
+ return ['green', 'green'];
43
+ }
44
+ }
45
+ };
46
+ const modes = [
47
+ { mode: types_1.TDarkMode.dark, icon: icons_1.Moon },
48
+ { mode: types_1.TDarkMode.system, icon: icons_1.Computer },
49
+ { mode: types_1.TDarkMode.light, icon: icons_1.Sun },
50
+ ];
51
+ /** shows darkmode toggle. Persists to cookie, and modifies html classList with either dark-mode or light-mode */
52
+ const DarkMode = (p) => {
53
+ const { iconSize = '2.5rem' } = p;
54
+ const [darkmode, setDarkmodeRaw] = (0, use_1.useCookie)({
55
+ defaultValue: types_1.TDarkMode.system,
56
+ name: 'darkmode',
57
+ cookieDocument: p.cookieDocument,
58
+ parse: (v) => Number(v),
59
+ stringify: (v) => v.toString(),
60
+ });
61
+ const index = modes.findIndex((d) => d.mode === darkmode);
62
+ const [fill, background] = getColours(modes[index].mode, p.mode === 'vert');
63
+ const twCalc = `calc(${iconSize} + ${iconSize} + ${iconSize} + 20px)`;
64
+ const setDarkmode = (newDarkMode) => {
65
+ var _a;
66
+ let className = '';
67
+ if (newDarkMode === types_1.TDarkMode.dark) {
68
+ className += 'dark-mode';
69
+ }
70
+ else if (newDarkMode === types_1.TDarkMode.light) {
71
+ className += 'light-mode';
72
+ }
73
+ else {
74
+ className = '';
75
+ }
76
+ document.getElementsByTagName('html')[0].classList.remove('dark-mode');
77
+ document.getElementsByTagName('html')[0].classList.remove('light-mode');
78
+ if (className) {
79
+ document.getElementsByTagName('html')[0].classList.add(className);
80
+ }
81
+ setDarkmodeRaw(newDarkMode);
82
+ (_a = p.onSubmit) === null || _a === void 0 ? void 0 : _a.call(p, newDarkMode);
83
+ };
84
+ return (react_1.default.createElement(Base_1.RadioGroup, { className: p.className, mode: p.mode, values: modes, defaultIndex: index, onSubmit: ({ mode }) => {
85
+ setDarkmode(mode);
86
+ }, style: Object.assign({ background, border: `solid 2px ${fill}`, width: twCalc, height: iconSize }, (p.mode === 'vert' && {
87
+ width: iconSize,
88
+ height: twCalc,
89
+ })), renderLabel: (v, selected) => {
90
+ return (react_1.default.createElement(Label, { "data-selected": selected, style: { width: iconSize, height: iconSize } },
91
+ react_1.default.createElement(IconStyled, null, v.icon({ style: { fill: selected ? fill : 'white' } }))));
92
+ } }));
93
+ };
94
+ exports.DarkMode = DarkMode;
@@ -0,0 +1,2 @@
1
+ export * from './Base';
2
+ export * from './DarkMode';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Base"), exports);
18
+ __exportStar(require("./DarkMode"), exports);
@@ -0,0 +1,5 @@
1
+ export declare enum TDarkMode {
2
+ 'dark' = 0,
3
+ 'light' = 1,
4
+ 'system' = 2
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TDarkMode = void 0;
4
+ var TDarkMode;
5
+ (function (TDarkMode) {
6
+ TDarkMode[TDarkMode["dark"] = 0] = "dark";
7
+ TDarkMode[TDarkMode["light"] = 1] = "light";
8
+ TDarkMode[TDarkMode["system"] = 2] = "system";
9
+ })(TDarkMode || (exports.TDarkMode = TDarkMode = {}));
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from 'react';
1
+ import type { CSSProperties, ReactNode } from 'react';
2
2
  import React from 'react';
3
3
  export interface IRowOrColumn {
4
4
  noGrow?: boolean;
@@ -6,8 +6,8 @@ export interface IRowOrColumn {
6
6
  noWrap?: boolean;
7
7
  children: ReactNode;
8
8
  className?: string;
9
- title?: string;
10
- enableOverflow?: boolean;
9
+ break?: 'small' | 'vsmall';
10
+ style?: CSSProperties;
11
11
  }
12
12
  export type IFlexColumn = IRowOrColumn;
13
13
  export type IFlexRow = IRowOrColumn;
@@ -10,7 +10,7 @@ const react_1 = __importDefault(require("react"));
10
10
  const media_1 = require("../../styles/media");
11
11
  const Base = styled_1.default.div `
12
12
  display: flex;
13
- flex-flow: row wrap;
13
+ flex-flow: row;
14
14
  flex-grow: 1;
15
15
  width: 100%;
16
16
  @media ${media_1.bigScreen} {
@@ -18,10 +18,16 @@ const Base = styled_1.default.div `
18
18
  flex-flow: row;
19
19
  }
20
20
  }
21
+ &[data-break='small'] {
22
+ @media ${media_1.smallScreen} {
23
+ flex-flow: column;
24
+ }
25
+ }
21
26
 
22
- @media ${media_1.smallScreen} {
23
- flex-flow: column;
24
- overflow: unset;
27
+ &[data-break='vsmall'] {
28
+ @media ${media_1.vSmallScreen} {
29
+ flex-flow: column;
30
+ }
25
31
  }
26
32
 
27
33
  &[data-center='true'] {
@@ -32,12 +38,9 @@ const Base = styled_1.default.div `
32
38
  flex-grow: 0;
33
39
  width: auto;
34
40
  }
35
- &[data-enableoverflow='true'] {
36
- overflow: visible;
37
- }
38
41
  `;
39
42
  const RowOrColumn = (props) => {
40
43
  var _a, _b, _c, _d;
41
- return (react_1.default.createElement(Base, Object.assign({ title: props.title, "data-nogrow": (_a = props.noGrow) !== null && _a !== void 0 ? _a : false, "data-center": (_b = props.center) !== null && _b !== void 0 ? _b : false, "data-nowrap": (_c = props.noWrap) !== null && _c !== void 0 ? _c : false, "data-enableoverflow": (_d = props.enableOverflow) !== null && _d !== void 0 ? _d : false }, props), props.children));
44
+ return (react_1.default.createElement(Base, Object.assign({ "data-nogrow": (_a = props.noGrow) !== null && _a !== void 0 ? _a : false, "data-center": (_b = props.center) !== null && _b !== void 0 ? _b : false, "data-nowrap": (_c = props.noWrap) !== null && _c !== void 0 ? _c : false }, props, { "data-break": (_d = props.break) !== null && _d !== void 0 ? _d : 'small' }), props.children));
42
45
  };
43
46
  exports.RowOrColumn = RowOrColumn;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- import type { ISearchInline } from './types';
3
- export declare const SearchInline: <T>(p: ISearchInline<T>) => React.JSX.Element;
2
+ import type { ISearchDialog } from './types';
3
+ export declare const SearchInline: <T>(p: ISearchDialog<T>) => React.JSX.Element;
@@ -1,10 +1,127 @@
1
1
  "use strict";
2
+ 'use client';
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
2
26
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
28
  };
5
29
  Object.defineProperty(exports, "__esModule", { value: true });
6
30
  exports.SearchInline = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const Base_1 = require("./Base");
9
- const SearchInline = (p) => (react_1.default.createElement(Base_1.SearchBase, Object.assign({}, p)));
31
+ const styled_1 = __importDefault(require("@emotion/styled"));
32
+ const react_1 = __importStar(require("react"));
33
+ const array_1 = require("../../../common/helpers/array");
34
+ const styles_1 = require("../../styles");
35
+ const SearchBox_1 = require("./SearchBox");
36
+ const Base = styled_1.default.div `
37
+ display: flex;
38
+ flex-flow: column;
39
+ flex-grow: 1;
40
+ width: 100%;
41
+ height: calc(100% - 1rem);
42
+ @media ${styles_1.smallScreen} {
43
+ height: calc(100% - 0.5rem);
44
+ }
45
+ `;
46
+ const Content = styled_1.default.div `
47
+ width: calc(100% - 2rem);
48
+ margin: auto;
49
+ display: flex;
50
+ flex-flow: column;
51
+ justify-content: flex-start;
52
+ align-items: center;
53
+ max-height: 100%;
54
+ overflow-y: auto;
55
+ overflow-x: hidden;
56
+
57
+ flex-grow: 1;
58
+ &[data-hasitems='true'] {
59
+ padding-bottom: 0.5rem;
60
+ }
61
+ @media ${styles_1.smallScreen} {
62
+ margin: 0;
63
+ width: calc(100% - 0.5rem);
64
+ }
65
+ `;
66
+ const RowCount = styled_1.default.div `
67
+ width: 100%;
68
+ text-align: center;
69
+ width: fit-content;
70
+ text-decoration-color: currentcolor;
71
+ text-decoration: underline;
72
+
73
+ &[data-top='true'] {
74
+ padding-bottom: 0.5rem;
75
+ }
76
+ &[data-top='false'] {
77
+ padding-top: 0.5rem;
78
+ }
79
+ `;
80
+ const SearchInline = (p) => {
81
+ var _a, _b, _c, _d, _e, _f;
82
+ const { maxDisplayItems = 1000 } = p;
83
+ const rowCountOptDisplay = (_b = (_a = p === null || p === void 0 ? void 0 : p.rowCountOpt) === null || _a === void 0 ? void 0 : _a.display) !== null && _b !== void 0 ? _b : 'bottom';
84
+ const [searchText, setSearchText] = (0, react_1.useState)((_c = p.defaultValue) !== null && _c !== void 0 ? _c : '');
85
+ (0, react_1.useImperativeHandle)(p.textBoxRef, () => ({
86
+ setValue: (v) => {
87
+ var _a, _b;
88
+ const value = (_a = textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current) === null || _a === void 0 ? void 0 : _a.getValue();
89
+ if (v === value) {
90
+ return;
91
+ }
92
+ (_b = textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current) === null || _b === void 0 ? void 0 : _b.setValue(v);
93
+ setSearchText(v);
94
+ },
95
+ focus: () => { var _a; return (_a = textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
96
+ getValue: () => { var _a; return (_a = textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current) === null || _a === void 0 ? void 0 : _a.getValue(); },
97
+ }));
98
+ const textBoxRef = (0, react_1.useRef)(null);
99
+ const resWrap = (foundItem, target) => {
100
+ var _a, _b;
101
+ if (!foundItem) {
102
+ (_a = p.onSelectItem) === null || _a === void 0 ? void 0 : _a.call(p, undefined);
103
+ }
104
+ else {
105
+ (_b = p.onSelectItem) === null || _b === void 0 ? void 0 : _b.call(p, { foundItem, searchText, target });
106
+ }
107
+ };
108
+ const filteredItemsRaw = p.displayItems.filter((i) => p.willDisplayItem(searchText, i));
109
+ const { part: filteredItems } = (0, array_1.take)(filteredItemsRaw, maxDisplayItems < 0 ? filteredItemsRaw.length : maxDisplayItems);
110
+ const outdiff = filteredItems.length !== p.displayItems.length;
111
+ const showText = (_f = (_e = (_d = p.texts) === null || _d === void 0 ? void 0 : _d.totalItems) === null || _e === void 0 ? void 0 : _e.call(_d, filteredItems.length, p.displayItems.length)) !== null && _f !== void 0 ? _f : `Showing ${filteredItems.length} out of ${p.displayItems.length} total
112
+ items`;
113
+ return (react_1.default.createElement(Base, { className: p.className },
114
+ react_1.default.createElement(SearchBox_1.SearchBox, Object.assign({}, p, { searchText: searchText, setSearchText: (t) => {
115
+ var _a;
116
+ setSearchText(t);
117
+ (_a = p.onSearchTextChange) === null || _a === void 0 ? void 0 : _a.call(p, t);
118
+ }, textBoxRef: textBoxRef })),
119
+ react_1.default.createElement(Content, { "data-hasitems": !!filteredItems.length, "data-type": "content" },
120
+ rowCountOptDisplay === 'top' && outdiff && (react_1.default.createElement(RowCount, { "data-top": "true" }, showText)),
121
+ filteredItems.map((item, index) => (0, react_1.cloneElement)(p.renderItem({ searchText, item, index }), {
122
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
+ onClick: (e) => resWrap(item, e.target),
124
+ })),
125
+ rowCountOptDisplay === 'bottom' && outdiff && (react_1.default.createElement(RowCount, { "data-top": "false" }, showText)))));
126
+ };
10
127
  exports.SearchInline = SearchInline;
@@ -9,7 +9,7 @@ const styled_1 = __importDefault(require("@emotion/styled"));
9
9
  const react_1 = __importDefault(require("react"));
10
10
  const styles_1 = require("../../styles");
11
11
  const Modal_1 = require("../Modal/Modal");
12
- const Base_1 = require("./Base");
12
+ const Inline_1 = require("./Inline");
13
13
  const ModalStyled = (0, styled_1.default)(Modal_1.Modal) `
14
14
  display: flex;
15
15
  flex-flow: column;
@@ -24,5 +24,5 @@ const ModalStyled = (0, styled_1.default)(Modal_1.Modal) `
24
24
  }
25
25
  `;
26
26
  const SearchModal = (p) => (react_1.default.createElement(ModalStyled, { position: "center", topPosition: "center", open: true, setOpen: () => { var _a; return (_a = p === null || p === void 0 ? void 0 : p.onSelectItem) === null || _a === void 0 ? void 0 : _a.call(p, undefined); }, showCloseButton: false, closeOnClickOutside: true },
27
- react_1.default.createElement(Base_1.SearchBase, Object.assign({}, p))));
27
+ react_1.default.createElement(Inline_1.SearchInline, Object.assign({}, p))));
28
28
  exports.SearchModal = SearchModal;
@@ -1,6 +1,6 @@
1
1
  export * from './AutoHideSearchBox';
2
- export * from './Base';
3
2
  export * from './Dialog';
4
3
  export * from './Inline';
5
4
  export * from './Modal';
5
+ export * from './SearchBox';
6
6
  export * from './types';
@@ -15,8 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./AutoHideSearchBox"), exports);
18
- __exportStar(require("./Base"), exports);
19
18
  __exportStar(require("./Dialog"), exports);
20
19
  __exportStar(require("./Inline"), exports);
21
20
  __exportStar(require("./Modal"), exports);
21
+ __exportStar(require("./SearchBox"), exports);
22
22
  __exportStar(require("./types"), exports);
@@ -46,5 +46,4 @@ export interface ISearchDialog<T> {
46
46
  display?: 'bottom' | 'top' | 'off';
47
47
  };
48
48
  }
49
- export type ISearchInline<T> = ISearchDialog<T>;
50
49
  export type ISearchModal<T> = ISearchDialog<T>;
@@ -78,7 +78,7 @@ allowUndo = true, rightSpan, className, }) => {
78
78
  }
79
79
  e.stopPropagation();
80
80
  } }),
81
- allowUndo && value !== defaultValue && (react_1.default.createElement(Icons, { center: true, enableOverflow: true },
81
+ allowUndo && value !== defaultValue && (react_1.default.createElement(Icons, { center: true },
82
82
  react_1.default.createElement(common_2.IconD, { style: common_2.iconLeft, onClick: (e) => {
83
83
  if (value !== defaultValue) {
84
84
  onSubmit(value);
@@ -1,6 +1,5 @@
1
1
  export * from './CheckboxEdit';
2
2
  export * from './ColourEdit';
3
3
  export * from './ListboxEdit';
4
- export * from './RadioGroup';
5
4
  export * from './TextEdit';
6
5
  export * from './types';
@@ -17,6 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./CheckboxEdit"), exports);
18
18
  __exportStar(require("./ColourEdit"), exports);
19
19
  __exportStar(require("./ListboxEdit"), exports);
20
- __exportStar(require("./RadioGroup"), exports);
21
20
  __exportStar(require("./TextEdit"), exports);
22
21
  __exportStar(require("./types"), exports);
@@ -19,6 +19,7 @@ export * from './OpenApiCodeBlock';
19
19
  export * from './PieChart';
20
20
  export * from './ProgressBar';
21
21
  export * from './Prompt';
22
+ export * from './RadioGroup';
22
23
  export * from './RowOrColumn';
23
24
  export * from './Search';
24
25
  export * from './Sidebar';
@@ -35,6 +35,7 @@ __exportStar(require("./OpenApiCodeBlock"), exports);
35
35
  __exportStar(require("./PieChart"), exports);
36
36
  __exportStar(require("./ProgressBar"), exports);
37
37
  __exportStar(require("./Prompt"), exports);
38
+ __exportStar(require("./RadioGroup"), exports);
38
39
  __exportStar(require("./RowOrColumn"), exports);
39
40
  __exportStar(require("./Search"), exports);
40
41
  __exportStar(require("./Sidebar"), exports);
@@ -12,7 +12,7 @@ const raw_1 = require("./raw");
12
12
  */
13
13
  function getCookieRawWrapper({ name, cookieDocument, defaultValue, parse: parseRaw, }) {
14
14
  const parse = (s) => {
15
- if (!s) {
15
+ if (s === undefined || s === null) {
16
16
  return defaultValue;
17
17
  }
18
18
  if (parseRaw) {
@@ -28,7 +28,7 @@ function getCookieRawWrapper({ name, cookieDocument, defaultValue, parse: parseR
28
28
  name: name + currentCount,
29
29
  cookieDocument,
30
30
  });
31
- if (!newv) {
31
+ if (newv === undefined || newv === null) {
32
32
  break;
33
33
  }
34
34
  raw += newv;
@@ -18,7 +18,7 @@ function setCookieRawWrapper(p) {
18
18
  return JSON.stringify(s);
19
19
  };
20
20
  (0, raw_1.wipeCookies)(p.name);
21
- if (!p.value) {
21
+ if (p.value === undefined) {
22
22
  return;
23
23
  }
24
24
  const str = (0, base64_1.toBase64)(stringify(p.value));
@@ -5,6 +5,7 @@ const react_1 = require("react");
5
5
  const get_1 = require("./get");
6
6
  const set_1 = require("./set");
7
7
  function useCookie(p) {
8
+ var _a;
8
9
  const parse = (s) => {
9
10
  if (!s) {
10
11
  return p.defaultValue;
@@ -20,7 +21,7 @@ function useCookie(p) {
20
21
  }
21
22
  return JSON.stringify(s);
22
23
  };
23
- const [cookie, setCookie] = (0, react_1.useState)((0, get_1.getCookieRawWrapper)(Object.assign(Object.assign({}, p), { parse })) || p.defaultValue);
24
+ const [cookie, setCookie] = (0, react_1.useState)((_a = (0, get_1.getCookieRawWrapper)(Object.assign(Object.assign({}, p), { parse }))) !== null && _a !== void 0 ? _a : p.defaultValue);
24
25
  const setState = (valueRaw) => {
25
26
  const value = (valueRaw instanceof Function ? valueRaw(cookie) : valueRaw);
26
27
  (0, set_1.setCookieRawWrapper)(Object.assign(Object.assign({}, p), { stringify, value }));
@@ -29,7 +30,10 @@ function useCookie(p) {
29
30
  return [cookie, setState];
30
31
  }
31
32
  exports.useCookie = useCookie;
32
- const useCookieString = (p) => useCookie(Object.assign(Object.assign({}, p), { parse: (s) => s || '', stringify: (s) => s, defaultValue: p.defaultValue || '' }));
33
+ const useCookieString = (p) => {
34
+ var _a;
35
+ return useCookie(Object.assign(Object.assign({}, p), { parse: (s) => s !== null && s !== void 0 ? s : '', stringify: (s) => s, defaultValue: (_a = p.defaultValue) !== null && _a !== void 0 ? _a : '' }));
36
+ };
33
37
  exports.useCookieString = useCookieString;
34
38
  const useCookieNumber = (p) => useCookie(Object.assign(Object.assign({}, p), { parse: (s) => (!s ? undefined : Number.parseFloat(s)), stringify: (s) => (!s ? '' : s.toString()), defaultValue: p.defaultValue }));
35
39
  exports.useCookieNumber = useCookieNumber;
@@ -7,7 +7,7 @@ exports.Checkmark = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const Checkmark = ({ style, }) => {
9
9
  var _a;
10
- return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "2 2 20 20", style: Object.assign(Object.assign({}, style), { fill: undefined }) },
10
+ return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "2 2 20 20", style: Object.assign({}, style) },
11
11
  react_1.default.createElement("path", { fill: "none", stroke: (_a = style === null || style === void 0 ? void 0 : style.fill) !== null && _a !== void 0 ? _a : '#000', strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M8 12.333 10.461 15 16 9m5 3a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" })));
12
12
  };
13
13
  exports.Checkmark = Checkmark;
@@ -7,7 +7,7 @@ exports.Circle = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const Circle = ({ style, dotted = false, }) => {
9
9
  var _a;
10
- return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "2 2 20 20", style: Object.assign(Object.assign({}, style), { fill: undefined }) },
10
+ return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "2 2 20 20", style: Object.assign({}, style) },
11
11
  react_1.default.createElement("path", { fill: "none", stroke: (_a = style === null || style === void 0 ? void 0 : style.fill) !== null && _a !== void 0 ? _a : '#000', strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: !dotted ? '' : '4 4', strokeWidth: "2", d: "M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" })));
12
12
  };
13
13
  exports.Circle = Circle;
@@ -0,0 +1,8 @@
1
+ import type { CSSProperties } from 'react';
2
+ import React from 'react';
3
+ export declare const Computer: ({ style, }: {
4
+ style?: ({
5
+ /** change the colour of the icon. default black */
6
+ fill?: string | undefined;
7
+ } & CSSProperties) | undefined;
8
+ }) => React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Computer = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const Computer = ({ style, }) => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: Object.assign({}, style) },
9
+ react_1.default.createElement("path", { fillRule: "evenodd", d: "M2 6a3 3 0 0 1 3-3h14a3 3 0 0 1 3 3v9a3 3 0 0 1-3 3h-6v1h2a1 1 0 1 1 0 2H9a1 1 0 1 1 0-2h2v-1H5a3 3 0 0 1-3-3V6Zm3-1a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1H5Z", clipRule: "evenodd" })));
10
+ exports.Computer = Computer;
@@ -7,7 +7,7 @@ exports.Magnify = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const Magnify = ({ style, }) => {
9
9
  var _a;
10
- return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 490 490" },
10
+ return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 490 490", style: Object.assign({}, style) },
11
11
  react_1.default.createElement("path", { fill: "none", stroke: (_a = style === null || style === void 0 ? void 0 : style.fill) !== null && _a !== void 0 ? _a : 'black', strokeWidth: "36", strokeLinecap: "round", d: "M280 278a153 153 0 1 0-2 2l170 170m-91-117 110 110-26 26-110-110" })));
12
12
  };
13
13
  exports.Magnify = Magnify;
@@ -0,0 +1,8 @@
1
+ import type { CSSProperties } from 'react';
2
+ import React from 'react';
3
+ export declare const Moon: ({ style, }: {
4
+ style?: ({
5
+ /** change the colour of the icon. default black */
6
+ fill?: string | undefined;
7
+ } & CSSProperties) | undefined;
8
+ }) => React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Moon = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const Moon = ({ style, }) => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 35 35", style: Object.assign({}, style) },
9
+ react_1.default.createElement("path", { d: "M18.44 34.68a18.22 18.22 0 0 1-2.94-.24 18.18 18.18 0 0 1-15-20.86A18.06 18.06 0 0 1 9.59.63a2.42 2.42 0 0 1 2.61.16 2.39 2.39 0 0 1 1 2.41l-1.3-.1 1.23.22A15.66 15.66 0 0 0 23.34 21a15.82 15.82 0 0 0 8.47.53A2.44 2.44 0 0 1 34.47 25a18.18 18.18 0 0 1-16.03 9.68ZM10.67 2.89a15.67 15.67 0 0 0-5 22.77A15.66 15.66 0 0 0 32.18 24a18.49 18.49 0 0 1-9.65-.64A18.18 18.18 0 0 1 10.67 2.89Z" })));
10
+ exports.Moon = Moon;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export declare const Sun: (p: {
3
+ style: {
4
+ fill: string;
5
+ };
6
+ }) => React.JSX.Element;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Sun = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const Sun = (p) => {
9
+ var _a, _b;
10
+ return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" },
11
+ react_1.default.createElement("g", { stroke: (_b = (_a = p === null || p === void 0 ? void 0 : p.style) === null || _a === void 0 ? void 0 : _a.fill) !== null && _b !== void 0 ? _b : 'black', strokeMiterlimit: "10", strokeWidth: "1.5", clipPath: "url(#a)" },
12
+ react_1.default.createElement("path", { strokeLinecap: "round", d: "M5 12H1m22 0h-4M7.05 7.05 4.222 4.222m15.556 15.556L16.95 16.95m-9.9 0-2.828 2.828M19.778 4.222 16.95 7.05" }),
13
+ react_1.default.createElement("path", { fillOpacity: "0", d: "M12 16a4 4 0 1 0 0-8 4 4 0 0 0 0 8Z" }),
14
+ react_1.default.createElement("path", { strokeLinecap: "round", d: "M12 19v4m0-22v4" })),
15
+ react_1.default.createElement("defs", null,
16
+ react_1.default.createElement("clipPath", { id: "a" },
17
+ react_1.default.createElement("path", { fill: "#fff", d: "M0 0h24v24H0z" })))));
18
+ };
19
+ exports.Sun = Sun;
@@ -2,13 +2,16 @@ export * from './Checkmark';
2
2
  export * from './ChevronRight';
3
3
  export * from './Circle';
4
4
  export * from './CircleDot';
5
+ export * from './Computer';
5
6
  export * from './CrossIcon';
6
7
  export * from './Door';
7
8
  export * from './Hamburger';
8
9
  export * from './HorizontalDots';
9
10
  export * from './Magnify';
11
+ export * from './Moon';
10
12
  export * from './Pencil';
11
13
  export * from './Save';
14
+ export * from './Sun';
12
15
  export * from './Undo';
13
16
  export * from './UserOutline';
14
17
  export * from './Warning';
@@ -18,13 +18,16 @@ __exportStar(require("./Checkmark"), exports);
18
18
  __exportStar(require("./ChevronRight"), exports);
19
19
  __exportStar(require("./Circle"), exports);
20
20
  __exportStar(require("./CircleDot"), exports);
21
+ __exportStar(require("./Computer"), exports);
21
22
  __exportStar(require("./CrossIcon"), exports);
22
23
  __exportStar(require("./Door"), exports);
23
24
  __exportStar(require("./Hamburger"), exports);
24
25
  __exportStar(require("./HorizontalDots"), exports);
25
26
  __exportStar(require("./Magnify"), exports);
27
+ __exportStar(require("./Moon"), exports);
26
28
  __exportStar(require("./Pencil"), exports);
27
29
  __exportStar(require("./Save"), exports);
30
+ __exportStar(require("./Sun"), exports);
28
31
  __exportStar(require("./Undo"), exports);
29
32
  __exportStar(require("./UserOutline"), exports);
30
33
  __exportStar(require("./Warning"), exports);
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.553",
2
+ "version": "0.0.555",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import type { ISearchDialog } from './types';
3
- type ISearchBase<T> = ISearchDialog<T>;
4
- export declare const SearchBase: <T>(p: ISearchBase<T>) => React.JSX.Element;
5
- export {};
@@ -1,127 +0,0 @@
1
- "use strict";
2
- 'use client';
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
- var __importDefault = (this && this.__importDefault) || function (mod) {
27
- return (mod && mod.__esModule) ? mod : { "default": mod };
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.SearchBase = void 0;
31
- const styled_1 = __importDefault(require("@emotion/styled"));
32
- const react_1 = __importStar(require("react"));
33
- const array_1 = require("../../../common/helpers/array");
34
- const styles_1 = require("../../styles");
35
- const SearchBox_1 = require("./SearchBox");
36
- const Base = styled_1.default.div `
37
- display: flex;
38
- flex-flow: column;
39
- flex-grow: 1;
40
- width: 100%;
41
- height: calc(100% - 1rem);
42
- @media ${styles_1.smallScreen} {
43
- height: calc(100% - 0.5rem);
44
- }
45
- `;
46
- const Content = styled_1.default.div `
47
- width: calc(100% - 2rem);
48
- margin: auto;
49
- display: flex;
50
- flex-flow: column;
51
- justify-content: flex-start;
52
- align-items: center;
53
- max-height: 100%;
54
- overflow-y: auto;
55
- overflow-x: hidden;
56
-
57
- flex-grow: 1;
58
- &[data-hasitems='true'] {
59
- padding-bottom: 0.5rem;
60
- }
61
- @media ${styles_1.smallScreen} {
62
- margin: 0;
63
- width: calc(100% - 0.5rem);
64
- }
65
- `;
66
- const RowCount = styled_1.default.div `
67
- width: 100%;
68
- text-align: center;
69
- width: fit-content;
70
- text-decoration-color: currentcolor;
71
- text-decoration: underline;
72
-
73
- &[data-top='true'] {
74
- padding-bottom: 0.5rem;
75
- }
76
- &[data-top='false'] {
77
- padding-top: 0.5rem;
78
- }
79
- `;
80
- const SearchBase = (p) => {
81
- var _a, _b, _c, _d, _e, _f;
82
- const { maxDisplayItems = 1000 } = p;
83
- const rowCountOptDisplay = (_b = (_a = p === null || p === void 0 ? void 0 : p.rowCountOpt) === null || _a === void 0 ? void 0 : _a.display) !== null && _b !== void 0 ? _b : 'bottom';
84
- const [searchText, setSearchText] = (0, react_1.useState)((_c = p.defaultValue) !== null && _c !== void 0 ? _c : '');
85
- (0, react_1.useImperativeHandle)(p.textBoxRef, () => ({
86
- setValue: (v) => {
87
- var _a, _b;
88
- const value = (_a = divRef === null || divRef === void 0 ? void 0 : divRef.current) === null || _a === void 0 ? void 0 : _a.getValue();
89
- if (v === value) {
90
- return;
91
- }
92
- (_b = divRef === null || divRef === void 0 ? void 0 : divRef.current) === null || _b === void 0 ? void 0 : _b.setValue(v);
93
- setSearchText(v);
94
- },
95
- focus: () => { var _a; return (_a = divRef === null || divRef === void 0 ? void 0 : divRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
96
- getValue: () => { var _a; return (_a = divRef === null || divRef === void 0 ? void 0 : divRef.current) === null || _a === void 0 ? void 0 : _a.getValue(); },
97
- }));
98
- const divRef = (0, react_1.useRef)(null);
99
- const resWrap = (foundItem, target) => {
100
- var _a, _b;
101
- if (!foundItem) {
102
- (_a = p.onSelectItem) === null || _a === void 0 ? void 0 : _a.call(p, undefined);
103
- }
104
- else {
105
- (_b = p.onSelectItem) === null || _b === void 0 ? void 0 : _b.call(p, { foundItem, searchText, target });
106
- }
107
- };
108
- const filteredItemsRaw = p.displayItems.filter((i) => p.willDisplayItem(searchText, i));
109
- const { part: filteredItems } = (0, array_1.take)(filteredItemsRaw, maxDisplayItems < 0 ? filteredItemsRaw.length : maxDisplayItems);
110
- const outdiff = filteredItems.length !== p.displayItems.length;
111
- const showText = (_f = (_e = (_d = p.texts) === null || _d === void 0 ? void 0 : _d.totalItems) === null || _e === void 0 ? void 0 : _e.call(_d, filteredItems.length, p.displayItems.length)) !== null && _f !== void 0 ? _f : `Showing ${filteredItems.length} out of ${p.displayItems.length} total
112
- items`;
113
- return (react_1.default.createElement(Base, { className: p.className },
114
- react_1.default.createElement(SearchBox_1.SearchBox, Object.assign({}, p, { searchText: searchText, setSearchText: (t) => {
115
- var _a;
116
- setSearchText(t);
117
- (_a = p.onSearchTextChange) === null || _a === void 0 ? void 0 : _a.call(p, t);
118
- }, textBoxRef: divRef })),
119
- react_1.default.createElement(Content, { "data-hasitems": !!filteredItems.length, "data-type": "content" },
120
- rowCountOptDisplay === 'top' && outdiff && (react_1.default.createElement(RowCount, { "data-top": "true" }, showText)),
121
- filteredItems.map((item, index) => (0, react_1.cloneElement)(p.renderItem({ searchText, item, index }), {
122
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
- onClick: (e) => resWrap(item, e.target),
124
- })),
125
- rowCountOptDisplay === 'bottom' && outdiff && (react_1.default.createElement(RowCount, { "data-top": "false" }, showText)))));
126
- };
127
- exports.SearchBase = SearchBase;
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- export declare const RadioGroup: <T>({ defaultValue, onSubmit, values, renderLabel, renderValue, }: {
3
- /**
4
- * can overload the render of the label. defaults to toString
5
- */
6
- renderLabel?: ((a: T) => string) | undefined;
7
- /**
8
- * render the value from the generic T. defaults to toString
9
- */
10
- renderValue?: ((a: T) => string) | undefined;
11
- defaultValue: T;
12
- onSubmit: (val: T) => void;
13
- values: T[];
14
- }) => React.JSX.Element;