pixelize-design-library 2.1.46 → 2.1.48

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.
@@ -67,6 +67,9 @@ function CustomDatePicker(props) {
67
67
  if (!isRange && !selectedDate) {
68
68
  setTempDate(new Date());
69
69
  }
70
+ if (showTime) {
71
+ setTempDate(new Date()); // add new
72
+ }
70
73
  onOpen();
71
74
  };
72
75
  (0, react_1.useEffect)(function () {
@@ -164,6 +167,9 @@ function CustomDatePicker(props) {
164
167
  if (popoverRef.current &&
165
168
  !popoverRef.current.contains(event.target) &&
166
169
  !((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target))) {
170
+ if (tempDate) {
171
+ props.onChange(tempDate); // add new
172
+ }
167
173
  onClose();
168
174
  }
169
175
  };
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import { SwitchProps } from "@chakra-ui/react";
3
+ export interface ThemedSwitchProps extends SwitchProps {
4
+ switchText?: string;
5
+ switchTextPosition?: "left" | "right";
6
+ isInformation?: boolean;
7
+ informationMessage?: string;
8
+ isRequired?: boolean;
9
+ label?: string;
10
+ size?: "sm" | "md" | "lg";
11
+ }
12
+ export declare const InputSwitch: ({ switchText, switchTextPosition, id, isChecked, label, isInformation, informationMessage, isRequired, size, ...props }: ThemedSwitchProps) => React.JSX.Element;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.InputSwitch = void 0;
29
+ var react_1 = __importDefault(require("react"));
30
+ var react_2 = require("@chakra-ui/react");
31
+ var FormLabel_1 = require("../../Common/FormLabel");
32
+ var InputSwitch = function (_a) {
33
+ var switchText = _a.switchText, _b = _a.switchTextPosition, switchTextPosition = _b === void 0 ? "right" : _b, id = _a.id, isChecked = _a.isChecked, label = _a.label, isInformation = _a.isInformation, informationMessage = _a.informationMessage, isRequired = _a.isRequired, _c = _a.size, size = _c === void 0 ? "md" : _c, props = __rest(_a, ["switchText", "switchTextPosition", "id", "isChecked", "label", "isInformation", "informationMessage", "isRequired", "size"]);
34
+ var activeColor = (0, react_2.useColorModeValue)("blue.500", "blue.300");
35
+ var inactiveColor = (0, react_2.useColorModeValue)("gray.300", "gray.600");
36
+ var sizeStyles = {
37
+ sm: { fontSize: "sm", spacing: 1 },
38
+ md: { fontSize: "md", spacing: 2 },
39
+ lg: { fontSize: "lg", spacing: 3 },
40
+ };
41
+ return (react_1.default.createElement(react_2.FormControl, null,
42
+ label && (react_1.default.createElement(FormLabel_1.TextLabel, { label: label, id: id, isInformation: isInformation, informationMessage: informationMessage, isRequired: isRequired })),
43
+ react_1.default.createElement(react_2.Box, { display: "flex", alignItems: "center", flexGrow: 1 },
44
+ react_1.default.createElement(react_2.HStack, { spacing: sizeStyles[size].spacing },
45
+ switchText && switchTextPosition === "left" && (react_1.default.createElement(react_2.FormLabel, { mb: "0", htmlFor: id, fontSize: sizeStyles[size].fontSize, cursor: "pointer" }, switchText)),
46
+ react_1.default.createElement(react_2.Switch, __assign({ id: id, size: size, isChecked: isChecked, colorScheme: "blue", sx: {
47
+ "span.chakra-switch__track": {
48
+ bg: isChecked ? activeColor : inactiveColor,
49
+ },
50
+ } }, props)),
51
+ switchText && switchTextPosition === "right" && (react_1.default.createElement(react_2.FormLabel, { mb: "0", htmlFor: id, fontSize: sizeStyles[size].fontSize, cursor: "pointer" }, switchText))))));
52
+ };
53
+ exports.InputSwitch = InputSwitch;
@@ -29,8 +29,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  var react_1 = __importStar(require("react"));
30
30
  var TextInput_1 = __importDefault(require("../Components/Input/TextInput"));
31
31
  var PhoneNumberInput_1 = __importDefault(require("../Components/Input/PhoneNumberInput"));
32
+ var InputSwitch_1 = require("../Components/Input/Switch/InputSwitch");
32
33
  var InputPage = function () {
33
34
  var _a = (0, react_1.useState)([]), countries = _a[0], setCountries = _a[1];
35
+ var _b = (0, react_1.useState)(false), switchState = _b[0], setSwitchState = _b[1];
34
36
  (0, react_1.useEffect)(function () {
35
37
  fetch("https://dev.api.pixelizetech.com/account/api/allCountries")
36
38
  .then(function (res) { return res.json(); })
@@ -71,6 +73,9 @@ var InputPage = function () {
71
73
  isRequired: true, informationMessage: "This is information", isInformation: true,
72
74
  // isDisabled
73
75
  minW: "200px", maxW: "300px" }),
74
- react_1.default.createElement(PhoneNumberInput_1.default, { label: "Phone", id: "input1", name: "hello", country: "IN", value: "", countries: countries, onChange: function (val) { console.log(val, "hello"); }, isRequired: true, informationMessage: "This is information", isInformation: true, error: true, errorMessage: "Required", showCountrySelect: true, minW: "200px", maxW: "300px" })));
76
+ react_1.default.createElement(PhoneNumberInput_1.default, { label: "Phone", id: "input1", name: "hello", country: "IN", value: "", countries: countries, onChange: function (val) {
77
+ console.log(val, "hello");
78
+ }, isRequired: true, informationMessage: "This is information", isInformation: true, error: true, errorMessage: "Required", showCountrySelect: true, minW: "200px", maxW: "300px" }),
79
+ react_1.default.createElement(InputSwitch_1.InputSwitch, { id: "repeat-switch", isChecked: switchState, onChange: function (e) { return setSwitchState(e.target.checked); }, switchText: "Repeat", switchTextPosition: "right", label: "My Switch", isInformation: true, informationMessage: "This is information", isRequired: true, size: "md" })));
75
80
  };
76
81
  exports.default = InputPage;