@propellerads/time-picker 2.0.4 → 3.0.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/index.d.ts +20 -4
- package/dist/index.js +60 -6
- package/dist/index.js.map +1 -0
- package/package.json +32 -27
- package/dist/allowJavaScriptModules.d.ts +0 -1
- package/dist/style.d.ts +0 -4
- package/dist/time-picker.cjs.development.js +0 -66
- package/dist/time-picker.cjs.development.js.map +0 -1
- package/dist/time-picker.cjs.production.min.js +0 -2
- package/dist/time-picker.cjs.production.min.js.map +0 -1
- package/dist/time-picker.esm.js +0 -60
- package/dist/time-picker.esm.js.map +0 -1
- package/dist/types.d.ts +0 -13
- package/src/allowJavaScriptModules.ts +0 -1
- package/src/index.tsx +0 -61
- package/src/style.tsx +0 -39
- package/src/types.ts +0 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type TimePickerProps = {
|
|
5
|
+
elementId: string;
|
|
6
|
+
onChange: (value: string) => void;
|
|
7
|
+
value: string;
|
|
8
|
+
minTime?: string;
|
|
9
|
+
maxTime?: string;
|
|
10
|
+
label?: ReactNode;
|
|
11
|
+
errors?: string[];
|
|
12
|
+
isRequired?: boolean;
|
|
13
|
+
isReadonly?: boolean;
|
|
14
|
+
showErrorLabel?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
declare const TimePicker: ({ elementId, onChange, errors, value, minTime, maxTime, label, isRequired, isReadonly, showErrorLabel, }: TimePickerProps) => react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { TimePicker as default };
|
|
20
|
+
export type { TimePickerProps };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,62 @@
|
|
|
1
|
+
import e from "@propellerads/error-label";
|
|
2
|
+
import t from "@propellerads/label";
|
|
3
|
+
import n from "styled-components";
|
|
4
|
+
import { errorColor as r, gray80 as i, gray95 as a, spacing as o } from "@propellerads/stylevariables";
|
|
5
|
+
import { inputStyles as s } from "@propellerads/theme-annotation";
|
|
6
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
7
|
+
//#region src/style.tsx
|
|
8
|
+
var d = n.div`
|
|
9
|
+
display: flex;
|
|
10
|
+
position: relative;
|
|
11
|
+
width: 82px;
|
|
12
|
+
`, f = n.input`
|
|
13
|
+
border: 1px solid ${i};
|
|
14
|
+
border-radius: 8px;
|
|
15
|
+
padding: 0 7px;
|
|
16
|
+
font-size: 14px;
|
|
17
|
+
height: 36px;
|
|
18
|
+
${s}
|
|
1
19
|
|
|
2
|
-
|
|
20
|
+
&[disabled] {
|
|
21
|
+
background-color: ${a};
|
|
22
|
+
}
|
|
3
23
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
24
|
+
${({ $hasErrors: e }) => e && `
|
|
25
|
+
border: 1px solid ${r} !important;
|
|
26
|
+
color: ${r};
|
|
27
|
+
|
|
28
|
+
&::-webkit-calendar-picker-indicator {
|
|
29
|
+
filter: invert(22%) sepia(63%) saturate(7197%) hue-rotate(353deg) brightness(106%) contrast(87%);
|
|
30
|
+
}
|
|
31
|
+
`}
|
|
32
|
+
`, p = n.div`
|
|
33
|
+
position: absolute;
|
|
34
|
+
right: 1px;
|
|
35
|
+
top: calc(50% - ${o * 2.5}px);
|
|
36
|
+
`, m = "00:00", h = "23:59", g = ({ elementId: n, onChange: r, errors: i, value: a, minTime: o = m, maxTime: s = h, label: g, isRequired: _ = !1, isReadonly: v = !1, showErrorLabel: y }) => {
|
|
37
|
+
let b = !!i?.length, x = (e) => {
|
|
38
|
+
let { value: t } = e.target;
|
|
39
|
+
r(t < o ? o : t > s ? s : t);
|
|
40
|
+
}, S = `${n}-input-time`;
|
|
41
|
+
return /* @__PURE__ */ u(c, { children: [g && /* @__PURE__ */ l(t, {
|
|
42
|
+
for: S,
|
|
43
|
+
label: g,
|
|
44
|
+
required: _
|
|
45
|
+
}), /* @__PURE__ */ u(d, { children: [/* @__PURE__ */ l(f, {
|
|
46
|
+
id: S,
|
|
47
|
+
$hasErrors: b,
|
|
48
|
+
required: _,
|
|
49
|
+
disabled: v,
|
|
50
|
+
onChange: (e) => r(e.target.value),
|
|
51
|
+
onBlur: x,
|
|
52
|
+
type: "time",
|
|
53
|
+
value: a
|
|
54
|
+
}), y && /* @__PURE__ */ l(p, { children: /* @__PURE__ */ l(e, {
|
|
55
|
+
elementId: n,
|
|
56
|
+
errors: i?.slice() ?? []
|
|
57
|
+
}) })] })] });
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { g as default };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport {spacing, errorColor, gray80, gray95} from '@propellerads/stylevariables';\nimport {inputStyles} from '@propellerads/theme-annotation';\n\ntype StyledInputTimeProps = {\n $hasErrors: boolean;\n};\n\nexport const StyledTimeContainer = styled.div`\n display: flex;\n position: relative;\n width: 82px;\n`;\n\nexport const StyledInputTime = styled.input<StyledInputTimeProps>`\n border: 1px solid ${gray80};\n border-radius: 8px;\n padding: 0 7px;\n font-size: 14px;\n height: 36px;\n ${inputStyles}\n\n &[disabled] {\n background-color: ${gray95};\n }\n\n ${({$hasErrors}) =>\n $hasErrors &&\n `\n border: 1px solid ${errorColor} !important;\n color: ${errorColor};\n\n &::-webkit-calendar-picker-indicator {\n filter: invert(22%) sepia(63%) saturate(7197%) hue-rotate(353deg) brightness(106%) contrast(87%);\n }\n `}\n`;\n\nexport const StyledTimePickerHelper = styled.div`\n position: absolute;\n right: 1px;\n top: calc(50% - ${spacing * 2.5}px);\n`;\n","import ErrorLabel from '@propellerads/error-label';\nimport Label from '@propellerads/label';\nimport type {FocusEventHandler} from 'react';\nimport {StyledInputTime, StyledTimeContainer, StyledTimePickerHelper} from './style';\nimport type {TimePickerProps} from './types';\n\nconst DEFAULT_MIN_TIME = '00:00' as const;\nconst DEFAULT_MAX_TIME = '23:59' as const;\n\nconst TimePicker = ({\n elementId,\n onChange,\n errors,\n value,\n minTime = DEFAULT_MIN_TIME,\n maxTime = DEFAULT_MAX_TIME,\n label,\n isRequired = false,\n isReadonly = false,\n showErrorLabel,\n}: TimePickerProps) => {\n const hasErrors = Boolean(errors?.length);\n\n const onBlurCorrectTime: FocusEventHandler<HTMLInputElement> = (event) => {\n const {value: nextValue} = event.target;\n const correctTime = nextValue < minTime ? minTime : nextValue > maxTime ? maxTime : nextValue;\n\n onChange(correctTime);\n };\n\n const inputTimeElementId = `${elementId}-input-time`;\n\n return (\n <>\n {label && <Label for={inputTimeElementId} label={label} required={isRequired} />}\n <StyledTimeContainer>\n <StyledInputTime\n id={inputTimeElementId}\n $hasErrors={hasErrors}\n required={isRequired}\n disabled={isReadonly}\n onChange={(e) => onChange(e.target.value)}\n onBlur={onBlurCorrectTime}\n type=\"time\"\n value={value}\n />\n {showErrorLabel && (\n <StyledTimePickerHelper>\n <ErrorLabel elementId={elementId} errors={errors?.slice() ?? []} />\n </StyledTimePickerHelper>\n )}\n </StyledTimeContainer>\n </>\n );\n};\n\nexport default TimePicker;\nexport type {TimePickerProps} from './types';\n"],"mappings":";;;;;;;AAQA,IAAa,IAAsB,EAAO,GAAG;;;;GAMhC,IAAkB,EAAO,KAA2B;sBAC3C,EAAO;;;;;IAKzB,EAAY;;;wBAGQ,EAAO;;;KAG1B,EAAC,oBACF,KACA;0BACsB,EAAW;eACtB,EAAW;;;;;MAKpB;GAGO,IAAyB,EAAO,GAAG;;;oBAG5B,IAAU,IAAI;GCnC5B,IAAmB,SACnB,IAAmB,SAEnB,KAAc,EAClB,cACA,aACA,WACA,UACA,aAAU,GACV,aAAU,GACV,UACA,gBAAa,IACb,gBAAa,IACb,wBACqB;CACrB,IAAM,IAAY,EAAQ,GAAQ,QAE5B,KAA0D,MAAU;EACxE,IAAM,EAAC,OAAO,MAAa,EAAM;EAGjC,EAFoB,IAAY,IAAU,IAAU,IAAY,IAAU,IAAU,EAE/D;IAGjB,IAAqB,GAAG,EAAU;CAExC,OACE,kBAAA,GAAA,EAAA,UAAA,CACG,KAAS,kBAAC,GAAD;EAAO,KAAK;EAA2B;EAAO,UAAU;EAAc,CAAA,EAChF,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;EACE,IAAI;EACJ,YAAY;EACZ,UAAU;EACV,UAAU;EACV,WAAW,MAAM,EAAS,EAAE,OAAO,MAAM;EACzC,QAAQ;EACR,MAAK;EACE;EACP,CAAA,EACD,KACC,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;EAAuB;EAAW,QAAQ,GAAQ,OAAO,IAAI,EAAE;EAAI,CAAA,EAC5C,CAAA,CAEP,EAAA,CAAA,CACrB,EAAA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,39 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/time-picker",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
10
12
|
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
"src"
|
|
13
|
+
"dist"
|
|
13
14
|
],
|
|
14
|
-
"
|
|
15
|
-
|
|
15
|
+
"repository": "https://github.com/propellerads/ui-components.git",
|
|
16
|
+
"author": "n.milantyeva@propellerads.net",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/propellerads/ui-components/issues"
|
|
16
20
|
},
|
|
17
21
|
"scripts": {
|
|
18
|
-
"
|
|
19
|
-
|
|
22
|
+
"build": "tsc && vite build && bunx rollup -c rollup.dts.config.mjs"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
25
|
+
"private": false,
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@propellerads/error-label": "^6.0.0",
|
|
28
|
+
"@propellerads/label": "^4.0.4",
|
|
29
|
+
"@propellerads/stylevariables": "^2.0.2",
|
|
30
|
+
"@propellerads/theme-annotation": "^2.1.1"
|
|
20
31
|
},
|
|
21
32
|
"peerDependencies": {
|
|
22
|
-
"react": "
|
|
23
|
-
"styled-components": "5.1.1"
|
|
24
|
-
"@types/styled-components": "^5.1.36"
|
|
33
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
34
|
+
"styled-components": "^5.1.1 || ^6.0.0"
|
|
25
35
|
},
|
|
26
|
-
"module": "dist/time-picker.esm.js",
|
|
27
36
|
"devDependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"@propellerads/stylevariables": "^2.0.2",
|
|
35
|
-
"@propellerads/error-label": "^5.0.2",
|
|
36
|
-
"@propellerads/label": "^4.0.4",
|
|
37
|
-
"@propellerads/theme-annotation": "1.2.1"
|
|
37
|
+
"@types/react": "^19.2.14",
|
|
38
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
39
|
+
"rollup": "^4.60.3",
|
|
40
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
41
|
+
"typescript": "^6.0.3",
|
|
42
|
+
"vite": "^8.0.10"
|
|
38
43
|
}
|
|
39
44
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare module '*';
|
package/dist/style.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { StyledComponent } from 'styled-components';
|
|
2
|
-
export declare const StyledTimeContainer: StyledComponent<"div", any, {}, never>;
|
|
3
|
-
export declare const StyledInputTime: StyledComponent<"input", any, {}, never>;
|
|
4
|
-
export declare const StyledTimePickerHelper: StyledComponent<"div", any, {}, never>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
|
-
var ErrorLabel = _interopDefault(require('@propellerads/error-label'));
|
|
8
|
-
var Label = _interopDefault(require('@propellerads/label'));
|
|
9
|
-
var React = _interopDefault(require('react'));
|
|
10
|
-
var styled = _interopDefault(require('styled-components'));
|
|
11
|
-
var stylevariables = require('@propellerads/stylevariables');
|
|
12
|
-
var themeAnnotation = require('@propellerads/theme-annotation');
|
|
13
|
-
|
|
14
|
-
function _taggedTemplateLiteralLoose(e, t) {
|
|
15
|
-
return t || (t = e.slice(0)), e.raw = t, e;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
19
|
-
var StyledTimeContainer = /*#__PURE__*/styled.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n position: relative;\n width: 82px;\n"])));
|
|
20
|
-
var StyledInputTime = /*#__PURE__*/themeAnnotation.themeAnnotation(/*#__PURE__*/styled.input(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 1px solid ", ";\n border-radius: 8px;\n padding: 0 7px;\n font-size: 14px;\n height: 36px;\n\n &[disabled] {\n background-color: ", ";\n }\n\n &[data-has-errors='true'] {\n border: 1px solid ", " !important;\n color: ", ";\n\n &::-webkit-calendar-picker-indicator {\n filter: invert(22%) sepia(63%) saturate(7197%) hue-rotate(353deg) brightness(106%) contrast(87%);\n }\n }\n "])), stylevariables.gray80, stylevariables.gray95, stylevariables.errorColor, stylevariables.errorColor), themeAnnotation.Input);
|
|
21
|
-
var StyledTimePickerHelper = /*#__PURE__*/styled.div(_templateObject3 || (_templateObject3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n right: 1px;\n top: calc(50% - ", "px);\n"])), stylevariables.spacing * 2.5);
|
|
22
|
-
|
|
23
|
-
var DEFAULT_MIN_TIME = '00:00';
|
|
24
|
-
var DEFAULT_MAX_TIME = '23:59';
|
|
25
|
-
var TimePicker = function TimePicker(_ref) {
|
|
26
|
-
var _errors$slice;
|
|
27
|
-
var elementId = _ref.elementId,
|
|
28
|
-
onChange = _ref.onChange,
|
|
29
|
-
errors = _ref.errors,
|
|
30
|
-
value = _ref.value,
|
|
31
|
-
minTime = _ref.minTime,
|
|
32
|
-
maxTime = _ref.maxTime,
|
|
33
|
-
label = _ref.label,
|
|
34
|
-
isRequired = _ref.isRequired,
|
|
35
|
-
isReadonly = _ref.isReadonly,
|
|
36
|
-
showErrorLabel = _ref.showErrorLabel;
|
|
37
|
-
var onChangeTime = function onChangeTime(event) {
|
|
38
|
-
onChange(event.target.value);
|
|
39
|
-
};
|
|
40
|
-
var onChangeCorrectTime = function onChangeCorrectTime(event) {
|
|
41
|
-
var timesArray = [minTime !== null && minTime !== void 0 ? minTime : DEFAULT_MIN_TIME, maxTime !== null && maxTime !== void 0 ? maxTime : DEFAULT_MAX_TIME, event.target.value];
|
|
42
|
-
var correctTime = timesArray.sort()[1];
|
|
43
|
-
onChange(correctTime);
|
|
44
|
-
};
|
|
45
|
-
var inputTimeElementId = elementId + "-input-time";
|
|
46
|
-
return React.createElement(React.Fragment, null, label && React.createElement(Label, {
|
|
47
|
-
"for": inputTimeElementId,
|
|
48
|
-
label: label,
|
|
49
|
-
required: isRequired
|
|
50
|
-
}), React.createElement(StyledTimeContainer, null, React.createElement(StyledInputTime, {
|
|
51
|
-
id: inputTimeElementId,
|
|
52
|
-
"data-has-errors": Boolean(errors === null || errors === void 0 ? void 0 : errors.length),
|
|
53
|
-
required: isRequired,
|
|
54
|
-
disabled: isReadonly,
|
|
55
|
-
onChange: onChangeTime,
|
|
56
|
-
onBlur: onChangeCorrectTime,
|
|
57
|
-
type: "time",
|
|
58
|
-
value: value
|
|
59
|
-
}), showErrorLabel && React.createElement(StyledTimePickerHelper, null, React.createElement(ErrorLabel, {
|
|
60
|
-
elementId: elementId,
|
|
61
|
-
errors: (_errors$slice = errors === null || errors === void 0 ? void 0 : errors.slice()) !== null && _errors$slice !== void 0 ? _errors$slice : []
|
|
62
|
-
}))));
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
exports.default = TimePicker;
|
|
66
|
-
//# sourceMappingURL=time-picker.cjs.development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"time-picker.cjs.development.js","sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled, {AnyStyledComponent, StyledComponent} from 'styled-components';\nimport {spacing, errorColor, gray80, gray95} from '@propellerads/stylevariables';\nimport {Input, themeAnnotation} from '@propellerads/theme-annotation';\n\nexport const StyledTimeContainer = styled.div`\n display: flex;\n position: relative;\n width: 82px;\n`;\n\nexport const StyledInputTime = themeAnnotation(\n styled.input`\n border: 1px solid ${gray80};\n border-radius: 8px;\n padding: 0 7px;\n font-size: 14px;\n height: 36px;\n\n &[disabled] {\n background-color: ${gray95};\n }\n\n &[data-has-errors='true'] {\n border: 1px solid ${errorColor} !important;\n color: ${errorColor};\n\n &::-webkit-calendar-picker-indicator {\n filter: invert(22%) sepia(63%) saturate(7197%) hue-rotate(353deg) brightness(106%) contrast(87%);\n }\n }\n ` as AnyStyledComponent,\n Input,\n) as StyledComponent<'input', any>;\n\nexport const StyledTimePickerHelper = styled.div`\n position: absolute;\n right: 1px;\n top: calc(50% - ${spacing * 2.5}px);\n`;\n","import ErrorLabel from '@propellerads/error-label';\n\nimport Label from '@propellerads/label';\nimport React, {ChangeEvent, FunctionComponent} from 'react';\n\nimport {StyledInputTime, StyledTimeContainer, StyledTimePickerHelper} from './style';\nimport {TimePickerProps} from './types';\n\nconst DEFAULT_MIN_TIME = '00:00';\nconst DEFAULT_MAX_TIME = '23:59';\n\nconst TimePicker: FunctionComponent<TimePickerProps> = ({\n elementId,\n onChange,\n errors,\n value,\n minTime,\n maxTime,\n label,\n isRequired,\n isReadonly,\n showErrorLabel,\n}: TimePickerProps) => {\n const onChangeTime = (event: ChangeEvent<HTMLInputElement>) => {\n onChange(event.target.value);\n };\n\n const onChangeCorrectTime = (event: ChangeEvent<HTMLInputElement>) => {\n const timesArray = [minTime ?? DEFAULT_MIN_TIME, maxTime ?? DEFAULT_MAX_TIME, event.target.value];\n const correctTime = timesArray.sort()[1];\n\n onChange(correctTime);\n };\n\n const inputTimeElementId = `${elementId}-input-time`;\n\n return (\n <>\n {label && <Label for={inputTimeElementId} label={label} required={isRequired} />}\n <StyledTimeContainer>\n <StyledInputTime\n id={inputTimeElementId}\n data-has-errors={Boolean(errors?.length)}\n required={isRequired}\n disabled={isReadonly}\n onChange={onChangeTime}\n onBlur={onChangeCorrectTime}\n type=\"time\"\n value={value}\n />\n {showErrorLabel && (\n <StyledTimePickerHelper>\n <ErrorLabel elementId={elementId} errors={errors?.slice() ?? []} />\n </StyledTimePickerHelper>\n )}\n </StyledTimeContainer>\n </>\n );\n};\n\nexport default TimePicker;\n"],"names":["StyledTimeContainer","styled","div","_templateObject","_taggedTemplateLiteralLoose","StyledInputTime","themeAnnotation","input","_templateObject2","gray80","gray95","errorColor","Input","StyledTimePickerHelper","_templateObject3","spacing","DEFAULT_MIN_TIME","DEFAULT_MAX_TIME","TimePicker","_ref","elementId","onChange","errors","value","minTime","maxTime","label","isRequired","isReadonly","showErrorLabel","onChangeTime","event","target","onChangeCorrectTime","timesArray","correctTime","sort","inputTimeElementId","React","Label","required","id","Boolean","length","disabled","onBlur","type","ErrorLabel","_errors$slice","slice"],"mappings":";;;;;;;;;;;;;;;;;;AAIO,IAAMA,mBAAmB,gBAAGC,MAAM,CAACC,GAAG,CAAAC,eAAA,KAAAA,eAAA,gBAAAC,2BAAA,mEAI5C;AAEM,IAAMC,eAAe,gBAAGC,+BAAe,cAC5CL,MAAM,CAACM,KAAK,CAAAC,gBAAA,KAAAA,gBAAA,gBAAAJ,2BAAA,wcACUK,qBAAM,EAOJC,qBAAM,EAINC,yBAAU,EACrBA,yBAAU,GAOvBC,qBAAK,CAC2B;AAE3B,IAAMC,sBAAsB,gBAAGZ,MAAM,CAACC,GAAG,CAAAY,gBAAA,KAAAA,gBAAA,gBAAAV,2BAAA,6EAG5BW,sBAAO,GAAG,GAAG,CAChC;;AC9BD,IAAMC,gBAAgB,GAAG,OAAO;AAChC,IAAMC,gBAAgB,GAAG,OAAO;AAEhC,IAAMC,UAAU,GAAuC,SAAjDA,UAAUA,CAAAC,IAAA;;MACdC,SAAS,GAAAD,IAAA,CAATC,SAAS;IACTC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,MAAM,GAAAH,IAAA,CAANG,MAAM;IACNC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IACLC,OAAO,GAAAL,IAAA,CAAPK,OAAO;IACPC,OAAO,GAAAN,IAAA,CAAPM,OAAO;IACPC,KAAK,GAAAP,IAAA,CAALO,KAAK;IACLC,UAAU,GAAAR,IAAA,CAAVQ,UAAU;IACVC,UAAU,GAAAT,IAAA,CAAVS,UAAU;IACVC,cAAc,GAAAV,IAAA,CAAdU,cAAc;EAEd,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAIC,KAAoC;IACxDV,QAAQ,CAACU,KAAK,CAACC,MAAM,CAACT,KAAK,CAAC;GAC7B;EAED,IAAMU,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIF,KAAoC;IAC/D,IAAMG,UAAU,GAAG,CAACV,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAIR,gBAAgB,EAAES,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAIR,gBAAgB,EAAEc,KAAK,CAACC,MAAM,CAACT,KAAK,CAAC;IACjG,IAAMY,WAAW,GAAGD,UAAU,CAACE,IAAI,EAAE,CAAC,CAAC,CAAC;IAExCf,QAAQ,CAACc,WAAW,CAAC;GACtB;EAED,IAAME,kBAAkB,GAAMjB,SAAS,gBAAa;EAEpD,OACEkB,0CACGZ,KAAK,IAAIY,oBAACC,KAAK;IAAC,OAAKF,kBAAkB;IAAEX,KAAK,EAAEA,KAAK;IAAEc,QAAQ,EAAEb;IAAc,EAChFW,oBAACtC,mBAAmB,QAClBsC,oBAACjC,eAAe;IACdoC,EAAE,EAAEJ,kBAAkB;uBACLK,OAAO,CAACpB,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEqB,MAAM,CAAC;IACxCH,QAAQ,EAAEb,UAAU;IACpBiB,QAAQ,EAAEhB,UAAU;IACpBP,QAAQ,EAAES,YAAY;IACtBe,MAAM,EAAEZ,mBAAmB;IAC3Ba,IAAI,EAAC,MAAM;IACXvB,KAAK,EAAEA;IACP,EACDM,cAAc,IACbS,oBAACzB,sBAAsB,QACrByB,oBAACS,UAAU;IAAC3B,SAAS,EAAEA,SAAS;IAAEE,MAAM,GAAA0B,aAAA,GAAE1B,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAE2B,KAAK,EAAE,cAAAD,aAAA,cAAAA,aAAA,GAAI;IAAM,CAEtE,CACmB,CACrB;AAEP,CAAC;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r,n,t,l=e(require("@propellerads/error-label")),a=e(require("@propellerads/label")),o=e(require("react")),i=e(require("styled-components")),u=require("@propellerads/stylevariables"),d=require("@propellerads/theme-annotation");function s(e,r){return r||(r=e.slice(0)),e.raw=r,e}var p=i.div(r||(r=s(["\n display: flex;\n position: relative;\n width: 82px;\n"]))),c=d.themeAnnotation(i.input(n||(n=s(["\n border: 1px solid ",";\n border-radius: 8px;\n padding: 0 7px;\n font-size: 14px;\n height: 36px;\n\n &[disabled] {\n background-color: ",";\n }\n\n &[data-has-errors='true'] {\n border: 1px solid "," !important;\n color: ",";\n\n &::-webkit-calendar-picker-indicator {\n filter: invert(22%) sepia(63%) saturate(7197%) hue-rotate(353deg) brightness(106%) contrast(87%);\n }\n }\n "])),u.gray80,u.gray95,u.errorColor,u.errorColor),d.Input),m=i.div(t||(t=s(["\n position: absolute;\n right: 1px;\n top: calc(50% - ","px);\n"])),2.5*u.spacing);exports.default=function(e){var r,n=e.elementId,t=e.onChange,i=e.errors,u=e.value,d=e.minTime,s=e.maxTime,b=e.label,v=e.isRequired,g=e.isReadonly,f=e.showErrorLabel,h=n+"-input-time";return o.createElement(o.Fragment,null,b&&o.createElement(a,{for:h,label:b,required:v}),o.createElement(p,null,o.createElement(c,{id:h,"data-has-errors":Boolean(null==i?void 0:i.length),required:v,disabled:g,onChange:function(e){t(e.target.value)},onBlur:function(e){var r=[null!=d?d:"00:00",null!=s?s:"23:59",e.target.value].sort()[1];t(r)},type:"time",value:u}),f&&o.createElement(m,null,o.createElement(l,{elementId:n,errors:null!==(r=null==i?void 0:i.slice())&&void 0!==r?r:[]}))))};
|
|
2
|
-
//# sourceMappingURL=time-picker.cjs.production.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"time-picker.cjs.production.min.js","sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled, {AnyStyledComponent, StyledComponent} from 'styled-components';\nimport {spacing, errorColor, gray80, gray95} from '@propellerads/stylevariables';\nimport {Input, themeAnnotation} from '@propellerads/theme-annotation';\n\nexport const StyledTimeContainer = styled.div`\n display: flex;\n position: relative;\n width: 82px;\n`;\n\nexport const StyledInputTime = themeAnnotation(\n styled.input`\n border: 1px solid ${gray80};\n border-radius: 8px;\n padding: 0 7px;\n font-size: 14px;\n height: 36px;\n\n &[disabled] {\n background-color: ${gray95};\n }\n\n &[data-has-errors='true'] {\n border: 1px solid ${errorColor} !important;\n color: ${errorColor};\n\n &::-webkit-calendar-picker-indicator {\n filter: invert(22%) sepia(63%) saturate(7197%) hue-rotate(353deg) brightness(106%) contrast(87%);\n }\n }\n ` as AnyStyledComponent,\n Input,\n) as StyledComponent<'input', any>;\n\nexport const StyledTimePickerHelper = styled.div`\n position: absolute;\n right: 1px;\n top: calc(50% - ${spacing * 2.5}px);\n`;\n","import ErrorLabel from '@propellerads/error-label';\n\nimport Label from '@propellerads/label';\nimport React, {ChangeEvent, FunctionComponent} from 'react';\n\nimport {StyledInputTime, StyledTimeContainer, StyledTimePickerHelper} from './style';\nimport {TimePickerProps} from './types';\n\nconst DEFAULT_MIN_TIME = '00:00';\nconst DEFAULT_MAX_TIME = '23:59';\n\nconst TimePicker: FunctionComponent<TimePickerProps> = ({\n elementId,\n onChange,\n errors,\n value,\n minTime,\n maxTime,\n label,\n isRequired,\n isReadonly,\n showErrorLabel,\n}: TimePickerProps) => {\n const onChangeTime = (event: ChangeEvent<HTMLInputElement>) => {\n onChange(event.target.value);\n };\n\n const onChangeCorrectTime = (event: ChangeEvent<HTMLInputElement>) => {\n const timesArray = [minTime ?? DEFAULT_MIN_TIME, maxTime ?? DEFAULT_MAX_TIME, event.target.value];\n const correctTime = timesArray.sort()[1];\n\n onChange(correctTime);\n };\n\n const inputTimeElementId = `${elementId}-input-time`;\n\n return (\n <>\n {label && <Label for={inputTimeElementId} label={label} required={isRequired} />}\n <StyledTimeContainer>\n <StyledInputTime\n id={inputTimeElementId}\n data-has-errors={Boolean(errors?.length)}\n required={isRequired}\n disabled={isReadonly}\n onChange={onChangeTime}\n onBlur={onChangeCorrectTime}\n type=\"time\"\n value={value}\n />\n {showErrorLabel && (\n <StyledTimePickerHelper>\n <ErrorLabel elementId={elementId} errors={errors?.slice() ?? []} />\n </StyledTimePickerHelper>\n )}\n </StyledTimeContainer>\n </>\n );\n};\n\nexport default TimePicker;\n"],"names":["StyledTimeContainer","styled","div","_templateObject","_taggedTemplateLiteralLoose","StyledInputTime","themeAnnotation","input","_templateObject2","gray80","gray95","errorColor","Input","StyledTimePickerHelper","_templateObject3","spacing","_ref","elementId","onChange","errors","value","minTime","maxTime","label","isRequired","isReadonly","showErrorLabel","inputTimeElementId","React","Label","for","required","id","Boolean","length","disabled","event","target","onBlur","correctTime","sort","type","ErrorLabel","_errors$slice","slice"],"mappings":"maAIO,IAAMA,EAAsBC,EAAOC,IAAGC,IAAAA,EAAAC,qEAMhCC,EAAkBC,kBAC7BL,EAAOM,MAAKC,IAAAA,EAAAJ,ocACUK,SAOEC,SAIAC,aACXA,cAObC,SAGWC,EAAyBZ,EAAOC,IAAGY,IAAAA,EAAAV,4EAGlB,IAAVW,2BC1BmC,SAAvCC,SACdC,EAASD,EAATC,UACAC,EAAQF,EAARE,SACAC,EAAMH,EAANG,OACAC,EAAKJ,EAALI,MACAC,EAAOL,EAAPK,QACAC,EAAON,EAAPM,QACAC,EAAKP,EAALO,MACAC,EAAUR,EAAVQ,WACAC,EAAUT,EAAVS,WACAC,EAAcV,EAAdU,eAaMC,EAAwBV,gBAE9B,OACEW,gCACGL,GAASK,gBAACC,GAAMC,IAAKH,EAAoBJ,MAAOA,EAAOQ,SAAUP,IAClEI,gBAAC5B,OACC4B,gBAACvB,GACC2B,GAAIL,oBACaM,QAAQd,MAAAA,SAAAA,EAAQe,QACjCH,SAAUP,EACVW,SAAUV,EACVP,SAtBa,SAACkB,GACpBlB,EAASkB,EAAMC,OAAOjB,QAsBhBkB,OAnBoB,SAACF,GAC3B,IACMG,EADa,CAAClB,MAAAA,EAAAA,EApBC,QAoB4BC,MAAAA,EAAAA,EAnB5B,QAmByDc,EAAMC,OAAOjB,OAC5DoB,OAAO,GAEtCtB,EAASqB,IAgBHE,KAAK,OACLrB,MAAOA,IAERM,GACCE,gBAACf,OACCe,gBAACc,GAAWzB,UAAWA,EAAWE,eAAMwB,EAAExB,MAAAA,SAAAA,EAAQyB,mBAAOD,EAAAA,EAAI"}
|
package/dist/time-picker.esm.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import ErrorLabel from '@propellerads/error-label';
|
|
2
|
-
import Label from '@propellerads/label';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import styled from 'styled-components';
|
|
5
|
-
import { gray80, gray95, errorColor, spacing } from '@propellerads/stylevariables';
|
|
6
|
-
import { themeAnnotation, Input } from '@propellerads/theme-annotation';
|
|
7
|
-
|
|
8
|
-
function _taggedTemplateLiteralLoose(e, t) {
|
|
9
|
-
return t || (t = e.slice(0)), e.raw = t, e;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
13
|
-
var StyledTimeContainer = /*#__PURE__*/styled.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n position: relative;\n width: 82px;\n"])));
|
|
14
|
-
var StyledInputTime = /*#__PURE__*/themeAnnotation(/*#__PURE__*/styled.input(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 1px solid ", ";\n border-radius: 8px;\n padding: 0 7px;\n font-size: 14px;\n height: 36px;\n\n &[disabled] {\n background-color: ", ";\n }\n\n &[data-has-errors='true'] {\n border: 1px solid ", " !important;\n color: ", ";\n\n &::-webkit-calendar-picker-indicator {\n filter: invert(22%) sepia(63%) saturate(7197%) hue-rotate(353deg) brightness(106%) contrast(87%);\n }\n }\n "])), gray80, gray95, errorColor, errorColor), Input);
|
|
15
|
-
var StyledTimePickerHelper = /*#__PURE__*/styled.div(_templateObject3 || (_templateObject3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n right: 1px;\n top: calc(50% - ", "px);\n"])), spacing * 2.5);
|
|
16
|
-
|
|
17
|
-
var DEFAULT_MIN_TIME = '00:00';
|
|
18
|
-
var DEFAULT_MAX_TIME = '23:59';
|
|
19
|
-
var TimePicker = function TimePicker(_ref) {
|
|
20
|
-
var _errors$slice;
|
|
21
|
-
var elementId = _ref.elementId,
|
|
22
|
-
onChange = _ref.onChange,
|
|
23
|
-
errors = _ref.errors,
|
|
24
|
-
value = _ref.value,
|
|
25
|
-
minTime = _ref.minTime,
|
|
26
|
-
maxTime = _ref.maxTime,
|
|
27
|
-
label = _ref.label,
|
|
28
|
-
isRequired = _ref.isRequired,
|
|
29
|
-
isReadonly = _ref.isReadonly,
|
|
30
|
-
showErrorLabel = _ref.showErrorLabel;
|
|
31
|
-
var onChangeTime = function onChangeTime(event) {
|
|
32
|
-
onChange(event.target.value);
|
|
33
|
-
};
|
|
34
|
-
var onChangeCorrectTime = function onChangeCorrectTime(event) {
|
|
35
|
-
var timesArray = [minTime !== null && minTime !== void 0 ? minTime : DEFAULT_MIN_TIME, maxTime !== null && maxTime !== void 0 ? maxTime : DEFAULT_MAX_TIME, event.target.value];
|
|
36
|
-
var correctTime = timesArray.sort()[1];
|
|
37
|
-
onChange(correctTime);
|
|
38
|
-
};
|
|
39
|
-
var inputTimeElementId = elementId + "-input-time";
|
|
40
|
-
return React.createElement(React.Fragment, null, label && React.createElement(Label, {
|
|
41
|
-
"for": inputTimeElementId,
|
|
42
|
-
label: label,
|
|
43
|
-
required: isRequired
|
|
44
|
-
}), React.createElement(StyledTimeContainer, null, React.createElement(StyledInputTime, {
|
|
45
|
-
id: inputTimeElementId,
|
|
46
|
-
"data-has-errors": Boolean(errors === null || errors === void 0 ? void 0 : errors.length),
|
|
47
|
-
required: isRequired,
|
|
48
|
-
disabled: isReadonly,
|
|
49
|
-
onChange: onChangeTime,
|
|
50
|
-
onBlur: onChangeCorrectTime,
|
|
51
|
-
type: "time",
|
|
52
|
-
value: value
|
|
53
|
-
}), showErrorLabel && React.createElement(StyledTimePickerHelper, null, React.createElement(ErrorLabel, {
|
|
54
|
-
elementId: elementId,
|
|
55
|
-
errors: (_errors$slice = errors === null || errors === void 0 ? void 0 : errors.slice()) !== null && _errors$slice !== void 0 ? _errors$slice : []
|
|
56
|
-
}))));
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export default TimePicker;
|
|
60
|
-
//# sourceMappingURL=time-picker.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"time-picker.esm.js","sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled, {AnyStyledComponent, StyledComponent} from 'styled-components';\nimport {spacing, errorColor, gray80, gray95} from '@propellerads/stylevariables';\nimport {Input, themeAnnotation} from '@propellerads/theme-annotation';\n\nexport const StyledTimeContainer = styled.div`\n display: flex;\n position: relative;\n width: 82px;\n`;\n\nexport const StyledInputTime = themeAnnotation(\n styled.input`\n border: 1px solid ${gray80};\n border-radius: 8px;\n padding: 0 7px;\n font-size: 14px;\n height: 36px;\n\n &[disabled] {\n background-color: ${gray95};\n }\n\n &[data-has-errors='true'] {\n border: 1px solid ${errorColor} !important;\n color: ${errorColor};\n\n &::-webkit-calendar-picker-indicator {\n filter: invert(22%) sepia(63%) saturate(7197%) hue-rotate(353deg) brightness(106%) contrast(87%);\n }\n }\n ` as AnyStyledComponent,\n Input,\n) as StyledComponent<'input', any>;\n\nexport const StyledTimePickerHelper = styled.div`\n position: absolute;\n right: 1px;\n top: calc(50% - ${spacing * 2.5}px);\n`;\n","import ErrorLabel from '@propellerads/error-label';\n\nimport Label from '@propellerads/label';\nimport React, {ChangeEvent, FunctionComponent} from 'react';\n\nimport {StyledInputTime, StyledTimeContainer, StyledTimePickerHelper} from './style';\nimport {TimePickerProps} from './types';\n\nconst DEFAULT_MIN_TIME = '00:00';\nconst DEFAULT_MAX_TIME = '23:59';\n\nconst TimePicker: FunctionComponent<TimePickerProps> = ({\n elementId,\n onChange,\n errors,\n value,\n minTime,\n maxTime,\n label,\n isRequired,\n isReadonly,\n showErrorLabel,\n}: TimePickerProps) => {\n const onChangeTime = (event: ChangeEvent<HTMLInputElement>) => {\n onChange(event.target.value);\n };\n\n const onChangeCorrectTime = (event: ChangeEvent<HTMLInputElement>) => {\n const timesArray = [minTime ?? DEFAULT_MIN_TIME, maxTime ?? DEFAULT_MAX_TIME, event.target.value];\n const correctTime = timesArray.sort()[1];\n\n onChange(correctTime);\n };\n\n const inputTimeElementId = `${elementId}-input-time`;\n\n return (\n <>\n {label && <Label for={inputTimeElementId} label={label} required={isRequired} />}\n <StyledTimeContainer>\n <StyledInputTime\n id={inputTimeElementId}\n data-has-errors={Boolean(errors?.length)}\n required={isRequired}\n disabled={isReadonly}\n onChange={onChangeTime}\n onBlur={onChangeCorrectTime}\n type=\"time\"\n value={value}\n />\n {showErrorLabel && (\n <StyledTimePickerHelper>\n <ErrorLabel elementId={elementId} errors={errors?.slice() ?? []} />\n </StyledTimePickerHelper>\n )}\n </StyledTimeContainer>\n </>\n );\n};\n\nexport default TimePicker;\n"],"names":["StyledTimeContainer","styled","div","_templateObject","_taggedTemplateLiteralLoose","StyledInputTime","themeAnnotation","input","_templateObject2","gray80","gray95","errorColor","Input","StyledTimePickerHelper","_templateObject3","spacing","DEFAULT_MIN_TIME","DEFAULT_MAX_TIME","TimePicker","_ref","elementId","onChange","errors","value","minTime","maxTime","label","isRequired","isReadonly","showErrorLabel","onChangeTime","event","target","onChangeCorrectTime","timesArray","correctTime","sort","inputTimeElementId","React","Label","required","id","Boolean","length","disabled","onBlur","type","ErrorLabel","_errors$slice","slice"],"mappings":";;;;;;;;;;;;AAIO,IAAMA,mBAAmB,gBAAGC,MAAM,CAACC,GAAG,CAAAC,eAAA,KAAAA,eAAA,gBAAAC,2BAAA,mEAI5C;AAEM,IAAMC,eAAe,gBAAGC,eAAe,cAC5CL,MAAM,CAACM,KAAK,CAAAC,gBAAA,KAAAA,gBAAA,gBAAAJ,2BAAA,wcACUK,MAAM,EAOJC,MAAM,EAINC,UAAU,EACrBA,UAAU,GAOvBC,KAAK,CAC2B;AAE3B,IAAMC,sBAAsB,gBAAGZ,MAAM,CAACC,GAAG,CAAAY,gBAAA,KAAAA,gBAAA,gBAAAV,2BAAA,6EAG5BW,OAAO,GAAG,GAAG,CAChC;;AC9BD,IAAMC,gBAAgB,GAAG,OAAO;AAChC,IAAMC,gBAAgB,GAAG,OAAO;AAEhC,IAAMC,UAAU,GAAuC,SAAjDA,UAAUA,CAAAC,IAAA;;MACdC,SAAS,GAAAD,IAAA,CAATC,SAAS;IACTC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,MAAM,GAAAH,IAAA,CAANG,MAAM;IACNC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IACLC,OAAO,GAAAL,IAAA,CAAPK,OAAO;IACPC,OAAO,GAAAN,IAAA,CAAPM,OAAO;IACPC,KAAK,GAAAP,IAAA,CAALO,KAAK;IACLC,UAAU,GAAAR,IAAA,CAAVQ,UAAU;IACVC,UAAU,GAAAT,IAAA,CAAVS,UAAU;IACVC,cAAc,GAAAV,IAAA,CAAdU,cAAc;EAEd,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAIC,KAAoC;IACxDV,QAAQ,CAACU,KAAK,CAACC,MAAM,CAACT,KAAK,CAAC;GAC7B;EAED,IAAMU,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIF,KAAoC;IAC/D,IAAMG,UAAU,GAAG,CAACV,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAIR,gBAAgB,EAAES,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAIR,gBAAgB,EAAEc,KAAK,CAACC,MAAM,CAACT,KAAK,CAAC;IACjG,IAAMY,WAAW,GAAGD,UAAU,CAACE,IAAI,EAAE,CAAC,CAAC,CAAC;IAExCf,QAAQ,CAACc,WAAW,CAAC;GACtB;EAED,IAAME,kBAAkB,GAAMjB,SAAS,gBAAa;EAEpD,OACEkB,0CACGZ,KAAK,IAAIY,oBAACC,KAAK;IAAC,OAAKF,kBAAkB;IAAEX,KAAK,EAAEA,KAAK;IAAEc,QAAQ,EAAEb;IAAc,EAChFW,oBAACtC,mBAAmB,QAClBsC,oBAACjC,eAAe;IACdoC,EAAE,EAAEJ,kBAAkB;uBACLK,OAAO,CAACpB,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEqB,MAAM,CAAC;IACxCH,QAAQ,EAAEb,UAAU;IACpBiB,QAAQ,EAAEhB,UAAU;IACpBP,QAAQ,EAAES,YAAY;IACtBe,MAAM,EAAEZ,mBAAmB;IAC3Ba,IAAI,EAAC,MAAM;IACXvB,KAAK,EAAEA;IACP,EACDM,cAAc,IACbS,oBAACzB,sBAAsB,QACrByB,oBAACS,UAAU;IAAC3B,SAAS,EAAEA,SAAS;IAAEE,MAAM,GAAA0B,aAAA,GAAE1B,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAE2B,KAAK,EAAE,cAAAD,aAAA,cAAAA,aAAA,GAAI;IAAM,CAEtE,CACmB,CACrB;AAEP,CAAC;;;;"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
declare type TimePickerProps = {
|
|
2
|
-
elementId: string;
|
|
3
|
-
onChange: (value: string) => void;
|
|
4
|
-
value: string;
|
|
5
|
-
minTime?: string | '00:00';
|
|
6
|
-
maxTime?: string | '23:59';
|
|
7
|
-
label?: string | null | undefined;
|
|
8
|
-
errors?: Array<string> | undefined;
|
|
9
|
-
isRequired?: boolean;
|
|
10
|
-
isReadonly?: boolean;
|
|
11
|
-
showErrorLabel?: boolean;
|
|
12
|
-
};
|
|
13
|
-
export type { TimePickerProps };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare module '*';
|
package/src/index.tsx
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import ErrorLabel from '@propellerads/error-label';
|
|
2
|
-
|
|
3
|
-
import Label from '@propellerads/label';
|
|
4
|
-
import React, {ChangeEvent, FunctionComponent} from 'react';
|
|
5
|
-
|
|
6
|
-
import {StyledInputTime, StyledTimeContainer, StyledTimePickerHelper} from './style';
|
|
7
|
-
import {TimePickerProps} from './types';
|
|
8
|
-
|
|
9
|
-
const DEFAULT_MIN_TIME = '00:00';
|
|
10
|
-
const DEFAULT_MAX_TIME = '23:59';
|
|
11
|
-
|
|
12
|
-
const TimePicker: FunctionComponent<TimePickerProps> = ({
|
|
13
|
-
elementId,
|
|
14
|
-
onChange,
|
|
15
|
-
errors,
|
|
16
|
-
value,
|
|
17
|
-
minTime,
|
|
18
|
-
maxTime,
|
|
19
|
-
label,
|
|
20
|
-
isRequired,
|
|
21
|
-
isReadonly,
|
|
22
|
-
showErrorLabel,
|
|
23
|
-
}: TimePickerProps) => {
|
|
24
|
-
const onChangeTime = (event: ChangeEvent<HTMLInputElement>) => {
|
|
25
|
-
onChange(event.target.value);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const onChangeCorrectTime = (event: ChangeEvent<HTMLInputElement>) => {
|
|
29
|
-
const timesArray = [minTime ?? DEFAULT_MIN_TIME, maxTime ?? DEFAULT_MAX_TIME, event.target.value];
|
|
30
|
-
const correctTime = timesArray.sort()[1];
|
|
31
|
-
|
|
32
|
-
onChange(correctTime);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const inputTimeElementId = `${elementId}-input-time`;
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<>
|
|
39
|
-
{label && <Label for={inputTimeElementId} label={label} required={isRequired} />}
|
|
40
|
-
<StyledTimeContainer>
|
|
41
|
-
<StyledInputTime
|
|
42
|
-
id={inputTimeElementId}
|
|
43
|
-
data-has-errors={Boolean(errors?.length)}
|
|
44
|
-
required={isRequired}
|
|
45
|
-
disabled={isReadonly}
|
|
46
|
-
onChange={onChangeTime}
|
|
47
|
-
onBlur={onChangeCorrectTime}
|
|
48
|
-
type="time"
|
|
49
|
-
value={value}
|
|
50
|
-
/>
|
|
51
|
-
{showErrorLabel && (
|
|
52
|
-
<StyledTimePickerHelper>
|
|
53
|
-
<ErrorLabel elementId={elementId} errors={errors?.slice() ?? []} />
|
|
54
|
-
</StyledTimePickerHelper>
|
|
55
|
-
)}
|
|
56
|
-
</StyledTimeContainer>
|
|
57
|
-
</>
|
|
58
|
-
);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export default TimePicker;
|
package/src/style.tsx
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import styled, {AnyStyledComponent, StyledComponent} from 'styled-components';
|
|
2
|
-
import {spacing, errorColor, gray80, gray95} from '@propellerads/stylevariables';
|
|
3
|
-
import {Input, themeAnnotation} from '@propellerads/theme-annotation';
|
|
4
|
-
|
|
5
|
-
export const StyledTimeContainer = styled.div`
|
|
6
|
-
display: flex;
|
|
7
|
-
position: relative;
|
|
8
|
-
width: 82px;
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
export const StyledInputTime = themeAnnotation(
|
|
12
|
-
styled.input`
|
|
13
|
-
border: 1px solid ${gray80};
|
|
14
|
-
border-radius: 8px;
|
|
15
|
-
padding: 0 7px;
|
|
16
|
-
font-size: 14px;
|
|
17
|
-
height: 36px;
|
|
18
|
-
|
|
19
|
-
&[disabled] {
|
|
20
|
-
background-color: ${gray95};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
&[data-has-errors='true'] {
|
|
24
|
-
border: 1px solid ${errorColor} !important;
|
|
25
|
-
color: ${errorColor};
|
|
26
|
-
|
|
27
|
-
&::-webkit-calendar-picker-indicator {
|
|
28
|
-
filter: invert(22%) sepia(63%) saturate(7197%) hue-rotate(353deg) brightness(106%) contrast(87%);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
` as AnyStyledComponent,
|
|
32
|
-
Input,
|
|
33
|
-
) as StyledComponent<'input', any>;
|
|
34
|
-
|
|
35
|
-
export const StyledTimePickerHelper = styled.div`
|
|
36
|
-
position: absolute;
|
|
37
|
-
right: 1px;
|
|
38
|
-
top: calc(50% - ${spacing * 2.5}px);
|
|
39
|
-
`;
|
package/src/types.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
type TimePickerProps = {
|
|
2
|
-
elementId: string;
|
|
3
|
-
onChange: (value: string) => void;
|
|
4
|
-
value: string;
|
|
5
|
-
minTime?: string | '00:00';
|
|
6
|
-
maxTime?: string | '23:59';
|
|
7
|
-
label?: string | null | undefined;
|
|
8
|
-
errors?: Array<string> | undefined;
|
|
9
|
-
isRequired?: boolean;
|
|
10
|
-
isReadonly?: boolean;
|
|
11
|
-
showErrorLabel?: boolean;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export type {TimePickerProps};
|