blixify-ui-web 0.3.32 → 0.3.33
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.
|
@@ -16,7 +16,12 @@ interface Props {
|
|
|
16
16
|
horizontal?: boolean;
|
|
17
17
|
}
|
|
18
18
|
export declare class RadioList extends Component<Props> {
|
|
19
|
+
state: {
|
|
20
|
+
error: string;
|
|
21
|
+
};
|
|
22
|
+
setAsyncState: (newState: any) => Promise<unknown>;
|
|
19
23
|
handleOnChange: (id: string) => void;
|
|
24
|
+
handleSubmit: () => Promise<boolean>;
|
|
20
25
|
render(): React.JSX.Element;
|
|
21
26
|
}
|
|
22
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/action/radioList/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,oBAAoB,CAAC;AAE5B,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B;AAED,UAAU,KAAK;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,qBAAa,SAAU,SAAQ,SAAS,CAAC,KAAK,CAAC;IAC7C,cAAc,OAAQ,MAAM,UAE1B;IAEF,MAAM;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/action/radioList/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,oBAAoB,CAAC;AAE5B,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B;AAED,UAAU,KAAK;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,qBAAa,SAAU,SAAQ,SAAS,CAAC,KAAK,CAAC;IAC7C,KAAK;;MAEH;IAEF,aAAa,sCACqD;IAElE,cAAc,OAAQ,MAAM,UAE1B;IAEF,YAAY,yBAmBV;IAEF,MAAM;CA+CP"}
|
|
@@ -37,6 +37,42 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
37
37
|
__setModuleDefault(result, mod);
|
|
38
38
|
return result;
|
|
39
39
|
};
|
|
40
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
41
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
43
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
44
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
45
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
46
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
50
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
51
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
52
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
53
|
+
function step(op) {
|
|
54
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
55
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
56
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
57
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
58
|
+
switch (op[0]) {
|
|
59
|
+
case 0: case 1: t = op; break;
|
|
60
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
61
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
62
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
63
|
+
default:
|
|
64
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
65
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
66
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
67
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
68
|
+
if (t[2]) _.ops.pop();
|
|
69
|
+
_.trys.pop(); continue;
|
|
70
|
+
}
|
|
71
|
+
op = body.call(thisArg, _);
|
|
72
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
73
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
74
|
+
}
|
|
75
|
+
};
|
|
40
76
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
77
|
exports.RadioList = void 0;
|
|
42
78
|
var react_1 = __importStar(require("react"));
|
|
@@ -45,25 +81,64 @@ var RadioList = /** @class */ (function (_super) {
|
|
|
45
81
|
__extends(RadioList, _super);
|
|
46
82
|
function RadioList() {
|
|
47
83
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
84
|
+
_this.state = {
|
|
85
|
+
error: "",
|
|
86
|
+
};
|
|
87
|
+
_this.setAsyncState = function (newState) {
|
|
88
|
+
return new Promise(function (resolve) { return _this.setState(newState, resolve); });
|
|
89
|
+
};
|
|
48
90
|
_this.handleOnChange = function (id) {
|
|
49
91
|
_this.props.onSelect(id);
|
|
50
92
|
};
|
|
93
|
+
_this.handleSubmit = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
94
|
+
var testCond, error;
|
|
95
|
+
return __generator(this, function (_a) {
|
|
96
|
+
switch (_a.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
testCond = false;
|
|
99
|
+
error = "Please select an option";
|
|
100
|
+
if (!this.props.optional) {
|
|
101
|
+
if (Array.isArray(this.props.selectedId)) {
|
|
102
|
+
testCond = this.props.selectedId.length > 0 ? true : false;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
testCond = this.props.selectedId ? true : false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
testCond = true;
|
|
110
|
+
}
|
|
111
|
+
if (!!testCond) return [3 /*break*/, 2];
|
|
112
|
+
return [4 /*yield*/, this.setAsyncState({ error: error })];
|
|
113
|
+
case 1:
|
|
114
|
+
_a.sent();
|
|
115
|
+
return [3 /*break*/, 4];
|
|
116
|
+
case 2: return [4 /*yield*/, this.setAsyncState({ error: "" })];
|
|
117
|
+
case 3:
|
|
118
|
+
_a.sent();
|
|
119
|
+
_a.label = 4;
|
|
120
|
+
case 4: return [2 /*return*/, testCond];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}); };
|
|
51
124
|
return _this;
|
|
52
125
|
}
|
|
53
126
|
RadioList.prototype.render = function () {
|
|
54
127
|
var _this = this;
|
|
55
128
|
var _a = this.props, id = _a.id, list = _a.list, selectedId = _a.selectedId, name = _a.name, optional = _a.optional, horizontal = _a.horizontal;
|
|
56
129
|
var isHorizontal = horizontal;
|
|
57
|
-
return (react_1.default.createElement("div", { className: "".concat(isHorizontal ? "flex flex-wrap space-x-4" : "divide-y divide-gray-200") },
|
|
58
|
-
react_1.default.createElement("div", {
|
|
59
|
-
react_1.default.createElement("
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
react_1.default.createElement("
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
130
|
+
return (react_1.default.createElement("div", { className: "".concat(isHorizontal ? "flex flex-wrap space-x-4" : "divide-y divide-gray-200") },
|
|
131
|
+
list.map(function (eachItem, index) { return (react_1.default.createElement("div", { key: "".concat(id, "-").concat(eachItem.id, "-").concat(index), className: "relative flex items-start pb-4 pt-3.5" },
|
|
132
|
+
react_1.default.createElement("div", { className: "min-w-0 flex-1 text-sm leading-6" },
|
|
133
|
+
react_1.default.createElement("label", { htmlFor: "".concat(id, "-").concat(eachItem.id, "-").concat(index), className: "font-medium text-gray-900" }, eachItem.label),
|
|
134
|
+
eachItem.content && (react_1.default.createElement("div", { className: "text-gray-500" }, eachItem.content)),
|
|
135
|
+
eachItem.addContent && react_1.default.createElement("div", null, eachItem.addContent)),
|
|
136
|
+
react_1.default.createElement("div", { className: "ml-3 flex h-6 items-center" },
|
|
137
|
+
react_1.default.createElement("input", { id: "".concat(id, "-").concat(eachItem.id, "-").concat(index), checked: eachItem.id === selectedId, name: name !== null && name !== void 0 ? name : "".concat(id, "-radioList"), type: "radio", className: "h-4 w-4 border-gray-300 text-primary-600 focus:ring-primary-600", onChange: function () {
|
|
138
|
+
var newId = optional && selectedId === eachItem.id ? "" : eachItem.id;
|
|
139
|
+
_this.handleOnChange(newId);
|
|
140
|
+
} })))); }),
|
|
141
|
+
react_1.default.createElement("span", { className: "text-red-500 text-sm" }, this.state.error)));
|
|
67
142
|
};
|
|
68
143
|
return RadioList;
|
|
69
144
|
}(react_1.Component));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/action/radioList/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/action/radioList/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAuD;AACvD,8BAA4B;AAmB5B;IAA+B,6BAAgB;IAA/C;;QACE,WAAK,GAAG;YACN,KAAK,EAAE,EAAE;SACV,CAAC;QAEF,mBAAa,GAAG,UAAC,QAAQ;YACvB,OAAA,IAAI,OAAO,CAAC,UAAC,OAAY,IAAK,OAAA,KAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAhC,CAAgC,CAAC;QAA/D,CAA+D,CAAC;QAElE,oBAAc,GAAG,UAAC,EAAU;YAC1B,KAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC1B,CAAC,CAAC;QAEF,kBAAY,GAAG;;;;;wBACT,QAAQ,GAAG,KAAK,CAAC;wBACf,KAAK,GAAG,yBAAyB,CAAC;wBACxC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;4BACzB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;gCACzC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC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