ag-common 0.0.249 → 0.0.252
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/dist/ui/components/Prompt/Modal.js +0 -2
- package/dist/ui/components/TextEdit/CheckboxEdit.js +0 -1
- package/dist/ui/components/TextEdit/ColourEdit.js +0 -1
- package/dist/ui/components/TextEdit/ListboxEdit.d.ts +6 -2
- package/dist/ui/components/TextEdit/ListboxEdit.js +4 -6
- package/dist/ui/components/TextEdit/RadioGroup.d.ts +14 -0
- package/dist/ui/components/TextEdit/RadioGroup.js +51 -0
- package/dist/ui/components/TextEdit/TextEdit.js +0 -1
- package/dist/ui/components/TextEdit/index.d.ts +1 -0
- package/dist/ui/components/TextEdit/index.js +1 -0
- package/package.json +1 -1
|
@@ -27,8 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.PromptModal = void 0;
|
|
30
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
31
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
32
30
|
const Button_1 = require("../Button");
|
|
33
31
|
const FlexColumn_1 = require("../FlexColumn");
|
|
34
32
|
const FlexRow_1 = require("../FlexRow");
|
|
@@ -27,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.CheckboxEdit = void 0;
|
|
30
|
-
/* eslint-disable jsx-a11y/no-onchange */
|
|
31
30
|
const images_1 = require("./images");
|
|
32
31
|
const common_1 = require("./common");
|
|
33
32
|
const common_2 = require("../../styles/common");
|
|
@@ -24,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.ColourEdit = void 0;
|
|
27
|
-
/* eslint-disable jsx-a11y/no-onchange */
|
|
28
27
|
const images_1 = require("./images");
|
|
29
28
|
const common_1 = require("./common");
|
|
30
29
|
const useOnClickOutside_1 = require("../../helpers/useOnClickOutside");
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const ListboxEdit: ({ defaultValue, onSubmit, values, }: {
|
|
2
|
+
export declare const ListboxEdit: ({ defaultValue, onSubmit, values, canEdit, }: {
|
|
3
3
|
defaultValue: string;
|
|
4
|
-
onSubmit: (val: string
|
|
4
|
+
onSubmit: (val: string) => void;
|
|
5
5
|
values: string[];
|
|
6
|
+
/**
|
|
7
|
+
* if true can revert or explicit save. default true
|
|
8
|
+
*/
|
|
9
|
+
canEdit?: boolean | undefined;
|
|
6
10
|
}) => JSX.Element;
|
|
@@ -24,22 +24,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.ListboxEdit = void 0;
|
|
27
|
-
/* eslint-disable jsx-a11y/no-onchange */
|
|
28
27
|
const images_1 = require("./images");
|
|
29
28
|
const common_1 = require("./common");
|
|
30
29
|
const common_2 = require("../../styles/common");
|
|
31
30
|
const react_1 = __importStar(require("react"));
|
|
32
|
-
const ListboxEdit = ({ defaultValue, onSubmit, values, }) => {
|
|
31
|
+
const ListboxEdit = ({ defaultValue, onSubmit, values, canEdit = true, }) => {
|
|
33
32
|
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
34
33
|
(0, react_1.useEffect)(() => {
|
|
35
34
|
setValue(defaultValue);
|
|
36
35
|
}, [defaultValue]);
|
|
37
36
|
return (react_1.default.createElement(common_1.ValueBox, Object.assign({}, common_2.noDrag),
|
|
38
|
-
react_1.default.createElement("select", { size: 5, value: value, onChange: (v) => setValue(v.target.value) }, values.map((v) => (react_1.default.createElement("option", { key: v, value: v }, v)))),
|
|
39
|
-
value !== defaultValue && (react_1.default.createElement(common_1.IconD, { style: common_1.iconLeft, onClick: () => value !== defaultValue &&
|
|
40
|
-
onSubmit(value.split(',').map((s) => s.trim())) },
|
|
37
|
+
react_1.default.createElement("select", { size: 5, value: value, onChange: (v) => canEdit ? setValue(v.target.value) : onSubmit(v.target.value) }, values.map((v) => (react_1.default.createElement("option", { key: v, value: v }, v)))),
|
|
38
|
+
canEdit && value !== defaultValue && (react_1.default.createElement(common_1.IconD, { style: common_1.iconLeft, onClick: () => value !== defaultValue && onSubmit(value) },
|
|
41
39
|
react_1.default.createElement(images_1.SaveIcon, null))),
|
|
42
|
-
value !== defaultValue && (react_1.default.createElement(common_1.IconD, { style: common_1.iconRight, onClick: () => setValue(defaultValue) },
|
|
40
|
+
canEdit && value !== defaultValue && (react_1.default.createElement(common_1.IconD, { style: common_1.iconRight, onClick: () => setValue(defaultValue) },
|
|
43
41
|
react_1.default.createElement(images_1.UndoIcon, null)))));
|
|
44
42
|
};
|
|
45
43
|
exports.ListboxEdit = ListboxEdit;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="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
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.RadioGroup = void 0;
|
|
30
|
+
const common_1 = require("./common");
|
|
31
|
+
const FlexColumn_1 = require("../FlexColumn");
|
|
32
|
+
const common_2 = require("../../styles/common");
|
|
33
|
+
const math_1 = require("../../../common/helpers/math");
|
|
34
|
+
const react_1 = __importStar(require("react"));
|
|
35
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
36
|
+
const Label = styled_components_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 [name] = (0, react_1.useState)((0, math_1.getRandomInt)(10000).toString());
|
|
43
|
+
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
44
|
+
(0, react_1.useEffect)(() => {
|
|
45
|
+
setValue(defaultValue);
|
|
46
|
+
}, [defaultValue]);
|
|
47
|
+
return (react_1.default.createElement(common_1.ValueBox, Object.assign({}, common_2.noDrag), values.map((v) => (react_1.default.createElement(FlexColumn_1.FlexColumn, { key: name + v },
|
|
48
|
+
react_1.default.createElement(Label, null, renderLabel(v)),
|
|
49
|
+
react_1.default.createElement("input", { type: "radio", key: renderValue(v), value: renderValue(v), name: name, checked: v === value, onChange: () => onSubmit(v) }))))));
|
|
50
|
+
};
|
|
51
|
+
exports.RadioGroup = RadioGroup;
|
|
@@ -24,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.TextEdit = exports.ValueReadonly = void 0;
|
|
27
|
-
/* eslint-disable jsx-a11y/no-onchange */
|
|
28
27
|
const images_1 = require("./images");
|
|
29
28
|
const common_1 = require("./common");
|
|
30
29
|
const LengthBox_1 = require("./LengthBox");
|
|
@@ -17,5 +17,6 @@ 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);
|
|
20
21
|
__exportStar(require("./TextEdit"), exports);
|
|
21
22
|
__exportStar(require("./types"), exports);
|