@elliemae/ds-legacy-time-picker 1.0.0-rc.1
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/cjs/DSTimePicker.js +129 -0
- package/dist/cjs/DSTimePicker.js.map +7 -0
- package/dist/cjs/DSTimePickerMenu.js +45 -0
- package/dist/cjs/DSTimePickerMenu.js.map +7 -0
- package/dist/cjs/PickerPanel.js +337 -0
- package/dist/cjs/PickerPanel.js.map +7 -0
- package/dist/cjs/TimePickerDropdown.js +71 -0
- package/dist/cjs/TimePickerDropdown.js.map +7 -0
- package/dist/cjs/TimePickerImpl.js +190 -0
- package/dist/cjs/TimePickerImpl.js.map +7 -0
- package/dist/cjs/TimePickerMenu.js +280 -0
- package/dist/cjs/TimePickerMenu.js.map +7 -0
- package/dist/cjs/index.js +42 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/moveElementOnScroll.js +94 -0
- package/dist/cjs/moveElementOnScroll.js.map +7 -0
- package/dist/cjs/package.json +7 -0
- package/dist/cjs/utils.js +72 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/esm/DSTimePicker.js +99 -0
- package/dist/esm/DSTimePicker.js.map +7 -0
- package/dist/esm/DSTimePickerMenu.js +15 -0
- package/dist/esm/DSTimePickerMenu.js.map +7 -0
- package/dist/esm/PickerPanel.js +307 -0
- package/dist/esm/PickerPanel.js.map +7 -0
- package/dist/esm/TimePickerDropdown.js +41 -0
- package/dist/esm/TimePickerDropdown.js.map +7 -0
- package/dist/esm/TimePickerImpl.js +160 -0
- package/dist/esm/TimePickerImpl.js.map +7 -0
- package/dist/esm/TimePickerMenu.js +250 -0
- package/dist/esm/TimePickerMenu.js.map +7 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/moveElementOnScroll.js +64 -0
- package/dist/esm/moveElementOnScroll.js.map +7 -0
- package/dist/esm/package.json +7 -0
- package/dist/esm/utils.js +42 -0
- package/dist/esm/utils.js.map +7 -0
- package/dist/types/DSTimePicker.d.ts +86 -0
- package/dist/types/DSTimePickerMenu.d.ts +3 -0
- package/dist/types/PickerPanel.d.ts +25 -0
- package/dist/types/TimePickerDropdown.d.ts +24 -0
- package/dist/types/TimePickerImpl.d.ts +34 -0
- package/dist/types/TimePickerMenu.d.ts +19 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/moveElementOnScroll.d.ts +13 -0
- package/dist/types/utils.d.ts +8 -0
- package/package.json +108 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var moveElementOnScroll_exports = {};
|
|
30
|
+
__export(moveElementOnScroll_exports, {
|
|
31
|
+
MoveElementOnScroll: () => MoveElementOnScroll,
|
|
32
|
+
default: () => moveElementOnScroll_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(moveElementOnScroll_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
function MoveElementOnScroll(element, {
|
|
37
|
+
container,
|
|
38
|
+
min = 0,
|
|
39
|
+
max = element.offsetHeight,
|
|
40
|
+
speed = 1,
|
|
41
|
+
smooth = 2,
|
|
42
|
+
onUpdate = () => null,
|
|
43
|
+
onEndScroll = () => null
|
|
44
|
+
}) {
|
|
45
|
+
let moving = false;
|
|
46
|
+
let pos = min;
|
|
47
|
+
let lastPos = pos;
|
|
48
|
+
const requestFrame = function() {
|
|
49
|
+
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(func) {
|
|
50
|
+
window.setTimeout(func, 1e3 / 50);
|
|
51
|
+
};
|
|
52
|
+
}();
|
|
53
|
+
function update() {
|
|
54
|
+
moving = true;
|
|
55
|
+
const delta = (pos - lastPos) / smooth;
|
|
56
|
+
lastPos += delta;
|
|
57
|
+
if (Math.abs(delta) > 0.7) {
|
|
58
|
+
requestFrame(() => {
|
|
59
|
+
onUpdate(lastPos, delta);
|
|
60
|
+
update();
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
onEndScroll(pos);
|
|
64
|
+
moving = false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function scrolling(e) {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
let delta = e.delta || e.wheelDelta;
|
|
70
|
+
if (delta === void 0) {
|
|
71
|
+
delta = -e.detail;
|
|
72
|
+
delta *= 10 * speed;
|
|
73
|
+
}
|
|
74
|
+
pos += -delta * speed;
|
|
75
|
+
pos = Math.max(min, Math.min(pos, max));
|
|
76
|
+
if (!moving) {
|
|
77
|
+
update();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
container.addEventListener("mousewheel", scrolling, false);
|
|
81
|
+
container.addEventListener("DOMMouseScroll", scrolling, false);
|
|
82
|
+
return {
|
|
83
|
+
unsubscribe: () => {
|
|
84
|
+
container.removeEventListener("mousewheel", scrolling);
|
|
85
|
+
container.removeEventListener("DOMMouseScroll", scrolling);
|
|
86
|
+
},
|
|
87
|
+
updatePosition: (newPos) => {
|
|
88
|
+
pos = -newPos;
|
|
89
|
+
lastPos = -pos;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
var moveElementOnScroll_default = MoveElementOnScroll;
|
|
94
|
+
//# sourceMappingURL=moveElementOnScroll.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/moveElementOnScroll.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export function MoveElementOnScroll(\n element,\n {\n container,\n min = 0,\n max = element.offsetHeight,\n speed = 1,\n smooth = 2,\n onUpdate = () => null,\n onEndScroll = () => null,\n },\n) {\n let moving = false;\n let pos = min;\n let lastPos = pos;\n\n // todo: move this to utils if we finally need it\n const requestFrame = (function () {\n return (\n window.requestAnimationFrame ||\n window.webkitRequestAnimationFrame ||\n window.mozRequestAnimationFrame ||\n window.oRequestAnimationFrame ||\n window.msRequestAnimationFrame ||\n function (func) {\n window.setTimeout(func, 1000 / 50);\n }\n );\n })();\n\n function update() {\n moving = true;\n const delta = (pos - lastPos) / smooth;\n lastPos += delta;\n\n if (Math.abs(delta) > 0.7) {\n requestFrame(() => {\n onUpdate(lastPos, delta);\n update();\n });\n } else {\n onEndScroll(pos);\n moving = false;\n }\n }\n\n function scrolling(e) {\n e.preventDefault(); // disable default scrolling\n let delta = e.delta || e.wheelDelta;\n if (delta === undefined) {\n // for firefox\n delta = -e.detail;\n delta *= 10 * speed;\n }\n\n pos += -delta * speed;\n pos = Math.max(min, Math.min(pos, max)); // limit scrolling\n if (!moving) {\n update();\n }\n }\n\n container.addEventListener('mousewheel', scrolling, false);\n container.addEventListener('DOMMouseScroll', scrolling, false);\n\n return {\n unsubscribe: () => {\n container.removeEventListener('mousewheel', scrolling);\n container.removeEventListener('DOMMouseScroll', scrolling);\n },\n updatePosition: (newPos) => {\n pos = -newPos;\n lastPos = -pos;\n },\n };\n}\n\nexport default MoveElementOnScroll;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,SAAS,oBACd,SACA;AAAA,EACE;AAAA,EACA,MAAM;AAAA,EACN,MAAM,QAAQ;AAAA,EACd,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WAAW,MAAM;AAAA,EACjB,cAAc,MAAM;AACtB,GACA;AACA,MAAI,SAAS;AACb,MAAI,MAAM;AACV,MAAI,UAAU;AAGd,QAAM,eAAgB,WAAY;AAChC,WACE,OAAO,yBACP,OAAO,+BACP,OAAO,4BACP,OAAO,0BACP,OAAO,2BACP,SAAU,MAAM;AACd,aAAO,WAAW,MAAM,MAAO,EAAE;AAAA,IACnC;AAAA,EAEJ,EAAG;AAEH,WAAS,SAAS;AAChB,aAAS;AACT,UAAM,SAAS,MAAM,WAAW;AAChC,eAAW;AAEX,QAAI,KAAK,IAAI,KAAK,IAAI,KAAK;AACzB,mBAAa,MAAM;AACjB,iBAAS,SAAS,KAAK;AACvB,eAAO;AAAA,MACT,CAAC;AAAA,IACH,OAAO;AACL,kBAAY,GAAG;AACf,eAAS;AAAA,IACX;AAAA,EACF;AAEA,WAAS,UAAU,GAAG;AACpB,MAAE,eAAe;AACjB,QAAI,QAAQ,EAAE,SAAS,EAAE;AACzB,QAAI,UAAU,QAAW;AAEvB,cAAQ,CAAC,EAAE;AACX,eAAS,KAAK;AAAA,IAChB;AAEA,WAAO,CAAC,QAAQ;AAChB,UAAM,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,GAAG,CAAC;AACtC,QAAI,CAAC,QAAQ;AACX,aAAO;AAAA,IACT;AAAA,EACF;AAEA,YAAU,iBAAiB,cAAc,WAAW,KAAK;AACzD,YAAU,iBAAiB,kBAAkB,WAAW,KAAK;AAE7D,SAAO;AAAA,IACL,aAAa,MAAM;AACjB,gBAAU,oBAAoB,cAAc,SAAS;AACrD,gBAAU,oBAAoB,kBAAkB,SAAS;AAAA,IAC3D;AAAA,IACA,gBAAgB,CAAC,WAAW;AAC1B,YAAM,CAAC;AACP,gBAAU,CAAC;AAAA,IACb;AAAA,EACF;AACF;AAEA,IAAO,8BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var utils_exports = {};
|
|
30
|
+
__export(utils_exports, {
|
|
31
|
+
convertTimeString: () => convertTimeString,
|
|
32
|
+
getOptionIndex: () => getOptionIndex,
|
|
33
|
+
isAM: () => isAM,
|
|
34
|
+
validateIndex: () => validateIndex
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(utils_exports);
|
|
37
|
+
var React = __toESM(require("react"));
|
|
38
|
+
const validateIndex = (index, options) => {
|
|
39
|
+
if (index < 0)
|
|
40
|
+
return 0;
|
|
41
|
+
if (index >= options.length)
|
|
42
|
+
return options.length - 1;
|
|
43
|
+
return index;
|
|
44
|
+
};
|
|
45
|
+
const getOptionIndex = (options, selectedOption, valueProperty = "value") => {
|
|
46
|
+
const index = options.findIndex((option) => option[valueProperty] === selectedOption);
|
|
47
|
+
return validateIndex(index, options);
|
|
48
|
+
};
|
|
49
|
+
const isAM = (time) => time && time.hour() < 12;
|
|
50
|
+
const convertTimeString = (string) => {
|
|
51
|
+
if (!string)
|
|
52
|
+
return null;
|
|
53
|
+
let meridiem = "AM";
|
|
54
|
+
if (string.toUpperCase().includes("PM"))
|
|
55
|
+
meridiem = "PM";
|
|
56
|
+
const arr = string.split(":");
|
|
57
|
+
let hour = parseInt(arr[0], 10);
|
|
58
|
+
if (meridiem === "PM" && hour !== 12)
|
|
59
|
+
hour += 12;
|
|
60
|
+
if (meridiem === "AM" && hour === 12)
|
|
61
|
+
hour = 0;
|
|
62
|
+
if (meridiem === "PM" && hour === 12)
|
|
63
|
+
hour = 12;
|
|
64
|
+
const min = parseInt(arr[1], 10);
|
|
65
|
+
const sec = parseInt(arr[2], 10);
|
|
66
|
+
return {
|
|
67
|
+
hour,
|
|
68
|
+
min,
|
|
69
|
+
sec
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export const validateIndex = (index, options) => {\n if (index < 0) return 0;\n if (index >= options.length) return options.length - 1;\n return index;\n};\n\nexport const getOptionIndex = (options, selectedOption, valueProperty = 'value') => {\n const index = options.findIndex((option) => option[valueProperty] === selectedOption);\n return validateIndex(index, options);\n};\n\nexport const isAM = (time) => time && time.hour() < 12;\n\nexport const convertTimeString = (string) => {\n if (!string) return null;\n let meridiem = 'AM';\n if (string.toUpperCase().includes('PM')) meridiem = 'PM';\n\n const arr = string.split(':');\n let hour = parseInt(arr[0], 10);\n if (meridiem === 'PM' && hour !== 12) hour += 12; // formats to 24\n if (meridiem === 'AM' && hour === 12) hour = 0;\n if (meridiem === 'PM' && hour === 12) hour = 12;\n\n const min = parseInt(arr[1], 10);\n const sec = parseInt(arr[2], 10);\n\n return {\n hour,\n min,\n sec,\n };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,gBAAgB,CAAC,OAAO,YAAY;AAC/C,MAAI,QAAQ;AAAG,WAAO;AACtB,MAAI,SAAS,QAAQ;AAAQ,WAAO,QAAQ,SAAS;AACrD,SAAO;AACT;AAEO,MAAM,iBAAiB,CAAC,SAAS,gBAAgB,gBAAgB,YAAY;AAClF,QAAM,QAAQ,QAAQ,UAAU,CAAC,WAAW,OAAO,aAAa,MAAM,cAAc;AACpF,SAAO,cAAc,OAAO,OAAO;AACrC;AAEO,MAAM,OAAO,CAAC,SAAS,QAAQ,KAAK,KAAK,IAAI;AAE7C,MAAM,oBAAoB,CAAC,WAAW;AAC3C,MAAI,CAAC;AAAQ,WAAO;AACpB,MAAI,WAAW;AACf,MAAI,OAAO,YAAY,EAAE,SAAS,IAAI;AAAG,eAAW;AAEpD,QAAM,MAAM,OAAO,MAAM,GAAG;AAC5B,MAAI,OAAO,SAAS,IAAI,CAAC,GAAG,EAAE;AAC9B,MAAI,aAAa,QAAQ,SAAS;AAAI,YAAQ;AAC9C,MAAI,aAAa,QAAQ,SAAS;AAAI,WAAO;AAC7C,MAAI,aAAa,QAAQ,SAAS;AAAI,WAAO;AAE7C,QAAM,MAAM,SAAS,IAAI,CAAC,GAAG,EAAE;AAC/B,QAAM,MAAM,SAAS,IAAI,CAAC,GAAG,EAAE;AAE/B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { PropTypes, describe } from "@elliemae/ds-legacy-props-helpers";
|
|
4
|
+
import Moment from "moment";
|
|
5
|
+
import TimePickerImpl from "./TimePickerImpl.js";
|
|
6
|
+
const DSTimePicker = ({
|
|
7
|
+
containerProps = {},
|
|
8
|
+
innerRef,
|
|
9
|
+
className = "",
|
|
10
|
+
disabled = false,
|
|
11
|
+
value = "",
|
|
12
|
+
format,
|
|
13
|
+
style = {},
|
|
14
|
+
onChange = () => null,
|
|
15
|
+
onOpen = () => null,
|
|
16
|
+
isOpen = void 0,
|
|
17
|
+
clearable = false,
|
|
18
|
+
hasHeader = true,
|
|
19
|
+
hasHeaderDisplay = false,
|
|
20
|
+
"aria-label": ariaLabel,
|
|
21
|
+
zIndex = "auto",
|
|
22
|
+
placement = "bottom",
|
|
23
|
+
disabledTimes,
|
|
24
|
+
minutesInterval = 1
|
|
25
|
+
}) => /* @__PURE__ */ jsx(
|
|
26
|
+
TimePickerImpl,
|
|
27
|
+
{
|
|
28
|
+
ref: innerRef,
|
|
29
|
+
"aria-label": ariaLabel,
|
|
30
|
+
className,
|
|
31
|
+
clearable,
|
|
32
|
+
containerProps,
|
|
33
|
+
disabled,
|
|
34
|
+
format,
|
|
35
|
+
hasHeader,
|
|
36
|
+
hasHeaderDisplay,
|
|
37
|
+
isOpen,
|
|
38
|
+
onChange,
|
|
39
|
+
onOpen,
|
|
40
|
+
placement,
|
|
41
|
+
style,
|
|
42
|
+
value,
|
|
43
|
+
zIndex,
|
|
44
|
+
minutesInterval,
|
|
45
|
+
disabledTimes
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
DSTimePicker.defaultProps = {
|
|
49
|
+
format: "hh:mm:ss A"
|
|
50
|
+
};
|
|
51
|
+
const props = {
|
|
52
|
+
/** a11y label */
|
|
53
|
+
"aria-label": PropTypes.string.description("a11y label"),
|
|
54
|
+
/** inject props to time picker wrapper */
|
|
55
|
+
containerProps: PropTypes.object.description("inject props to time picker wrapper"),
|
|
56
|
+
/** Whether the time picker is disabled or not */
|
|
57
|
+
disabled: PropTypes.bool.description("Whether the time picker is disabled or not"),
|
|
58
|
+
/** Time picker value */
|
|
59
|
+
value: PropTypes.instanceOf(Moment).description("Time picker value"),
|
|
60
|
+
/** Time format (hh:mm:ss, H:m:s) */
|
|
61
|
+
format: PropTypes.string.description("Time format (hh:mm:ss, H:m:s)"),
|
|
62
|
+
/** toggle header style */
|
|
63
|
+
hasHeader: PropTypes.bool.description("toggle header style"),
|
|
64
|
+
/** toggle header display */
|
|
65
|
+
hasHeaderDisplay: PropTypes.bool.description("toggle header display"),
|
|
66
|
+
/** Handler when time picker value changes */
|
|
67
|
+
onChange: PropTypes.func.description("Handler when time picker value changes"),
|
|
68
|
+
/** Handler when the time picker menu opens */
|
|
69
|
+
onOpen: PropTypes.func.description("Handler when the time picker menu opens"),
|
|
70
|
+
/** Whether the time picker menu is opened or not */
|
|
71
|
+
isOpen: PropTypes.bool.description("Whether the time picker menu is opened or not"),
|
|
72
|
+
/** ref for time picker input */
|
|
73
|
+
innerRef: PropTypes.func.description("ref for time picker input"),
|
|
74
|
+
/** Enable to clear the time picker value */
|
|
75
|
+
clearable: PropTypes.bool.description("Enable to clear the time picker value"),
|
|
76
|
+
/** class for time picker */
|
|
77
|
+
className: PropTypes.string.description("class for time picker"),
|
|
78
|
+
/** style object */
|
|
79
|
+
style: PropTypes.object.description("style object"),
|
|
80
|
+
/** z index for menu */
|
|
81
|
+
zIndex: PropTypes.number.description("z index for menu"),
|
|
82
|
+
/** DSPopper placement */
|
|
83
|
+
placement: PropTypes.string.description("DSPopper placement"),
|
|
84
|
+
/** disabled time */
|
|
85
|
+
disabledTimes: PropTypes.object.description("disabled time"),
|
|
86
|
+
/** steps for the picker */
|
|
87
|
+
minutesInterval: PropTypes.number.description("steps for the picker")
|
|
88
|
+
};
|
|
89
|
+
DSTimePicker.propTypes = props;
|
|
90
|
+
DSTimePicker.displayName = "DSTimePicker";
|
|
91
|
+
const DSTimePickerWithSchema = describe(DSTimePicker);
|
|
92
|
+
DSTimePickerWithSchema.propTypes = props;
|
|
93
|
+
var DSTimePicker_default = DSTimePicker;
|
|
94
|
+
export {
|
|
95
|
+
DSTimePicker,
|
|
96
|
+
DSTimePickerWithSchema,
|
|
97
|
+
DSTimePicker_default as default
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=DSTimePicker.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSTimePicker.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { PropTypes, describe } from '@elliemae/ds-legacy-props-helpers';\nimport Moment from 'moment';\nimport TimePickerImpl from './TimePickerImpl.js';\n\nconst DSTimePicker = ({\n containerProps = {},\n innerRef,\n className = '',\n disabled = false,\n value = '',\n format,\n style = {},\n onChange = () => null,\n onOpen = () => null,\n isOpen = undefined,\n clearable = false,\n hasHeader = true,\n hasHeaderDisplay = false,\n 'aria-label': ariaLabel,\n zIndex = 'auto',\n placement = 'bottom',\n disabledTimes,\n minutesInterval = 1,\n}) => (\n <TimePickerImpl\n ref={innerRef}\n aria-label={ariaLabel}\n className={className}\n clearable={clearable}\n containerProps={containerProps}\n disabled={disabled}\n format={format}\n hasHeader={hasHeader}\n hasHeaderDisplay={hasHeaderDisplay}\n isOpen={isOpen}\n onChange={onChange}\n onOpen={onOpen}\n placement={placement}\n style={style}\n value={value}\n zIndex={zIndex}\n minutesInterval={minutesInterval}\n disabledTimes={disabledTimes}\n />\n);\n\nDSTimePicker.defaultProps = {\n format: 'hh:mm:ss A',\n};\n\nconst props = {\n /** a11y label */\n 'aria-label': PropTypes.string.description('a11y label'),\n /** inject props to time picker wrapper */\n containerProps: PropTypes.object.description('inject props to time picker wrapper'),\n /** Whether the time picker is disabled or not */\n disabled: PropTypes.bool.description('Whether the time picker is disabled or not'),\n /** Time picker value */\n value: PropTypes.instanceOf(Moment).description('Time picker value'),\n /** Time format (hh:mm:ss, H:m:s) */\n format: PropTypes.string.description('Time format (hh:mm:ss, H:m:s)'),\n /** toggle header style */\n hasHeader: PropTypes.bool.description('toggle header style'),\n /** toggle header display */\n hasHeaderDisplay: PropTypes.bool.description('toggle header display'),\n /** Handler when time picker value changes */\n onChange: PropTypes.func.description('Handler when time picker value changes'),\n /** Handler when the time picker menu opens */\n onOpen: PropTypes.func.description('Handler when the time picker menu opens'),\n /** Whether the time picker menu is opened or not */\n isOpen: PropTypes.bool.description('Whether the time picker menu is opened or not'),\n /** ref for time picker input */\n innerRef: PropTypes.func.description('ref for time picker input'),\n /** Enable to clear the time picker value */\n clearable: PropTypes.bool.description('Enable to clear the time picker value'),\n /** class for time picker */\n className: PropTypes.string.description('class for time picker'),\n /** style object */\n style: PropTypes.object.description('style object'),\n /** z index for menu */\n zIndex: PropTypes.number.description('z index for menu'),\n /** DSPopper placement */\n placement: PropTypes.string.description('DSPopper placement'),\n /** disabled time */\n disabledTimes: PropTypes.object.description('disabled time'),\n /** steps for the picker */\n minutesInterval: PropTypes.number.description('steps for the picker'),\n};\n\nDSTimePicker.propTypes = props;\nDSTimePicker.displayName = 'DSTimePicker';\nconst DSTimePickerWithSchema = describe(DSTimePicker);\nDSTimePickerWithSchema.propTypes = props;\n\nexport { DSTimePicker, DSTimePickerWithSchema };\nexport default DSTimePicker;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACyBrB;AAxBF,SAAS,WAAW,gBAAgB;AACpC,OAAO,YAAY;AACnB,OAAO,oBAAoB;AAE3B,MAAM,eAAe,CAAC;AAAA,EACpB,iBAAiB,CAAC;AAAA,EAClB;AAAA,EACA,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,QAAQ;AAAA,EACR;AAAA,EACA,QAAQ,CAAC;AAAA,EACT,WAAW,MAAM;AAAA,EACjB,SAAS,MAAM;AAAA,EACf,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,SAAS;AAAA,EACT,YAAY;AAAA,EACZ;AAAA,EACA,kBAAkB;AACpB,MACE;AAAA,EAAC;AAAA;AAAA,IACC,KAAK;AAAA,IACL,cAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AACF;AAGF,aAAa,eAAe;AAAA,EAC1B,QAAQ;AACV;AAEA,MAAM,QAAQ;AAAA;AAAA,EAEZ,cAAc,UAAU,OAAO,YAAY,YAAY;AAAA;AAAA,EAEvD,gBAAgB,UAAU,OAAO,YAAY,qCAAqC;AAAA;AAAA,EAElF,UAAU,UAAU,KAAK,YAAY,4CAA4C;AAAA;AAAA,EAEjF,OAAO,UAAU,WAAW,MAAM,EAAE,YAAY,mBAAmB;AAAA;AAAA,EAEnE,QAAQ,UAAU,OAAO,YAAY,+BAA+B;AAAA;AAAA,EAEpE,WAAW,UAAU,KAAK,YAAY,qBAAqB;AAAA;AAAA,EAE3D,kBAAkB,UAAU,KAAK,YAAY,uBAAuB;AAAA;AAAA,EAEpE,UAAU,UAAU,KAAK,YAAY,wCAAwC;AAAA;AAAA,EAE7E,QAAQ,UAAU,KAAK,YAAY,yCAAyC;AAAA;AAAA,EAE5E,QAAQ,UAAU,KAAK,YAAY,+CAA+C;AAAA;AAAA,EAElF,UAAU,UAAU,KAAK,YAAY,2BAA2B;AAAA;AAAA,EAEhE,WAAW,UAAU,KAAK,YAAY,uCAAuC;AAAA;AAAA,EAE7E,WAAW,UAAU,OAAO,YAAY,uBAAuB;AAAA;AAAA,EAE/D,OAAO,UAAU,OAAO,YAAY,cAAc;AAAA;AAAA,EAElD,QAAQ,UAAU,OAAO,YAAY,kBAAkB;AAAA;AAAA,EAEvD,WAAW,UAAU,OAAO,YAAY,oBAAoB;AAAA;AAAA,EAE5D,eAAe,UAAU,OAAO,YAAY,eAAe;AAAA;AAAA,EAE3D,iBAAiB,UAAU,OAAO,YAAY,sBAAsB;AACtE;AAEA,aAAa,YAAY;AACzB,aAAa,cAAc;AAC3B,MAAM,yBAAyB,SAAS,YAAY;AACpD,uBAAuB,YAAY;AAGnC,IAAO,uBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { styled } from "@elliemae/ds-legacy-system";
|
|
4
|
+
import TimePickerMenu from "./TimePickerMenu.js";
|
|
5
|
+
const DSTimePickerMenuWrapper = styled.div`
|
|
6
|
+
display: flex;
|
|
7
|
+
height: 18.6rem;
|
|
8
|
+
`;
|
|
9
|
+
const DSTimePickerMenu = (props) => /* @__PURE__ */ jsx(DSTimePickerMenuWrapper, { children: /* @__PURE__ */ jsx(TimePickerMenu, { ...props }) });
|
|
10
|
+
var DSTimePickerMenu_default = DSTimePickerMenu;
|
|
11
|
+
export {
|
|
12
|
+
DSTimePickerMenu,
|
|
13
|
+
DSTimePickerMenu_default as default
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=DSTimePickerMenu.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSTimePickerMenu.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { styled } from '@elliemae/ds-legacy-system';\nimport TimePickerMenu from './TimePickerMenu.js';\n\nconst DSTimePickerMenuWrapper = styled.div`\n display: flex;\n height: 18.6rem;\n`;\nconst DSTimePickerMenu = (props) => (\n <DSTimePickerMenuWrapper>\n <TimePickerMenu {...props} />\n </DSTimePickerMenuWrapper>\n);\nexport { DSTimePickerMenu };\nexport default DSTimePickerMenu;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACUnB;AATJ,SAAS,cAAc;AACvB,OAAO,oBAAoB;AAE3B,MAAM,0BAA0B,OAAO;AAAA;AAAA;AAAA;AAIvC,MAAM,mBAAmB,CAAC,UACxB,oBAAC,2BACC,8BAAC,kBAAgB,GAAG,OAAO,GAC7B;AAGF,IAAO,2BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React2, { Component } from "react";
|
|
4
|
+
import { findIndex } from "lodash";
|
|
5
|
+
import { aggregatedClasses } from "@elliemae/ds-legacy-classnames";
|
|
6
|
+
import memoizeOne from "memoize-one";
|
|
7
|
+
import { ChevronSmallUp, ChevronSmallDown } from "@elliemae/ds-legacy-icons";
|
|
8
|
+
import { DSButton } from "@elliemae/ds-legacy-button";
|
|
9
|
+
import { MoveElementOnScroll } from "./moveElementOnScroll.js";
|
|
10
|
+
import { validateIndex } from "./utils.js";
|
|
11
|
+
const blockName = "time-picker-panel";
|
|
12
|
+
const Container = aggregatedClasses("div")(blockName, null, ({ scrolling }) => ({ scrolling }));
|
|
13
|
+
const Wrapper = aggregatedClasses("div")(blockName, "wrapper");
|
|
14
|
+
const PickerItemListContainer = aggregatedClasses("div")(blockName, "item-list-container");
|
|
15
|
+
const PickerItemList = aggregatedClasses("div")(blockName, "item-list");
|
|
16
|
+
const PickerHeader = aggregatedClasses("div")(blockName, "header");
|
|
17
|
+
const PickerItemContainer = aggregatedClasses("div")(blockName, "item", ({ selected, disabled }) => ({
|
|
18
|
+
selected,
|
|
19
|
+
disabled
|
|
20
|
+
}));
|
|
21
|
+
const PickerSelectedOptionSelected = aggregatedClasses("div")(blockName, "selected-container");
|
|
22
|
+
const SelectedCircle = aggregatedClasses("div")(blockName, "selected-circle");
|
|
23
|
+
const ArrowButtonContainer = aggregatedClasses("div")(blockName, "arrow-container");
|
|
24
|
+
const getOptionIndex = (options, selectedOption, valueProperty = "value") => {
|
|
25
|
+
const index = options.findIndex((option) => option[valueProperty] === selectedOption);
|
|
26
|
+
return validateIndex(index, options);
|
|
27
|
+
};
|
|
28
|
+
const arrowProps = {
|
|
29
|
+
buttonType: "text",
|
|
30
|
+
fluidHeight: true,
|
|
31
|
+
fluidWidth: true,
|
|
32
|
+
size: "s"
|
|
33
|
+
};
|
|
34
|
+
class PickerPanel extends Component {
|
|
35
|
+
constructor(props) {
|
|
36
|
+
super(props);
|
|
37
|
+
this.computeContainerTranslation = memoizeOne((index) => {
|
|
38
|
+
const { options, valueProperty } = this.props;
|
|
39
|
+
const { selectedOption, scrolling } = this.state;
|
|
40
|
+
const selectedOptionIndex = index || getOptionIndex(options, selectedOption, valueProperty);
|
|
41
|
+
const listYPosition = this.minYListPosition - selectedOptionIndex * this.optionHeight;
|
|
42
|
+
if (this.scrollHandler && !scrolling)
|
|
43
|
+
this.scrollHandler.updatePosition(listYPosition);
|
|
44
|
+
return listYPosition;
|
|
45
|
+
});
|
|
46
|
+
this.pickerListContainerRef = React2.createRef();
|
|
47
|
+
this.pickerListRef = React2.createRef();
|
|
48
|
+
this.pickerItemRef = React2.createRef();
|
|
49
|
+
this.selectedOptionRef = React2.createRef();
|
|
50
|
+
this.state = {
|
|
51
|
+
selectedOption: props.selected,
|
|
52
|
+
activeIndex: 0,
|
|
53
|
+
// eslint-disable-next-line react/no-unused-state
|
|
54
|
+
prevProps: {}
|
|
55
|
+
};
|
|
56
|
+
this.getOptionValue = this.getOptionValue.bind(this);
|
|
57
|
+
this.getOptionLabel = this.getOptionLabel.bind(this);
|
|
58
|
+
this.computeSizes = this.computeSizes.bind(this);
|
|
59
|
+
this.handleOptionSelect = this.handleOptionSelect.bind(this);
|
|
60
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
61
|
+
this.moveTo = this.moveTo.bind(this);
|
|
62
|
+
this.handleStepMoveUp = this.handleStepMoveUp.bind(this);
|
|
63
|
+
this.handleStepMoveDown = this.handleStepMoveDown.bind(this);
|
|
64
|
+
this.renderHeader = this.renderHeader.bind(this);
|
|
65
|
+
}
|
|
66
|
+
componentDidMount() {
|
|
67
|
+
this.computeSizes();
|
|
68
|
+
const pickerListContainerEl = this.pickerListContainerRef.current;
|
|
69
|
+
const pickerListEl = this.pickerListRef.current;
|
|
70
|
+
this.scrollHandler = new MoveElementOnScroll(pickerListEl, {
|
|
71
|
+
container: pickerListContainerEl,
|
|
72
|
+
min: -this.minYListPosition,
|
|
73
|
+
max: this.maxYListPosition,
|
|
74
|
+
onUpdate: (pos, delta) => {
|
|
75
|
+
const { options } = this.props;
|
|
76
|
+
const index = options.length - -Math.floor((pos - this.maxYListPosition) / this.optionHeight) + (delta > 0 ? 1 : -1);
|
|
77
|
+
this.moveTo(index, true);
|
|
78
|
+
},
|
|
79
|
+
onEndScroll: () => {
|
|
80
|
+
this.setState({ scrolling: false });
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
this.computeContainerTranslation();
|
|
84
|
+
}
|
|
85
|
+
componentWillUnmount() {
|
|
86
|
+
this.scrollHandler.unsubscribe();
|
|
87
|
+
}
|
|
88
|
+
static getDerivedStateFromProps(nextProps, { prevProps }) {
|
|
89
|
+
const { selected, valueProperty, options } = nextProps;
|
|
90
|
+
if (selected !== prevProps.selected) {
|
|
91
|
+
return {
|
|
92
|
+
selectedOption: selected,
|
|
93
|
+
activeIndex: getOptionIndex(options, selected, valueProperty),
|
|
94
|
+
prevProps: nextProps
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
getOptionValue(option) {
|
|
100
|
+
const { valueProperty } = this.props;
|
|
101
|
+
return option[valueProperty];
|
|
102
|
+
}
|
|
103
|
+
getOptionLabel(option) {
|
|
104
|
+
const { labelProperty } = this.props;
|
|
105
|
+
return option[labelProperty];
|
|
106
|
+
}
|
|
107
|
+
computeSizes() {
|
|
108
|
+
const { options, numberItemsOnScreen } = this.props;
|
|
109
|
+
const { offsetHeight: optionHeight } = this.pickerItemRef.current;
|
|
110
|
+
this.optionHeight = optionHeight;
|
|
111
|
+
this.listHeight = this.optionHeight * numberItemsOnScreen;
|
|
112
|
+
this.minYListPosition = this.listHeight / 2 - this.optionHeight / 2;
|
|
113
|
+
this.maxYListPosition = this.optionHeight * (options.length - Math.ceil(numberItemsOnScreen / 2));
|
|
114
|
+
}
|
|
115
|
+
handleOptionSelect(optionValue, index, scrolling) {
|
|
116
|
+
const { onChange } = this.props;
|
|
117
|
+
this.setState(
|
|
118
|
+
(state) => ({
|
|
119
|
+
...state,
|
|
120
|
+
scrolling,
|
|
121
|
+
selectedOption: optionValue,
|
|
122
|
+
activeIndex: index
|
|
123
|
+
}),
|
|
124
|
+
() => {
|
|
125
|
+
onChange(optionValue, index);
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
// TODO: this needs a refactor from de FocusGroup
|
|
130
|
+
// eslint-disable-next-line max-statements
|
|
131
|
+
handleKeyDown(e) {
|
|
132
|
+
const { activeIndex } = this.state;
|
|
133
|
+
const { options } = this.props;
|
|
134
|
+
const [firstColumn, ...restColumns] = document.getElementsByClassName("em-ds-time-picker-panel");
|
|
135
|
+
const [lastColumn] = restColumns.slice(-1);
|
|
136
|
+
const [prev] = document.getElementsByClassName("DayPickerNavigation_button");
|
|
137
|
+
const focusedElement = document.activeElement;
|
|
138
|
+
switch (e.key) {
|
|
139
|
+
case "Home":
|
|
140
|
+
this.moveTo(0);
|
|
141
|
+
break;
|
|
142
|
+
case "End":
|
|
143
|
+
this.moveTo(options.length - 1);
|
|
144
|
+
break;
|
|
145
|
+
case "ArrowUp":
|
|
146
|
+
this.moveTo(activeIndex - 1);
|
|
147
|
+
break;
|
|
148
|
+
case "ArrowDown":
|
|
149
|
+
this.moveTo(activeIndex + 1);
|
|
150
|
+
break;
|
|
151
|
+
case "Tab": {
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
if (prev && focusedElement === lastColumn) {
|
|
154
|
+
prev.focus();
|
|
155
|
+
} else if (focusedElement === lastColumn) {
|
|
156
|
+
firstColumn.focus();
|
|
157
|
+
} else {
|
|
158
|
+
const position = findIndex(restColumns, focusedElement);
|
|
159
|
+
restColumns[position + 1].focus();
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
default:
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
moveTo(index, scrolling) {
|
|
168
|
+
const { options } = this.props;
|
|
169
|
+
const { selectedOption } = this.state;
|
|
170
|
+
const validIndex = validateIndex(index, options);
|
|
171
|
+
const option = options[validIndex];
|
|
172
|
+
const optionValue = this.getOptionValue(option);
|
|
173
|
+
if (selectedOption !== optionValue && option.disabled !== true) {
|
|
174
|
+
this.handleOptionSelect(optionValue, validIndex, scrolling);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
handleStepMoveUp() {
|
|
178
|
+
const { activeIndex } = this.state;
|
|
179
|
+
const { arrowStep, options } = this.props;
|
|
180
|
+
const supposedPos = activeIndex - arrowStep;
|
|
181
|
+
const nextPos = supposedPos >= 0 ? supposedPos : activeIndex - 1;
|
|
182
|
+
const nextValidOption = options.find((op) => !op.disabled);
|
|
183
|
+
this.moveTo(nextPos, true, nextValidOption);
|
|
184
|
+
}
|
|
185
|
+
handleStepMoveDown() {
|
|
186
|
+
const { activeIndex } = this.state;
|
|
187
|
+
const { arrowStep, options } = this.props;
|
|
188
|
+
const supposedPos = activeIndex + arrowStep;
|
|
189
|
+
const nextPos = supposedPos <= options.length ? supposedPos : activeIndex + 1;
|
|
190
|
+
this.moveTo(nextPos);
|
|
191
|
+
}
|
|
192
|
+
renderHeader() {
|
|
193
|
+
const { header } = this.props;
|
|
194
|
+
return /* @__PURE__ */ jsx(PickerHeader, { children: header });
|
|
195
|
+
}
|
|
196
|
+
render() {
|
|
197
|
+
const { options, hasHeader, type, time, meridiem, disabledTimes } = this.props;
|
|
198
|
+
const { selectedOption, activeIndex, scrolling } = this.state;
|
|
199
|
+
const listYPosition = this.computeContainerTranslation(activeIndex);
|
|
200
|
+
return /* @__PURE__ */ jsxs(Wrapper, { children: [
|
|
201
|
+
hasHeader && this.renderHeader(),
|
|
202
|
+
/* @__PURE__ */ jsxs(Container, { classProps: { scrolling }, onKeyDown: this.handleKeyDown, tabIndex: 0, children: [
|
|
203
|
+
/* @__PURE__ */ jsx(PickerSelectedOptionSelected, { innerRef: this.selectedOptionRef, children: /* @__PURE__ */ jsx(SelectedCircle, {}) }),
|
|
204
|
+
/* @__PURE__ */ jsx(ArrowButtonContainer, { children: /* @__PURE__ */ jsx(
|
|
205
|
+
DSButton,
|
|
206
|
+
{
|
|
207
|
+
...arrowProps,
|
|
208
|
+
"aria-label": "Chevron Up",
|
|
209
|
+
"data-testid": `${type}-chevron-up`,
|
|
210
|
+
disabled: activeIndex <= 0,
|
|
211
|
+
icon: /* @__PURE__ */ jsx(ChevronSmallUp, {}),
|
|
212
|
+
onClick: this.handleStepMoveUp,
|
|
213
|
+
tabIndex: -1
|
|
214
|
+
}
|
|
215
|
+
) }),
|
|
216
|
+
/* @__PURE__ */ jsx(
|
|
217
|
+
PickerItemListContainer,
|
|
218
|
+
{
|
|
219
|
+
innerRef: this.pickerListContainerRef,
|
|
220
|
+
style: {
|
|
221
|
+
height: this.listHeight
|
|
222
|
+
},
|
|
223
|
+
children: /* @__PURE__ */ jsx(
|
|
224
|
+
PickerItemList,
|
|
225
|
+
{
|
|
226
|
+
"data-testid": `${type}-list`,
|
|
227
|
+
innerRef: this.pickerListRef,
|
|
228
|
+
style: {
|
|
229
|
+
transform: `translateY(${listYPosition}px)`
|
|
230
|
+
},
|
|
231
|
+
children: options.map((option, index) => {
|
|
232
|
+
const value = this.getOptionValue(option);
|
|
233
|
+
const label = this.getOptionLabel(option);
|
|
234
|
+
let valueFormatted;
|
|
235
|
+
if (meridiem === "AM")
|
|
236
|
+
valueFormatted = value;
|
|
237
|
+
else if (meridiem === "PM" && value === 12)
|
|
238
|
+
valueFormatted = value;
|
|
239
|
+
else if (meridiem === "PM")
|
|
240
|
+
valueFormatted = value + 12;
|
|
241
|
+
let disabled = false;
|
|
242
|
+
if (disabledTimes) {
|
|
243
|
+
const { from, to } = disabledTimes;
|
|
244
|
+
if (type === "hour" && valueFormatted >= from?.hour && valueFormatted < to?.hour || type === "minutes" && value >= from?.min && value < to?.min) {
|
|
245
|
+
disabled = true;
|
|
246
|
+
}
|
|
247
|
+
if (type === "minutes" && (time?.hour() > to?.hour || time?.hour() < from?.hour)) {
|
|
248
|
+
disabled = false;
|
|
249
|
+
}
|
|
250
|
+
if (label === "am" && from?.hour == 0 && to?.hour >= 12) {
|
|
251
|
+
disabled = true;
|
|
252
|
+
}
|
|
253
|
+
if (label === "pm" && to?.hour == 24) {
|
|
254
|
+
disabled = true;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
option.disabled = disabled;
|
|
258
|
+
return /* @__PURE__ */ jsx(
|
|
259
|
+
PickerItemContainer,
|
|
260
|
+
{
|
|
261
|
+
classProps: {
|
|
262
|
+
selected: selectedOption ? value === selectedOption : index === 0,
|
|
263
|
+
disabled
|
|
264
|
+
},
|
|
265
|
+
innerRef: this.pickerItemRef,
|
|
266
|
+
onClick: () => {
|
|
267
|
+
if (!disabled)
|
|
268
|
+
this.handleOptionSelect(value, index);
|
|
269
|
+
},
|
|
270
|
+
children: label
|
|
271
|
+
},
|
|
272
|
+
value
|
|
273
|
+
);
|
|
274
|
+
})
|
|
275
|
+
}
|
|
276
|
+
)
|
|
277
|
+
}
|
|
278
|
+
),
|
|
279
|
+
/* @__PURE__ */ jsx(ArrowButtonContainer, { children: /* @__PURE__ */ jsx(
|
|
280
|
+
DSButton,
|
|
281
|
+
{
|
|
282
|
+
...arrowProps,
|
|
283
|
+
"aria-label": "Chevron Down",
|
|
284
|
+
"data-testid": `${type}-chevron-down`,
|
|
285
|
+
disabled: activeIndex >= options.length - 1,
|
|
286
|
+
icon: /* @__PURE__ */ jsx(ChevronSmallDown, {}),
|
|
287
|
+
onClick: this.handleStepMoveDown,
|
|
288
|
+
tabIndex: -1
|
|
289
|
+
}
|
|
290
|
+
) })
|
|
291
|
+
] })
|
|
292
|
+
] });
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
PickerPanel.defaultProps = {
|
|
296
|
+
valueProperty: "value",
|
|
297
|
+
labelProperty: "label",
|
|
298
|
+
numberItemsOnScreen: 5,
|
|
299
|
+
// this number should be impair
|
|
300
|
+
options: [],
|
|
301
|
+
arrowStep: 1
|
|
302
|
+
};
|
|
303
|
+
export {
|
|
304
|
+
PickerPanel,
|
|
305
|
+
PickerPanel as default
|
|
306
|
+
};
|
|
307
|
+
//# sourceMappingURL=PickerPanel.js.map
|