kui-complex 0.0.62 → 0.0.64
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/ButtonSelect/cjs/index.js +56 -88
- package/ButtonSelect/cjs/index.js.map +1 -1
- package/ButtonSelect/index.d.ts +1 -0
- package/ButtonSelect/index.js +58 -90
- package/ButtonSelect/index.js.map +1 -1
- package/CalendarHeaderWithSelect/cjs/index.js +56 -88
- package/CalendarHeaderWithSelect/cjs/index.js.map +1 -1
- package/CalendarHeaderWithSelect/index.d.ts +1 -0
- package/CalendarHeaderWithSelect/index.js +58 -90
- package/CalendarHeaderWithSelect/index.js.map +1 -1
- package/InputMultiSelect/cjs/index.js +237 -0
- package/InputMultiSelect/cjs/index.js.map +1 -0
- package/InputMultiSelect/cjs/package.json +10 -0
- package/InputMultiSelect/index.d.ts +24 -0
- package/InputMultiSelect/index.js +231 -0
- package/InputMultiSelect/index.js.map +1 -0
- package/InputMultiSelect/package.json +10 -0
- package/InputMultiSelectOption/cjs/index.js +60 -0
- package/InputMultiSelectOption/cjs/index.js.map +1 -0
- package/InputMultiSelectOption/cjs/package.json +9 -0
- package/InputMultiSelectOption/index.d.ts +14 -0
- package/InputMultiSelectOption/index.js +54 -0
- package/InputMultiSelectOption/index.js.map +1 -0
- package/InputMultiSelectOption/package.json +9 -0
- package/InputSelect/cjs/index.js +59 -91
- package/InputSelect/cjs/index.js.map +1 -1
- package/InputSelect/index.d.ts +13 -15
- package/InputSelect/index.js +59 -91
- package/InputSelect/index.js.map +1 -1
- package/InputSelectBase/cjs/index.js +171 -0
- package/InputSelectBase/cjs/index.js.map +1 -0
- package/InputSelectBase/cjs/package.json +9 -0
- package/InputSelectBase/index.d.ts +23 -0
- package/InputSelectBase/index.js +165 -0
- package/InputSelectBase/index.js.map +1 -0
- package/InputSelectBase/package.json +9 -0
- package/InputSelectDropdown/cjs/index.js +17 -34
- package/InputSelectDropdown/cjs/index.js.map +1 -1
- package/InputSelectDropdown/index.d.ts +3 -3
- package/InputSelectDropdown/index.js +18 -35
- package/InputSelectDropdown/index.js.map +1 -1
- package/InputSelectOption/cjs/index.js +53 -0
- package/InputSelectOption/cjs/index.js.map +1 -0
- package/InputSelectOption/cjs/package.json +9 -0
- package/InputSelectOption/index.d.ts +14 -0
- package/InputSelectOption/index.js +47 -0
- package/InputSelectOption/index.js.map +1 -0
- package/InputSelectOption/package.json +9 -0
- package/InputSelectWithController/cjs/index.js +223 -0
- package/InputSelectWithController/cjs/index.js.map +1 -0
- package/InputSelectWithController/cjs/package.json +10 -0
- package/InputSelectWithController/index.d.ts +22 -0
- package/InputSelectWithController/index.js +217 -0
- package/InputSelectWithController/index.js.map +1 -0
- package/InputSelectWithController/package.json +10 -0
- package/InputWithDatePicker/cjs/index.js +58 -90
- package/InputWithDatePicker/cjs/index.js.map +1 -1
- package/InputWithDatePicker/index.js +60 -92
- package/InputWithDatePicker/index.js.map +1 -1
- package/RadioButtons/cjs/index.js +80 -0
- package/RadioButtons/cjs/index.js.map +1 -0
- package/RadioButtons/cjs/package.json +9 -0
- package/RadioButtons/index.d.ts +27 -0
- package/RadioButtons/index.js +78 -0
- package/RadioButtons/index.js.map +1 -0
- package/RadioButtons/package.json +9 -0
- package/RadioButtonsWithController/cjs/index.js +102 -0
- package/RadioButtonsWithController/cjs/index.js.map +1 -0
- package/RadioButtonsWithController/cjs/package.json +10 -0
- package/RadioButtonsWithController/index.d.ts +31 -0
- package/RadioButtonsWithController/index.js +100 -0
- package/RadioButtonsWithController/index.js.map +1 -0
- package/RadioButtonsWithController/package.json +10 -0
- package/RadioGroupWithLabel/cjs/index.js +149 -0
- package/RadioGroupWithLabel/cjs/index.js.map +1 -0
- package/RadioGroupWithLabel/cjs/package.json +10 -0
- package/RadioGroupWithLabel/index.d.ts +34 -0
- package/RadioGroupWithLabel/index.js +143 -0
- package/RadioGroupWithLabel/index.js.map +1 -0
- package/RadioGroupWithLabel/package.json +10 -0
- package/SelectMonth/cjs/index.js +57 -89
- package/SelectMonth/cjs/index.js.map +1 -1
- package/SelectMonth/index.d.ts +1 -0
- package/SelectMonth/index.js +58 -90
- package/SelectMonth/index.js.map +1 -1
- package/SelectYear/cjs/index.js +57 -89
- package/SelectYear/cjs/index.js.map +1 -1
- package/SelectYear/index.d.ts +1 -0
- package/SelectYear/index.js +58 -90
- package/SelectYear/index.js.map +1 -1
- package/TestForm/cjs/index.js +67 -88
- package/TestForm/cjs/index.js.map +1 -1
- package/TestForm/index.js +68 -89
- package/TestForm/index.js.map +1 -1
- package/cjs/index.js +336 -172
- package/cjs/index.js.map +1 -1
- package/index.d.ts +78 -19
- package/index.js +333 -174
- package/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../node_modules/tslib/tslib.es6.js","../../../src/components/RadioButtons/index.tsx","../../../src/components/RadioButtonsWithController/index.tsx","../../../src/components/RadioGroupWithLabel/index.tsx"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n 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;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","import React, { ForwardedRef, forwardRef, useEffect, useState } from \"react\"\nimport { Grid, Radio } from \"kui-basic\"\nimport { OptionType, RadioButtonsProps } from \"./types\"\n\nconst RadioButtons = forwardRef(\n (\n {\n options,\n disabled,\n direction,\n defaultValue,\n value: valueOfProps,\n onChange,\n isSquare,\n ...otherProps\n }: RadioButtonsProps,\n ref: ForwardedRef<HTMLInputElement>\n ) => {\n const [value, setValue] = useState(\n defaultValue || valueOfProps || options[0].value\n )\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const radioValue = e.target.value\n setValue(radioValue)\n if (onChange) {\n onChange(e, radioValue)\n }\n }\n\n const handleClick = (e: any) => {\n const radioValue = e.target.value\n if (String(value) === String(radioValue)) {\n setValue(null)\n if (onChange) {\n onChange(e, null)\n }\n }\n }\n\n useEffect(() => {\n if (valueOfProps) {\n setValue(valueOfProps)\n }\n }, [valueOfProps])\n\n return (\n <Grid container direction={direction} ref={ref}>\n {options.map((option: OptionType) => (\n <Radio\n key={option.value}\n value={option.value}\n label={option.label}\n disabled={Boolean(disabled)}\n checked={String(value) === String(option.value)}\n isSquare={isSquare}\n onClick={handleClick}\n onChange={handleChange}\n {...otherProps}\n />\n ))}\n </Grid>\n )\n }\n)\n\nRadioButtons.defaultProps = {\n disabled: false,\n direction: \"row\",\n fullWidth: false,\n defaultValue: undefined,\n}\n\nRadioButtons.displayName = \"RadioButtons\"\n\nexport default RadioButtons\n","import React, { ChangeEvent, useEffect } from \"react\"\nimport { Controller, Path, PathValue } from \"react-hook-form\"\nimport { ControllerRenderProps } from \"react-hook-form/dist/types/controller\"\nimport RadioButtons from \"../RadioButtons\"\nimport { RadioButtonsWithControllerProps } from \"./types\"\n\nfunction RadioButtonsWithController<T extends object>({\n form,\n name,\n defaultValue,\n ...otherProps\n}: RadioButtonsWithControllerProps<T>) {\n const handleChange = (\n e: ChangeEvent<HTMLInputElement>,\n value: string | null,\n field: ControllerRenderProps<any, Path<T>>\n ) => {\n field.onChange({ target: { value, name }, type: \"change\" })\n if (otherProps.onChange) {\n otherProps.onChange(e, value)\n }\n }\n\n useEffect(() => {\n if (!form.getValues(name as Path<T>) && !defaultValue) {\n form.setValue(\n name as Path<T>,\n otherProps.options[0].value as PathValue<T, any>\n )\n }\n }, [])\n\n return (\n <Controller\n control={form.control}\n name={String(name) as Path<T>}\n render={({ field }) => (\n <RadioButtons\n {...otherProps}\n {...field}\n defaultValue={defaultValue}\n onChange={(e: ChangeEvent<HTMLInputElement>, value: string | null) =>\n handleChange(e, value, field)\n }\n />\n )}\n />\n )\n}\n\nexport default RadioButtonsWithController\n","import * as React from \"react\"\nimport styled from \"@emotion/styled\"\nimport { useController } from \"react-hook-form\"\nimport { css } from \"@emotion/react\"\nimport { Caption, Grid, InputMessage, theme } from \"kui-basic\"\nimport {\n RadioGroupTitleStylesProps,\n RadioGroupWithLabelProps,\n RadioGroupWithTitleStylesProps,\n} from \"./types\"\nimport RadioButtonsWithController from \"../RadioButtonsWithController\"\n\nfunction RadioGroupWithLabel<TFormValues extends object>(\n props: RadioGroupWithLabelProps<TFormValues>\n) {\n const { title, className, direction, form, name, ...otherProps } = props\n const { fieldState } = useController({\n control: form.control,\n name,\n })\n const errorMessage = fieldState.error?.message\n\n return (\n <StyledContainer>\n <StyledWrapper\n container\n alignItems={direction === \"vertical\" ? \"flex-start\" : \"center\"}\n justify=\"space-between\"\n direction={direction === \"vertical\" ? \"column\" : \"row\"}\n hasError={!!errorMessage}\n className={className}\n withTitle={!!title}\n >\n {title && (\n <StyledTitle direction={direction} size=\"xs\" weight={600}>\n {title.toUpperCase()}\n </StyledTitle>\n )}\n <Grid item>\n <RadioButtonsWithController form={form} name={name} {...otherProps} />\n </Grid>\n </StyledWrapper>\n {errorMessage && <InputMessage variant=\"error\" msg={errorMessage} />}\n </StyledContainer>\n )\n}\n\nexport default RadioGroupWithLabel\n\nconst StyledContainer = styled.div`\n position: relative;\n`\n\nconst columnDirectionCSS = ({\n hasError,\n}: RadioGroupWithTitleStylesProps) => css`\n padding: 12px 15px 15px;\n border-radius: ${hasError ? \"8px 8px 0 0\" : \"8px\"};\n`\n\nconst rowDirectionCSS = ({\n hasError,\n withTitle,\n}: RadioGroupWithTitleStylesProps) => css`\n padding: ${withTitle ? \"3px 4px 3px 16px\" : \"3px\"};\n border-radius: ${hasError ? \"66px 66px 0 0\" : \"66px\"};\n`\n\nconst StyledWrapper = styled(Grid, {\n shouldForwardProp: (prop) => prop !== \"hasError\" && prop !== \"withTitle\",\n})<RadioGroupWithTitleStylesProps>`\n border: 1px solid\n ${({ hasError }) =>\n hasError ? theme.palette.red.fiftyP : theme.palette.grey.fifteenB};\n ${({ direction, hasError, withTitle }) =>\n direction === \"column\"\n ? columnDirectionCSS({ hasError })\n : rowDirectionCSS({ hasError, withTitle })};\n`\n\nconst StyledTitle = styled(Caption)<RadioGroupTitleStylesProps>`\n margin-bottom: ${({ direction }) => (direction === \"vertical\" ? 8 : 0)}px;\n`\n"],"names":["forwardRef","useState","useEffect","_jsx","Grid","Radio","Controller","useController","_jsxs","InputMessage","styled","css","theme","Caption"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAiBA;AACO,IAAI,QAAQ,GAAG,WAAW;AACjC,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAM,IAAI,SAAS,QAAQ,CAAC,CAAC,EAAE;AACrD,Q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E4C,CAC/C,CAAA;AAED,IAAM,WAAW,GAAGF,0BAAM,CAACG,gBAAO,CAAC,CAA4B,gBAAA,KAAA,gBAAA,GAAA,oBAAA,CAAA,CAAA,qBAAA,EAAA,OAAA,CAAA,EAAA,CAAA,qBAC5C,EAAqD,OACvE,CADkB,CAAA,CAAA,EAAA,UAAC,EAAa,EAAA;AAAX,IAAA,IAAA,SAAS,GAAA,EAAA,CAAA,SAAA,CAAA;AAAO,IAAA,QAAC,SAAS,KAAK,UAAU,GAAG,CAAC,GAAG,CAAC,EAAC;AAAlC,CAAkC,CACvE,CAAA;;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RadioGroupProps } from '@mui/material';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
interface RadioButtonsProps extends Omit<RadioGroupProps, "onChange"> {
|
|
5
|
+
options: OptionType[]
|
|
6
|
+
disabled?: boolean
|
|
7
|
+
direction?: "row" | "column"
|
|
8
|
+
fullWidth?: boolean
|
|
9
|
+
defaultValue?: any
|
|
10
|
+
isInvalid?: boolean
|
|
11
|
+
testId?: number | string
|
|
12
|
+
isSquare?: boolean
|
|
13
|
+
onChange?: (
|
|
14
|
+
event: React.ChangeEvent<HTMLInputElement>,
|
|
15
|
+
value: string | null
|
|
16
|
+
) => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type OptionType = {
|
|
20
|
+
value: string | number
|
|
21
|
+
label: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type RadioGroupWithTitleDirections = "horizontal" | "vertical"
|
|
25
|
+
|
|
26
|
+
type RadioGroupWithLabelProps<TFormValues> = {
|
|
27
|
+
title: string
|
|
28
|
+
options: OptionType[]
|
|
29
|
+
direction?: RadioGroupWithTitleDirections
|
|
30
|
+
} & RadioButtonsProps<TFormValues>
|
|
31
|
+
|
|
32
|
+
declare function RadioGroupWithLabel<TFormValues extends object>(props: RadioGroupWithLabelProps<TFormValues>): JSX.Element;
|
|
33
|
+
|
|
34
|
+
export { RadioGroupWithLabel as default };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import { Controller, useController } from 'react-hook-form';
|
|
4
|
+
import { css } from '@emotion/react';
|
|
5
|
+
import { Grid, Radio, theme, Caption, InputMessage } from 'kui-basic';
|
|
6
|
+
import { forwardRef, useState, useEffect } from 'react';
|
|
7
|
+
|
|
8
|
+
/******************************************************************************
|
|
9
|
+
Copyright (c) Microsoft Corporation.
|
|
10
|
+
|
|
11
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
12
|
+
purpose with or without fee is hereby granted.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
15
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
16
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
17
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
18
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
+
***************************************************************************** */
|
|
22
|
+
|
|
23
|
+
var __assign = function() {
|
|
24
|
+
__assign = Object.assign || function __assign(t) {
|
|
25
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
26
|
+
s = arguments[i];
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
28
|
+
}
|
|
29
|
+
return t;
|
|
30
|
+
};
|
|
31
|
+
return __assign.apply(this, arguments);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function __rest(s, e) {
|
|
35
|
+
var t = {};
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
37
|
+
t[p] = s[p];
|
|
38
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
39
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
40
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
41
|
+
t[p[i]] = s[p[i]];
|
|
42
|
+
}
|
|
43
|
+
return t;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function __makeTemplateObject(cooked, raw) {
|
|
47
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
48
|
+
return cooked;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var RadioButtons = forwardRef(function (_a, ref) {
|
|
52
|
+
var options = _a.options, disabled = _a.disabled, direction = _a.direction, defaultValue = _a.defaultValue, valueOfProps = _a.value, onChange = _a.onChange, isSquare = _a.isSquare, otherProps = __rest(_a, ["options", "disabled", "direction", "defaultValue", "value", "onChange", "isSquare"]);
|
|
53
|
+
var _b = useState(defaultValue || valueOfProps || options[0].value), value = _b[0], setValue = _b[1];
|
|
54
|
+
var handleChange = function (e) {
|
|
55
|
+
var radioValue = e.target.value;
|
|
56
|
+
setValue(radioValue);
|
|
57
|
+
if (onChange) {
|
|
58
|
+
onChange(e, radioValue);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var handleClick = function (e) {
|
|
62
|
+
var radioValue = e.target.value;
|
|
63
|
+
if (String(value) === String(radioValue)) {
|
|
64
|
+
setValue(null);
|
|
65
|
+
if (onChange) {
|
|
66
|
+
onChange(e, null);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
useEffect(function () {
|
|
71
|
+
if (valueOfProps) {
|
|
72
|
+
setValue(valueOfProps);
|
|
73
|
+
}
|
|
74
|
+
}, [valueOfProps]);
|
|
75
|
+
return (jsx(Grid, __assign({ container: true, direction: direction, ref: ref }, { children: options.map(function (option) { return (jsx(Radio, __assign({ value: option.value, label: option.label, disabled: Boolean(disabled), checked: String(value) === String(option.value), isSquare: isSquare, onClick: handleClick, onChange: handleChange }, otherProps), option.value)); }) })));
|
|
76
|
+
});
|
|
77
|
+
RadioButtons.defaultProps = {
|
|
78
|
+
disabled: false,
|
|
79
|
+
direction: "row",
|
|
80
|
+
fullWidth: false,
|
|
81
|
+
defaultValue: undefined,
|
|
82
|
+
};
|
|
83
|
+
RadioButtons.displayName = "RadioButtons";
|
|
84
|
+
|
|
85
|
+
function RadioButtonsWithController(_a) {
|
|
86
|
+
var form = _a.form, name = _a.name, defaultValue = _a.defaultValue, otherProps = __rest(_a, ["form", "name", "defaultValue"]);
|
|
87
|
+
var handleChange = function (e, value, field) {
|
|
88
|
+
field.onChange({ target: { value: value, name: name }, type: "change" });
|
|
89
|
+
if (otherProps.onChange) {
|
|
90
|
+
otherProps.onChange(e, value);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
useEffect(function () {
|
|
94
|
+
if (!form.getValues(name) && !defaultValue) {
|
|
95
|
+
form.setValue(name, otherProps.options[0].value);
|
|
96
|
+
}
|
|
97
|
+
}, []);
|
|
98
|
+
return (jsx(Controller, { control: form.control, name: String(name), render: function (_a) {
|
|
99
|
+
var field = _a.field;
|
|
100
|
+
return (jsx(RadioButtons, __assign({}, otherProps, field, { defaultValue: defaultValue, onChange: function (e, value) {
|
|
101
|
+
return handleChange(e, value, field);
|
|
102
|
+
} })));
|
|
103
|
+
} }));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function RadioGroupWithLabel(props) {
|
|
107
|
+
var _a;
|
|
108
|
+
var title = props.title, className = props.className, direction = props.direction, form = props.form, name = props.name, otherProps = __rest(props, ["title", "className", "direction", "form", "name"]);
|
|
109
|
+
var fieldState = useController({
|
|
110
|
+
control: form.control,
|
|
111
|
+
name: name,
|
|
112
|
+
}).fieldState;
|
|
113
|
+
var errorMessage = (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
|
|
114
|
+
return (jsxs(StyledContainer, { children: [jsxs(StyledWrapper, __assign({ container: true, alignItems: direction === "vertical" ? "flex-start" : "center", justify: "space-between", direction: direction === "vertical" ? "column" : "row", hasError: !!errorMessage, className: className, withTitle: !!title }, { children: [title && (jsx(StyledTitle, __assign({ direction: direction, size: "xs", weight: 600 }, { children: title.toUpperCase() }))), jsx(Grid, __assign({ item: true }, { children: jsx(RadioButtonsWithController, __assign({ form: form, name: name }, otherProps)) }))] })), errorMessage && jsx(InputMessage, { variant: "error", msg: errorMessage })] }));
|
|
115
|
+
}
|
|
116
|
+
var StyledContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
|
|
117
|
+
var columnDirectionCSS = function (_a) {
|
|
118
|
+
var hasError = _a.hasError;
|
|
119
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 12px 15px 15px;\n border-radius: ", ";\n"], ["\n padding: 12px 15px 15px;\n border-radius: ", ";\n"])), hasError ? "8px 8px 0 0" : "8px");
|
|
120
|
+
};
|
|
121
|
+
var rowDirectionCSS = function (_a) {
|
|
122
|
+
var hasError = _a.hasError, withTitle = _a.withTitle;
|
|
123
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: ", ";\n border-radius: ", ";\n"], ["\n padding: ", ";\n border-radius: ", ";\n"])), withTitle ? "3px 4px 3px 16px" : "3px", hasError ? "66px 66px 0 0" : "66px");
|
|
124
|
+
};
|
|
125
|
+
var StyledWrapper = styled(Grid, {
|
|
126
|
+
shouldForwardProp: function (prop) { return prop !== "hasError" && prop !== "withTitle"; },
|
|
127
|
+
})(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n border: 1px solid\n ", ";\n ", ";\n"], ["\n border: 1px solid\n ", ";\n ", ";\n"])), function (_a) {
|
|
128
|
+
var hasError = _a.hasError;
|
|
129
|
+
return hasError ? theme.palette.red.fiftyP : theme.palette.grey.fifteenB;
|
|
130
|
+
}, function (_a) {
|
|
131
|
+
var direction = _a.direction, hasError = _a.hasError, withTitle = _a.withTitle;
|
|
132
|
+
return direction === "column"
|
|
133
|
+
? columnDirectionCSS({ hasError: hasError })
|
|
134
|
+
: rowDirectionCSS({ hasError: hasError, withTitle: withTitle });
|
|
135
|
+
});
|
|
136
|
+
var StyledTitle = styled(Caption)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-bottom: ", "px;\n"], ["\n margin-bottom: ", "px;\n"])), function (_a) {
|
|
137
|
+
var direction = _a.direction;
|
|
138
|
+
return (direction === "vertical" ? 8 : 0);
|
|
139
|
+
});
|
|
140
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
141
|
+
|
|
142
|
+
export { RadioGroupWithLabel as default };
|
|
143
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../node_modules/tslib/tslib.es6.js","../../src/components/RadioButtons/index.tsx","../../src/components/RadioButtonsWithController/index.tsx","../../src/components/RadioGroupWithLabel/index.tsx"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n 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;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","import React, { ForwardedRef, forwardRef, useEffect, useState } from \"react\"\nimport { Grid, Radio } from \"kui-basic\"\nimport { OptionType, RadioButtonsProps } from \"./types\"\n\nconst RadioButtons = forwardRef(\n (\n {\n options,\n disabled,\n direction,\n defaultValue,\n value: valueOfProps,\n onChange,\n isSquare,\n ...otherProps\n }: RadioButtonsProps,\n ref: ForwardedRef<HTMLInputElement>\n ) => {\n const [value, setValue] = useState(\n defaultValue || valueOfProps || options[0].value\n )\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const radioValue = e.target.value\n setValue(radioValue)\n if (onChange) {\n onChange(e, radioValue)\n }\n }\n\n const handleClick = (e: any) => {\n const radioValue = e.target.value\n if (String(value) === String(radioValue)) {\n setValue(null)\n if (onChange) {\n onChange(e, null)\n }\n }\n }\n\n useEffect(() => {\n if (valueOfProps) {\n setValue(valueOfProps)\n }\n }, [valueOfProps])\n\n return (\n <Grid container direction={direction} ref={ref}>\n {options.map((option: OptionType) => (\n <Radio\n key={option.value}\n value={option.value}\n label={option.label}\n disabled={Boolean(disabled)}\n checked={String(value) === String(option.value)}\n isSquare={isSquare}\n onClick={handleClick}\n onChange={handleChange}\n {...otherProps}\n />\n ))}\n </Grid>\n )\n }\n)\n\nRadioButtons.defaultProps = {\n disabled: false,\n direction: \"row\",\n fullWidth: false,\n defaultValue: undefined,\n}\n\nRadioButtons.displayName = \"RadioButtons\"\n\nexport default RadioButtons\n","import React, { ChangeEvent, useEffect } from \"react\"\nimport { Controller, Path, PathValue } from \"react-hook-form\"\nimport { ControllerRenderProps } from \"react-hook-form/dist/types/controller\"\nimport RadioButtons from \"../RadioButtons\"\nimport { RadioButtonsWithControllerProps } from \"./types\"\n\nfunction RadioButtonsWithController<T extends object>({\n form,\n name,\n defaultValue,\n ...otherProps\n}: RadioButtonsWithControllerProps<T>) {\n const handleChange = (\n e: ChangeEvent<HTMLInputElement>,\n value: string | null,\n field: ControllerRenderProps<any, Path<T>>\n ) => {\n field.onChange({ target: { value, name }, type: \"change\" })\n if (otherProps.onChange) {\n otherProps.onChange(e, value)\n }\n }\n\n useEffect(() => {\n if (!form.getValues(name as Path<T>) && !defaultValue) {\n form.setValue(\n name as Path<T>,\n otherProps.options[0].value as PathValue<T, any>\n )\n }\n }, [])\n\n return (\n <Controller\n control={form.control}\n name={String(name) as Path<T>}\n render={({ field }) => (\n <RadioButtons\n {...otherProps}\n {...field}\n defaultValue={defaultValue}\n onChange={(e: ChangeEvent<HTMLInputElement>, value: string | null) =>\n handleChange(e, value, field)\n }\n />\n )}\n />\n )\n}\n\nexport default RadioButtonsWithController\n","import * as React from \"react\"\nimport styled from \"@emotion/styled\"\nimport { useController } from \"react-hook-form\"\nimport { css } from \"@emotion/react\"\nimport { Caption, Grid, InputMessage, theme } from \"kui-basic\"\nimport {\n RadioGroupTitleStylesProps,\n RadioGroupWithLabelProps,\n RadioGroupWithTitleStylesProps,\n} from \"./types\"\nimport RadioButtonsWithController from \"../RadioButtonsWithController\"\n\nfunction RadioGroupWithLabel<TFormValues extends object>(\n props: RadioGroupWithLabelProps<TFormValues>\n) {\n const { title, className, direction, form, name, ...otherProps } = props\n const { fieldState } = useController({\n control: form.control,\n name,\n })\n const errorMessage = fieldState.error?.message\n\n return (\n <StyledContainer>\n <StyledWrapper\n container\n alignItems={direction === \"vertical\" ? \"flex-start\" : \"center\"}\n justify=\"space-between\"\n direction={direction === \"vertical\" ? \"column\" : \"row\"}\n hasError={!!errorMessage}\n className={className}\n withTitle={!!title}\n >\n {title && (\n <StyledTitle direction={direction} size=\"xs\" weight={600}>\n {title.toUpperCase()}\n </StyledTitle>\n )}\n <Grid item>\n <RadioButtonsWithController form={form} name={name} {...otherProps} />\n </Grid>\n </StyledWrapper>\n {errorMessage && <InputMessage variant=\"error\" msg={errorMessage} />}\n </StyledContainer>\n )\n}\n\nexport default RadioGroupWithLabel\n\nconst StyledContainer = styled.div`\n position: relative;\n`\n\nconst columnDirectionCSS = ({\n hasError,\n}: RadioGroupWithTitleStylesProps) => css`\n padding: 12px 15px 15px;\n border-radius: ${hasError ? \"8px 8px 0 0\" : \"8px\"};\n`\n\nconst rowDirectionCSS = ({\n hasError,\n withTitle,\n}: RadioGroupWithTitleStylesProps) => css`\n padding: ${withTitle ? \"3px 4px 3px 16px\" : \"3px\"};\n border-radius: ${hasError ? \"66px 66px 0 0\" : \"66px\"};\n`\n\nconst StyledWrapper = styled(Grid, {\n shouldForwardProp: (prop) => prop !== \"hasError\" && prop !== \"withTitle\",\n})<RadioGroupWithTitleStylesProps>`\n border: 1px solid\n ${({ hasError }) =>\n hasError ? theme.palette.red.fiftyP : theme.palette.grey.fifteenB};\n ${({ direction, hasError, withTitle }) =>\n direction === \"column\"\n ? columnDirectionCSS({ hasError })\n : rowDirectionCSS({ hasError, withTitle })};\n`\n\nconst StyledTitle = styled(Caption)<RadioGroupTitleStylesProps>`\n margin-bottom: ${({ direction }) => (direction === \"vertical\" ? 8 : 0)}px;\n`\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;A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AS,KAAK,QAAQ;AACpB,UAAE,kBAAkB,CAAC,EAAE,QAAQ,EAAA,QAAA,EAAE,CAAC;UAChC,eAAe,CAAC,EAAE,QAAQ,UAAA,EAAE,SAAS,EAAA,SAAA,EAAE,CAAC,CAAA;AAF5C,CAE4C,CAC/C,CAAA;AAED,IAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,CAA4B,gBAAA,KAAA,gBAAA,GAAA,oBAAA,CAAA,CAAA,qBAAA,EAAA,OAAA,CAAA,EAAA,CAAA,qBAC5C,EAAqD,OACvE,CADkB,CAAA,CAAA,EAAA,UAAC,EAAa,EAAA;AAAX,IAAA,IAAA,SAAS,GAAA,EAAA,CAAA,SAAA,CAAA;AAAO,IAAA,QAAC,SAAS,KAAK,UAAU,GAAG,CAAC,GAAG,CAAC,EAAC;AAAlC,CAAkC,CACvE,CAAA;;;;;"}
|
package/SelectMonth/cjs/index.js
CHANGED
|
@@ -4,9 +4,8 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var jsxRuntime$1 = require('@emotion/react/jsx-runtime');
|
|
6
6
|
var styled = require('@emotion/styled');
|
|
7
|
-
var kuiIcon = require('kui-icon');
|
|
8
7
|
var kuiBasic = require('kui-basic');
|
|
9
|
-
var
|
|
8
|
+
var kuiIcon = require('kui-icon');
|
|
10
9
|
|
|
11
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
11
|
|
|
@@ -101,7 +100,7 @@ var InputDropdown = react.forwardRef(function (props, ref) {
|
|
|
101
100
|
};
|
|
102
101
|
return (jsxRuntime.jsxs(StyledDropdown$1, __assign({ "data-testid": "input_dropdown", container: true, ref: forwardedRef, isOpen: isOpen }, otherProps, { children: [jsxRuntime.jsx(StyledWrapper, __assign({ isScrollable: isScrollable }, { children: jsxRuntime.jsx(ScrollingContainer, __assign({ isScrollable: isScrollable, className: "KUI-InputDropdown_scroll" }, { children: children })) })), endComponent] })));
|
|
103
102
|
});
|
|
104
|
-
var StyledDropdown$1 = styled__default["default"](kuiBasic.Grid)(templateObject_1$
|
|
103
|
+
var StyledDropdown$1 = styled__default["default"](kuiBasic.Grid)(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n width: 100%;\n display: ", ";\n position: absolute;\n background: ", ";\n z-index: 3;\n top: 50px;\n box-shadow: 0px 26px 34px 0px #0000001a;\n border-radius: 0 0 8px 8px;\n user-select: none;\n"], ["\n width: 100%;\n display: ", ";\n position: absolute;\n background: ", ";\n z-index: 3;\n top: 50px;\n box-shadow: 0px 26px 34px 0px #0000001a;\n border-radius: 0 0 8px 8px;\n user-select: none;\n"])), function (_a) {
|
|
105
104
|
var isOpen = _a.isOpen;
|
|
106
105
|
return (isOpen ? "flex" : "none");
|
|
107
106
|
}, kuiBasic.theme.palette.grey.zero);
|
|
@@ -109,77 +108,36 @@ var StyledWrapper = styled__default["default"].div(templateObject_2$2 || (templa
|
|
|
109
108
|
var isScrollable = _a.isScrollable;
|
|
110
109
|
return isScrollable ? "14px 8px 8px 0" : "14px 0px 8px 0";
|
|
111
110
|
});
|
|
112
|
-
var ScrollingContainer = styled__default["default"].div(templateObject_3
|
|
111
|
+
var ScrollingContainer = styled__default["default"].div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 100%;\n max-height: 389px;\n box-sizing: border-box;\n z-index: 3;\n overflow: auto;\n -ms-overflow-style: none;\n overflow-y: scroll;\n overflow-x: hidden;\n user-select: none;\n ::-webkit-scrollbar {\n width: ", ";\n position: absolute;\n right: 8px;\n }\n ::-webkit-scrollbar-track,\n ::-webkit-scrollbar-thumb {\n border-radius: 4px;\n transition: all ease-out 0.3s;\n }\n\n ::-webkit-resizer,\n ::-webkit-scrollbar-button,\n ::-webkit-scrollbar-corner {\n display: none;\n }\n ::-webkit-scrollbar-track {\n background: ", ";\n }\n\n ::-webkit-scrollbar-thumb {\n background: ", ";\n }\n"], ["\n width: 100%;\n max-height: 389px;\n box-sizing: border-box;\n z-index: 3;\n overflow: auto;\n -ms-overflow-style: none;\n overflow-y: scroll;\n overflow-x: hidden;\n user-select: none;\n ::-webkit-scrollbar {\n width: ", ";\n position: absolute;\n right: 8px;\n }\n ::-webkit-scrollbar-track,\n ::-webkit-scrollbar-thumb {\n border-radius: 4px;\n transition: all ease-out 0.3s;\n }\n\n ::-webkit-resizer,\n ::-webkit-scrollbar-button,\n ::-webkit-scrollbar-corner {\n display: none;\n }\n ::-webkit-scrollbar-track {\n background: ", ";\n }\n\n ::-webkit-scrollbar-thumb {\n background: ", ";\n }\n"])), function (_a) {
|
|
113
112
|
var isScrollable = _a.isScrollable;
|
|
114
113
|
return (isScrollable ? "4px" : "0px");
|
|
115
114
|
}, kuiBasic.theme.palette.grey.fifteenB, kuiBasic.theme.palette.grey.thirty);
|
|
116
|
-
var templateObject_1$
|
|
115
|
+
var templateObject_1$3, templateObject_2$2, templateObject_3;
|
|
117
116
|
|
|
118
117
|
var InputSelectDropdown = react.forwardRef(function (_a, ref) {
|
|
119
|
-
var options = _a.options, inputRef = _a.inputRef, isOpenDropdown = _a.isOpenDropdown, handleCloseDropdown = _a.handleCloseDropdown, handleSelect = _a.handleSelect, selectedValue = _a.selectedValue;
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (isOpenDropdown) {
|
|
124
|
-
var element = document.querySelector("[data-value=autocomplete_option_".concat(selectedValue, "]"));
|
|
125
|
-
var coordinates = element === null || element === void 0 ? void 0 : element.getBoundingClientRect();
|
|
126
|
-
if (coordinates && inputRef.current && element) {
|
|
127
|
-
(_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
|
128
|
-
top: coordinates.top -
|
|
129
|
-
inputRef.current.clientHeight -
|
|
130
|
-
element.clientHeight,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}, [isOpenDropdown]);
|
|
135
|
-
var forwardedRef = function (elem) {
|
|
136
|
-
if (ref) {
|
|
137
|
-
if (typeof ref === "function")
|
|
138
|
-
ref(elem);
|
|
139
|
-
else
|
|
140
|
-
ref.current = elem;
|
|
118
|
+
var options = _a.options, inputRef = _a.inputRef, isOpenDropdown = _a.isOpenDropdown, handleCloseDropdown = _a.handleCloseDropdown, handleSelect = _a.handleSelect, selectedValue = _a.selectedValue, renderOption = _a.renderOption;
|
|
119
|
+
var handleClick = function (option) {
|
|
120
|
+
if (!option.disabled) {
|
|
121
|
+
handleSelect(option);
|
|
141
122
|
}
|
|
142
|
-
dropdownRef.current = elem;
|
|
143
123
|
};
|
|
144
|
-
return (jsxRuntime
|
|
124
|
+
return (jsxRuntime.jsx(StyledDropdown, __assign({ buttonRef: inputRef, isOpen: isOpenDropdown, handleClose: handleCloseDropdown, ref: ref }, { children: options.map(function (option, key) { return (jsxRuntime.jsx(OptionWrapper, __assign({ disabled: option.disabled, onClick: function () { return handleClick(option); }, "data-value": "autocomplete_option_".concat(option.value), "data-testid": "autocomplete_option_".concat(key) }, { children: renderOption(option, selectedValue) }), option.label)); }) })));
|
|
145
125
|
});
|
|
146
|
-
var OptionWrapper = styled__default["default"].div(templateObject_1$
|
|
147
|
-
var
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
var
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
names === null || names === void 0 ? void 0 : names.forEach(function (field) {
|
|
156
|
-
if (fieldValue) {
|
|
157
|
-
fieldValue = fieldValue[field];
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
return fieldValue;
|
|
161
|
-
};
|
|
162
|
-
var getFormError = function (name, form) {
|
|
163
|
-
var names = name === null || name === void 0 ? void 0 : name.split(".");
|
|
164
|
-
var fieldError = form === null || form === void 0 ? void 0 : form.formState.errors;
|
|
165
|
-
names === null || names === void 0 ? void 0 : names.forEach(function (field) {
|
|
166
|
-
if (fieldError) {
|
|
167
|
-
// @ts-ignore
|
|
168
|
-
fieldError = fieldError[field];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
return fieldError === null || fieldError === void 0 ? void 0 : fieldError.message;
|
|
172
|
-
};
|
|
126
|
+
var OptionWrapper = styled__default["default"].div(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n width: 100%;\n padding: 2px 0;\n cursor: ", ";\n p {\n color: ", ";\n }\n"], ["\n width: 100%;\n padding: 2px 0;\n cursor: ", ";\n p {\n color: ", ";\n }\n"])), function (_a) {
|
|
127
|
+
var disabled = _a.disabled;
|
|
128
|
+
return (disabled ? "auto" : "pointer");
|
|
129
|
+
}, function (_a) {
|
|
130
|
+
var disabled = _a.disabled;
|
|
131
|
+
return disabled ? kuiBasic.theme.palette.grey.fiftyP : kuiBasic.theme.palette.grey.seventy;
|
|
132
|
+
});
|
|
133
|
+
var StyledDropdown = styled__default["default"](InputDropdown)(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n .KUI-InputDropdown_scroll {\n max-height: 142px;\n padding: 0 4px;\n }\n"], ["\n .KUI-InputDropdown_scroll {\n max-height: 142px;\n padding: 0 4px;\n }\n"])));
|
|
134
|
+
var templateObject_1$2, templateObject_2$1;
|
|
173
135
|
|
|
174
|
-
|
|
175
|
-
var
|
|
176
|
-
var options =
|
|
136
|
+
function InputSelectBase(_a) {
|
|
137
|
+
var _b;
|
|
138
|
+
var options = _a.options, name = _a.name, disabled = _a.disabled, handleChange = _a.handleChange, iconProps = _a.iconProps, renderOption = _a.renderOption, selectedLabel = _a.selectedLabel, selectedValue = _a.selectedValue, error = _a.error, inputProps = __rest(_a, ["options", "name", "disabled", "handleChange", "iconProps", "renderOption", "selectedLabel", "selectedValue", "error"]);
|
|
177
139
|
var _c = react.useState(false), isDropdownOpen = _c[0], setIsDropdownOpen = _c[1];
|
|
178
|
-
var _d = react.useState(defaultValue || getFormValue(name, form)), value = _d[0], setValue = _d[1];
|
|
179
|
-
var error = getFormError(name, form);
|
|
180
140
|
var inputRef = react.useRef(null);
|
|
181
|
-
var selectedLabel = (_a = options === null || options === void 0 ? void 0 : options.find(function (option) { return String(option.value) === String(value); })) === null || _a === void 0 ? void 0 : _a.label;
|
|
182
|
-
var register = form === null || form === void 0 ? void 0 : form.register(name);
|
|
183
141
|
var handleOpenDropdown = function () {
|
|
184
142
|
var _a, _b, _c, _d;
|
|
185
143
|
if ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.parentElement) {
|
|
@@ -191,41 +149,51 @@ var InputSelect = react.forwardRef(function (props, ref) {
|
|
|
191
149
|
setIsDropdownOpen(false);
|
|
192
150
|
};
|
|
193
151
|
var handleSelect = function (option) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
handleChange(option.value);
|
|
197
|
-
}
|
|
198
|
-
if (form) {
|
|
199
|
-
register === null || register === void 0 ? void 0 : register.onChange({
|
|
200
|
-
target: { value: option.value, name: name },
|
|
201
|
-
type: "change",
|
|
202
|
-
});
|
|
203
|
-
}
|
|
152
|
+
if (handleChange)
|
|
153
|
+
handleChange(option);
|
|
204
154
|
handleCloseDropdown();
|
|
205
155
|
};
|
|
206
|
-
|
|
207
|
-
if (ref) {
|
|
208
|
-
// eslint-disable-next-line no-param-reassign
|
|
209
|
-
// @ts-ignore
|
|
210
|
-
ref.current = e;
|
|
211
|
-
}
|
|
212
|
-
// @ts-ignore
|
|
213
|
-
inputRef.current = e;
|
|
214
|
-
register === null || register === void 0 ? void 0 : register.ref(e);
|
|
215
|
-
};
|
|
216
|
-
return (jsxRuntime$1.jsxs(Wrapper, { children: [jsxRuntime$1.jsx("input", { name: name, autoComplete: "off", hidden: true }), jsxRuntime$1.jsx(StyledInput, __assign({ onClick: handleOpenDropdown, readOnly: true, value: selectedLabel, message: error, isDropdownOpen: isDropdownOpen }, other, { endIcon: !props.disabled && (jsxRuntime$1.jsx(kuiIcon.HalfArrowIcon, __assign({ width: 12, height: 13, css: [
|
|
156
|
+
return (jsxRuntime$1.jsxs(Wrapper, { children: [jsxRuntime$1.jsx("input", { name: name, autoComplete: "off", hidden: true }), jsxRuntime$1.jsx(StyledInput, __assign({ onClick: handleOpenDropdown, ref: inputRef, disabled: disabled, readOnly: true, value: selectedLabel, message: error, isDropdownOpen: isDropdownOpen, isLabelShrink: Boolean(selectedValue) || selectedValue === 0 }, inputProps, { endIcon: !disabled && (jsxRuntime$1.jsx(kuiIcon.HalfArrowIcon, __assign({ width: 12, height: 13, css: [
|
|
217
157
|
{ transition: "all linear .2s" },
|
|
218
158
|
isDropdownOpen && { transform: "rotate(180deg)" },
|
|
219
|
-
] }, iconProps))) }
|
|
159
|
+
] }, iconProps))) })), options.length > 0 && !disabled && (jsxRuntime$1.jsx(InputSelectDropdown, { options: options, inputRef: {
|
|
220
160
|
current: (_b = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _b === void 0 ? void 0 : _b.parentElement,
|
|
221
|
-
}, isOpenDropdown: isDropdownOpen, handleCloseDropdown: handleCloseDropdown, handleSelect: handleSelect, selectedValue:
|
|
222
|
-
}
|
|
223
|
-
var Wrapper = styled__default["default"].div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n text-align: left;\n
|
|
161
|
+
}, isOpenDropdown: isDropdownOpen, handleCloseDropdown: handleCloseDropdown, handleSelect: handleSelect, selectedValue: selectedValue, renderOption: renderOption }))] }));
|
|
162
|
+
}
|
|
163
|
+
var Wrapper = styled__default["default"].div(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n position: relative;\n text-align: left;\n"], ["\n position: relative;\n text-align: left;\n"])));
|
|
224
164
|
var StyledInput = styled__default["default"](kuiBasic.InputWithAdornments)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n cursor: pointer;\n input,\n label {\n cursor: pointer !important;\n }\n .KUI-InputMessage {\n opacity: ", ";\n }\n"], ["\n cursor: pointer;\n input,\n label {\n cursor: pointer !important;\n }\n .KUI-InputMessage {\n opacity: ", ";\n }\n"])), function (_a) {
|
|
225
165
|
var isDropdownOpen = _a.isDropdownOpen;
|
|
226
166
|
return (isDropdownOpen ? 0 : 1);
|
|
227
167
|
});
|
|
228
|
-
var templateObject_1, templateObject_2;
|
|
168
|
+
var templateObject_1$1, templateObject_2;
|
|
169
|
+
|
|
170
|
+
function InputSelectOption(props) {
|
|
171
|
+
var option = props.option, selectedValue = props.selectedValue;
|
|
172
|
+
return (jsxRuntime.jsx(StyledOption, __assign({ selected: selectedValue === option.value }, { children: jsxRuntime.jsx(kuiBasic.Caption, __assign({ size: "sm", weight: 500 }, { children: option.label })) })));
|
|
173
|
+
}
|
|
174
|
+
var StyledOption = styled__default["default"].div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 8px;\n transition: all ease-out 0.3s;\n border-radius: 4px;\n background-color: ", ";\n &:hover {\n background-color: ", ";\n }\n"], ["\n padding: 8px;\n transition: all ease-out 0.3s;\n border-radius: 4px;\n background-color: ", ";\n &:hover {\n background-color: ", ";\n }\n"])), function (_a) {
|
|
175
|
+
var selected = _a.selected;
|
|
176
|
+
return selected ? kuiBasic.theme.palette.background.light1 : kuiBasic.theme.palette.grey.zero;
|
|
177
|
+
}, kuiBasic.theme.palette.background.light1);
|
|
178
|
+
var templateObject_1;
|
|
179
|
+
|
|
180
|
+
function InputSelect(_a) {
|
|
181
|
+
var _b;
|
|
182
|
+
var options = _a.options, name = _a.name, handleChange = _a.handleChange; _a.form; var valueProp = _a.value, inputProps = __rest(_a, ["options", "name", "handleChange", "form", "value"]);
|
|
183
|
+
var _c = react.useState(valueProp), value = _c[0], setValue = _c[1];
|
|
184
|
+
var selectedLabel = (_b = options.find(function (option) { return String(option.value) === String(value); })) === null || _b === void 0 ? void 0 : _b.label;
|
|
185
|
+
var handleSelect = function (option) {
|
|
186
|
+
setValue(option.value);
|
|
187
|
+
if (handleChange) {
|
|
188
|
+
handleChange(option.value);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
react.useEffect(function () {
|
|
192
|
+
if (typeof valueProp !== "undefined")
|
|
193
|
+
setValue(valueProp);
|
|
194
|
+
}, [valueProp]);
|
|
195
|
+
return (jsxRuntime.jsx(InputSelectBase, __assign({ options: options, handleChange: handleSelect, selectedLabel: selectedLabel, selectedValue: value, name: name, renderOption: function (option, selectedValue) { return (jsxRuntime.jsx(InputSelectOption, { option: option, selectedValue: selectedValue })); } }, inputProps)));
|
|
196
|
+
}
|
|
229
197
|
|
|
230
198
|
var checkDisabled = function (month, min, max) { return (min && month <= min) || (max && month >= max); };
|
|
231
199
|
var monthValues = [
|