@bbl-digital/snorre 3.1.1 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +557 -574
- package/esm/core/Autocomplete/index.d.js +1 -0
- package/esm/core/BoxedTable/DraggableRow/index.js +3 -1
- package/esm/core/DatepickerRange/YearMonthForm.js +56 -0
- package/esm/core/Text/index.js +1 -11
- package/esm/core/Timepicker/index.js +3 -10
- package/esm/utils/time.js +0 -3
- package/lib/core/Autocomplete/index.d.js +1 -0
- package/lib/core/BoxedTable/DraggableRow/index.d.ts +2 -0
- package/lib/core/BoxedTable/DraggableRow/index.d.ts.map +1 -1
- package/lib/core/BoxedTable/DraggableRow/index.js +3 -1
- package/lib/core/DatepickerRange/YearMonthForm.d.ts +10 -0
- package/lib/core/DatepickerRange/YearMonthForm.d.ts.map +1 -0
- package/lib/core/DatepickerRange/YearMonthForm.js +56 -0
- package/lib/core/Text/index.d.ts +0 -1
- package/lib/core/Text/index.d.ts.map +1 -1
- package/lib/core/Text/index.js +1 -11
- package/lib/core/Timepicker/index.d.ts.map +1 -1
- package/lib/core/Timepicker/index.js +3 -10
- package/lib/utils/time.d.ts.map +1 -1
- package/lib/utils/time.js +0 -3
- package/package.json +1 -1
- package/esm/enums/ModifierKey.js +0 -13
- package/lib/enums/ModifierKey.d.ts +0 -12
- package/lib/enums/ModifierKey.d.ts.map +0 -1
- package/lib/enums/ModifierKey.js +0 -13
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -9,10 +9,12 @@ const DraggableRow = ({
|
|
9
9
|
id,
|
10
10
|
index,
|
11
11
|
children,
|
12
|
-
subContent
|
12
|
+
subContent,
|
13
|
+
disableDrag
|
13
14
|
}) => /*#__PURE__*/_jsx(Draggable, {
|
14
15
|
draggableId: id,
|
15
16
|
index: index,
|
17
|
+
isDragDisabled: disableDrag,
|
16
18
|
children: provided => /*#__PURE__*/_jsxs(DraggableWrapper, {
|
17
19
|
className: "table-dragable",
|
18
20
|
ref: provided.innerRef,
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { MONTHS } from '../../utils/dates';
|
3
|
+
import { StyledSelect, Div } from './styles';
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
6
|
+
|
7
|
+
const YearMonthForm = ({
|
8
|
+
onChange,
|
9
|
+
date,
|
10
|
+
fromDate,
|
11
|
+
toDate
|
12
|
+
}) => {
|
13
|
+
const months = MONTHS;
|
14
|
+
const years = [];
|
15
|
+
|
16
|
+
for (let i = fromDate.getFullYear(); i <= toDate.getFullYear(); i += 1) {
|
17
|
+
years.push(i);
|
18
|
+
}
|
19
|
+
|
20
|
+
const changeMonth = e => {
|
21
|
+
let newDate = date;
|
22
|
+
newDate.setMonth(e.target.value);
|
23
|
+
if (newDate > toDate) newDate = toDate;
|
24
|
+
onChange(newDate);
|
25
|
+
};
|
26
|
+
|
27
|
+
const changeYear = e => {
|
28
|
+
let newDate = date;
|
29
|
+
newDate.setFullYear(e.target.value);
|
30
|
+
if (newDate > toDate) newDate = toDate;
|
31
|
+
onChange(newDate);
|
32
|
+
};
|
33
|
+
|
34
|
+
return /*#__PURE__*/_jsxs(Div, {
|
35
|
+
className: "DayPicker-Caption",
|
36
|
+
children: [/*#__PURE__*/_jsx(StyledSelect, {
|
37
|
+
name: "month",
|
38
|
+
onChange: changeMonth,
|
39
|
+
value: date.getMonth(),
|
40
|
+
children: months.map((month, i) => /*#__PURE__*/_jsx("option", {
|
41
|
+
value: i,
|
42
|
+
children: month
|
43
|
+
}, month))
|
44
|
+
}), /*#__PURE__*/_jsx(StyledSelect, {
|
45
|
+
name: "year",
|
46
|
+
onChange: changeYear,
|
47
|
+
value: date.getFullYear(),
|
48
|
+
children: years.map(year => /*#__PURE__*/_jsx("option", {
|
49
|
+
value: year,
|
50
|
+
children: year
|
51
|
+
}, year))
|
52
|
+
})]
|
53
|
+
});
|
54
|
+
};
|
55
|
+
|
56
|
+
export default YearMonthForm;
|
package/esm/core/Text/index.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
2
|
-
import React
|
3
|
-
import Timepicker from '../Timepicker';
|
2
|
+
import React from 'react';
|
4
3
|
import { styles } from './styles';
|
5
4
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
6
5
|
|
@@ -16,7 +15,6 @@ const Text = ({
|
|
16
15
|
size,
|
17
16
|
title,
|
18
17
|
onClick,
|
19
|
-
test,
|
20
18
|
children,
|
21
19
|
primary,
|
22
20
|
secondary,
|
@@ -27,14 +25,6 @@ const Text = ({
|
|
27
25
|
whiteSpace
|
28
26
|
}) => {
|
29
27
|
const Tag = paragraph ? 'p' : 'span';
|
30
|
-
const [testvalue, setTestvalue] = useState(null);
|
31
|
-
if (test) return _jsx(Timepicker, {
|
32
|
-
type: "date",
|
33
|
-
isNullable: true,
|
34
|
-
value: testvalue,
|
35
|
-
onChange: e => setTestvalue(new Date(e)),
|
36
|
-
label: "Time"
|
37
|
-
});
|
38
28
|
return _jsx(Tag, {
|
39
29
|
css: theme => [styles.default(theme, color), intro && styles.intro, small && styles.small, extrasmall && styles.extrasmall, bold && styles.bold, semibold && styles.semiBold, subtle && styles.subtle(theme), paragraph && styles.paragraph, size && styles.size(size), primary && styles.setColor(theme.primary), secondary && styles.setColor(theme.secondary), italic && styles.italic, align && styles.align(align), dark && styles.setColor(theme.secondaryDarkText), wordBreak && styles.setWordBreak(wordBreak), whiteSpace && styles.setWhiteSpace(whiteSpace)],
|
40
30
|
onClick: onClick,
|
@@ -39,9 +39,7 @@ const TimePicker = ({
|
|
39
39
|
const removedNumberReplacer = isNullable ? '-' : '0';
|
40
40
|
let valueToUse = isNullable && !value ? _defaultNullableValue : _isDate ? handleDateToStringConvertion(value, showSeconds) : value;
|
41
41
|
const [validatedTime] = validateTimeAndCursor(showSeconds, valueToUse, _defaultValue, _divider, undefined, isNullable);
|
42
|
-
const [inputStateValue, setInputStateValue] = useState(validatedTime); //
|
43
|
-
|
44
|
-
console.log(inputStateValue); // Loads of logic to handle string input with divider
|
42
|
+
const [inputStateValue, setInputStateValue] = useState(validatedTime); // Loads of logic to handle string input with divider
|
45
43
|
|
46
44
|
const onInputChange = async (event, callback) => {
|
47
45
|
const _maxLength = _defaultValue.length;
|
@@ -94,21 +92,16 @@ const TimePicker = ({
|
|
94
92
|
updatedValue = inputStateValue;
|
95
93
|
currentPosition = position - 1;
|
96
94
|
} else if (removedCharacter !== null) {
|
97
|
-
console.log('on remove', position);
|
98
|
-
|
99
95
|
if ((position === 2 || position === 5) && removedCharacter === _divider) {
|
100
96
|
updatedValue = `${inputValue.substring(0, position - 1)}${removedNumberReplacer}${_divider}${inputValue.substring(position)}`;
|
101
97
|
currentPosition = position - 1;
|
102
98
|
} else {
|
103
|
-
|
104
|
-
|
99
|
+
// user removed a number
|
105
100
|
updatedValue = `${inputValue.substring(0, position)}${removedNumberReplacer}${inputValue.substring(position)}`;
|
106
101
|
}
|
107
102
|
}
|
108
103
|
|
109
|
-
|
110
|
-
const [validatedTime, validatedCursorPosition] = validateTimeAndCursor(showSeconds, updatedValue, inputStateValue, _divider, currentPosition, isNullable);
|
111
|
-
console.log(validatedTime, validatedCursorPosition); // Needs to be awaited, for it to work
|
104
|
+
const [validatedTime, validatedCursorPosition] = validateTimeAndCursor(showSeconds, updatedValue, inputStateValue, _divider, currentPosition, isNullable); // Needs to be awaited, for it to work
|
112
105
|
|
113
106
|
await setInputStateValue(validatedTime);
|
114
107
|
event.target.selectionStart = validatedCursorPosition;
|
package/esm/utils/time.js
CHANGED
@@ -24,9 +24,6 @@ export function isNumber(value) {
|
|
24
24
|
*/
|
25
25
|
|
26
26
|
export const validateTimeAndCursor = (showSeconds = false, value = '', defaultValue = '', divider = DEFAULT_DIVIDER, cursorPosition = 0, isNullable = false) => {
|
27
|
-
console.log('defaultValue', defaultValue);
|
28
|
-
console.log('value', value); // const _default = defaultValue.replaceAll('-', '0')
|
29
|
-
|
30
27
|
const [oldHH, oldMM, oldSS] = defaultValue.split(divider);
|
31
28
|
let newCursorPosition = Number(cursorPosition);
|
32
29
|
let [HH, MM, SS] = String(value).split(divider);
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -9,6 +9,8 @@ interface IProps {
|
|
9
9
|
children: React.ReactNode | React.ReactNode[];
|
10
10
|
/**Extra react components beneath row */
|
11
11
|
subContent?: React.ReactNode | React.ReactNode[];
|
12
|
+
/** Boolean to conditionally disable drag */
|
13
|
+
disableDrag?: boolean;
|
12
14
|
}
|
13
15
|
declare const DraggableRow: FC<IProps>;
|
14
16
|
export default DraggableRow;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/packages/core/BoxedTable/DraggableRow/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAW1B,UAAU,MAAM;IACd,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,eAAe;IACf,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;IAC7C,wCAAwC;IACxC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/packages/core/BoxedTable/DraggableRow/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAW1B,UAAU,MAAM;IACd,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,eAAe;IACf,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;IAC7C,wCAAwC;IACxC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;IAChD,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,MAAM,CA8B5B,CAAA;AAED,eAAe,YAAY,CAAA"}
|
@@ -9,10 +9,12 @@ const DraggableRow = ({
|
|
9
9
|
id,
|
10
10
|
index,
|
11
11
|
children,
|
12
|
-
subContent
|
12
|
+
subContent,
|
13
|
+
disableDrag
|
13
14
|
}) => /*#__PURE__*/_jsx(Draggable, {
|
14
15
|
draggableId: id,
|
15
16
|
index: index,
|
17
|
+
isDragDisabled: disableDrag,
|
16
18
|
children: provided => /*#__PURE__*/_jsxs(DraggableWrapper, {
|
17
19
|
className: "table-dragable",
|
18
20
|
ref: provided.innerRef,
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"YearMonthForm.d.ts","sourceRoot":"","sources":["../../../src/packages/core/DatepickerRange/YearMonthForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,UAAU,MAAM;IACd,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,CAAA;IAC3B,QAAQ,EAAE,IAAI,CAAA;IACd,MAAM,EAAE,IAAI,CAAA;CACb;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAmDnC,CAAA;AAED,eAAe,aAAa,CAAA"}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { MONTHS } from '../../utils/dates';
|
3
|
+
import { StyledSelect, Div } from './styles';
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
6
|
+
|
7
|
+
const YearMonthForm = ({
|
8
|
+
onChange,
|
9
|
+
date,
|
10
|
+
fromDate,
|
11
|
+
toDate
|
12
|
+
}) => {
|
13
|
+
const months = MONTHS;
|
14
|
+
const years = [];
|
15
|
+
|
16
|
+
for (let i = fromDate.getFullYear(); i <= toDate.getFullYear(); i += 1) {
|
17
|
+
years.push(i);
|
18
|
+
}
|
19
|
+
|
20
|
+
const changeMonth = e => {
|
21
|
+
let newDate = date;
|
22
|
+
newDate.setMonth(e.target.value);
|
23
|
+
if (newDate > toDate) newDate = toDate;
|
24
|
+
onChange(newDate);
|
25
|
+
};
|
26
|
+
|
27
|
+
const changeYear = e => {
|
28
|
+
let newDate = date;
|
29
|
+
newDate.setFullYear(e.target.value);
|
30
|
+
if (newDate > toDate) newDate = toDate;
|
31
|
+
onChange(newDate);
|
32
|
+
};
|
33
|
+
|
34
|
+
return /*#__PURE__*/_jsxs(Div, {
|
35
|
+
className: "DayPicker-Caption",
|
36
|
+
children: [/*#__PURE__*/_jsx(StyledSelect, {
|
37
|
+
name: "month",
|
38
|
+
onChange: changeMonth,
|
39
|
+
value: date.getMonth(),
|
40
|
+
children: months.map((month, i) => /*#__PURE__*/_jsx("option", {
|
41
|
+
value: i,
|
42
|
+
children: month
|
43
|
+
}, month))
|
44
|
+
}), /*#__PURE__*/_jsx(StyledSelect, {
|
45
|
+
name: "year",
|
46
|
+
onChange: changeYear,
|
47
|
+
value: date.getFullYear(),
|
48
|
+
children: years.map(year => /*#__PURE__*/_jsx("option", {
|
49
|
+
value: year,
|
50
|
+
children: year
|
51
|
+
}, year))
|
52
|
+
})]
|
53
|
+
});
|
54
|
+
};
|
55
|
+
|
56
|
+
export default YearMonthForm;
|
package/lib/core/Text/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Text/index.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../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,6 +1,5 @@
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
2
|
-
import React
|
3
|
-
import Timepicker from '../Timepicker';
|
2
|
+
import React from 'react';
|
4
3
|
import { styles } from './styles';
|
5
4
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
6
5
|
|
@@ -16,7 +15,6 @@ const Text = ({
|
|
16
15
|
size,
|
17
16
|
title,
|
18
17
|
onClick,
|
19
|
-
test,
|
20
18
|
children,
|
21
19
|
primary,
|
22
20
|
secondary,
|
@@ -27,14 +25,6 @@ const Text = ({
|
|
27
25
|
whiteSpace
|
28
26
|
}) => {
|
29
27
|
const Tag = paragraph ? 'p' : 'span';
|
30
|
-
const [testvalue, setTestvalue] = useState(null);
|
31
|
-
if (test) return _jsx(Timepicker, {
|
32
|
-
type: "date",
|
33
|
-
isNullable: true,
|
34
|
-
value: testvalue,
|
35
|
-
onChange: e => setTestvalue(new Date(e)),
|
36
|
-
label: "Time"
|
37
|
-
});
|
38
28
|
return _jsx(Tag, {
|
39
29
|
css: theme => [styles.default(theme, color), intro && styles.intro, small && styles.small, extrasmall && styles.extrasmall, bold && styles.bold, semibold && styles.semiBold, subtle && styles.subtle(theme), paragraph && styles.paragraph, size && styles.size(size), primary && styles.setColor(theme.primary), secondary && styles.setColor(theme.secondary), italic && styles.italic, align && styles.align(align), dark && styles.setColor(theme.secondaryDarkText), wordBreak && styles.setWordBreak(wordBreak), whiteSpace && styles.setWhiteSpace(whiteSpace)],
|
40
30
|
onClick: onClick,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Timepicker/index.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAgC,MAAM,OAAO,CAAA;AAepD,aAAK,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;AAElD,UAAU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K,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3B,6CAA6C;IAC7C,QAAQ,EAAE,YAAY,CAAA;IACtB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;IACxB,wCAAwC;IACxC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+FAA+F;IAC/F,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gBAAgB;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,qCAAqC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,+BAA+B;IAC/B,GAAG,CAAC,EAAE,gBAAgB,CAAA;IACtB,0BAA0B;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,sBAAsB;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAgNhC,CAAA;AAED,eAAe,UAAU,CAAA"}
|
@@ -39,9 +39,7 @@ const TimePicker = ({
|
|
39
39
|
const removedNumberReplacer = isNullable ? '-' : '0';
|
40
40
|
let valueToUse = isNullable && !value ? _defaultNullableValue : _isDate ? handleDateToStringConvertion(value, showSeconds) : value;
|
41
41
|
const [validatedTime] = validateTimeAndCursor(showSeconds, valueToUse, _defaultValue, _divider, undefined, isNullable);
|
42
|
-
const [inputStateValue, setInputStateValue] = useState(validatedTime); //
|
43
|
-
|
44
|
-
console.log(inputStateValue); // Loads of logic to handle string input with divider
|
42
|
+
const [inputStateValue, setInputStateValue] = useState(validatedTime); // Loads of logic to handle string input with divider
|
45
43
|
|
46
44
|
const onInputChange = async (event, callback) => {
|
47
45
|
const _maxLength = _defaultValue.length;
|
@@ -94,21 +92,16 @@ const TimePicker = ({
|
|
94
92
|
updatedValue = inputStateValue;
|
95
93
|
currentPosition = position - 1;
|
96
94
|
} else if (removedCharacter !== null) {
|
97
|
-
console.log('on remove', position);
|
98
|
-
|
99
95
|
if ((position === 2 || position === 5) && removedCharacter === _divider) {
|
100
96
|
updatedValue = `${inputValue.substring(0, position - 1)}${removedNumberReplacer}${_divider}${inputValue.substring(position)}`;
|
101
97
|
currentPosition = position - 1;
|
102
98
|
} else {
|
103
|
-
|
104
|
-
|
99
|
+
// user removed a number
|
105
100
|
updatedValue = `${inputValue.substring(0, position)}${removedNumberReplacer}${inputValue.substring(position)}`;
|
106
101
|
}
|
107
102
|
}
|
108
103
|
|
109
|
-
|
110
|
-
const [validatedTime, validatedCursorPosition] = validateTimeAndCursor(showSeconds, updatedValue, inputStateValue, _divider, currentPosition, isNullable);
|
111
|
-
console.log(validatedTime, validatedCursorPosition); // Needs to be awaited, for it to work
|
104
|
+
const [validatedTime, validatedCursorPosition] = validateTimeAndCursor(showSeconds, updatedValue, inputStateValue, _divider, currentPosition, isNullable); // Needs to be awaited, for it to work
|
112
105
|
|
113
106
|
await setInputStateValue(validatedTime);
|
114
107
|
event.target.selectionStart = validatedCursorPosition;
|
package/lib/utils/time.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/packages/utils/time.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,MAAM,CAAA;AAClC,eAAO,MAAM,mBAAmB,QAA2B,CAAA;AAC3D,eAAO,MAAM,4BAA4B,QAA2B,CAAA;AACpE,eAAO,MAAM,kBAAkB,QAA+C,CAAA;AAC9E,eAAO,MAAM,2BAA2B,QAA+C,CAAA;AASvF;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAG7C;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,qIAO/B,CAAC,MAAM,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/packages/utils/time.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,MAAM,CAAA;AAClC,eAAO,MAAM,mBAAmB,QAA2B,CAAA;AAC3D,eAAO,MAAM,4BAA4B,QAA2B,CAAA;AACpE,eAAO,MAAM,kBAAkB,QAA+C,CAAA;AAC9E,eAAO,MAAM,2BAA2B,QAA+C,CAAA;AASvF;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAG7C;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,qIAO/B,CAAC,MAAM,EAAE,MAAM,CAwCjB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,SACjC,IAAI,wCAET,MAUF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,UAChC,MAAM,sCAEZ,IASF,CAAA"}
|
package/lib/utils/time.js
CHANGED
@@ -24,9 +24,6 @@ export function isNumber(value) {
|
|
24
24
|
*/
|
25
25
|
|
26
26
|
export const validateTimeAndCursor = (showSeconds = false, value = '', defaultValue = '', divider = DEFAULT_DIVIDER, cursorPosition = 0, isNullable = false) => {
|
27
|
-
console.log('defaultValue', defaultValue);
|
28
|
-
console.log('value', value); // const _default = defaultValue.replaceAll('-', '0')
|
29
|
-
|
30
27
|
const [oldHH, oldMM, oldSS] = defaultValue.split(divider);
|
31
28
|
let newCursorPosition = Number(cursorPosition);
|
32
29
|
let [HH, MM, SS] = String(value).split(divider);
|
package/package.json
CHANGED
package/esm/enums/ModifierKey.js
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
export let ModifierKey;
|
2
|
-
|
3
|
-
(function (ModifierKey) {
|
4
|
-
ModifierKey["enter"] = "Enter";
|
5
|
-
ModifierKey["tab"] = "Tab";
|
6
|
-
ModifierKey["space"] = " ";
|
7
|
-
ModifierKey["escape"] = "Escape";
|
8
|
-
ModifierKey["shift"] = "Shift";
|
9
|
-
ModifierKey["right"] = "ArrowRight";
|
10
|
-
ModifierKey["left"] = "ArrowLeft";
|
11
|
-
ModifierKey["up"] = "ArrowUp";
|
12
|
-
ModifierKey["down"] = "ArrowDown";
|
13
|
-
})(ModifierKey || (ModifierKey = {}));
|
@@ -1,12 +0,0 @@
|
|
1
|
-
export declare enum ModifierKey {
|
2
|
-
enter = "Enter",
|
3
|
-
tab = "Tab",
|
4
|
-
space = " ",
|
5
|
-
escape = "Escape",
|
6
|
-
shift = "Shift",
|
7
|
-
right = "ArrowRight",
|
8
|
-
left = "ArrowLeft",
|
9
|
-
up = "ArrowUp",
|
10
|
-
down = "ArrowDown"
|
11
|
-
}
|
12
|
-
//# sourceMappingURL=ModifierKey.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ModifierKey.d.ts","sourceRoot":"","sources":["../../src/packages/enums/ModifierKey.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,KAAK,MAAM;IACX,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,KAAK,eAAe;IACpB,IAAI,cAAc;IAClB,EAAE,YAAY;IACd,IAAI,cAAc;CACnB"}
|
package/lib/enums/ModifierKey.js
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
export let ModifierKey;
|
2
|
-
|
3
|
-
(function (ModifierKey) {
|
4
|
-
ModifierKey["enter"] = "Enter";
|
5
|
-
ModifierKey["tab"] = "Tab";
|
6
|
-
ModifierKey["space"] = " ";
|
7
|
-
ModifierKey["escape"] = "Escape";
|
8
|
-
ModifierKey["shift"] = "Shift";
|
9
|
-
ModifierKey["right"] = "ArrowRight";
|
10
|
-
ModifierKey["left"] = "ArrowLeft";
|
11
|
-
ModifierKey["up"] = "ArrowUp";
|
12
|
-
ModifierKey["down"] = "ArrowDown";
|
13
|
-
})(ModifierKey || (ModifierKey = {}));
|