@propellerads/time-picker 3.0.0 → 3.0.2
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.js +43 -55
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,74 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import i from "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
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`
|
|
8
9
|
display: flex;
|
|
9
10
|
position: relative;
|
|
10
11
|
width: 82px;
|
|
11
|
-
`,
|
|
12
|
-
border: 1px solid ${
|
|
12
|
+
`, f = n.input`
|
|
13
|
+
border: 1px solid ${i};
|
|
13
14
|
border-radius: 8px;
|
|
14
15
|
padding: 0 7px;
|
|
15
16
|
font-size: 14px;
|
|
16
17
|
height: 36px;
|
|
17
|
-
${
|
|
18
|
+
${s}
|
|
18
19
|
|
|
19
20
|
&[disabled] {
|
|
20
|
-
background-color: ${
|
|
21
|
+
background-color: ${a};
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
${({ $hasErrors:
|
|
24
|
-
border: 1px solid ${
|
|
25
|
-
color: ${
|
|
24
|
+
${({ $hasErrors: e }) => e && `
|
|
25
|
+
border: 1px solid ${r} !important;
|
|
26
|
+
color: ${r};
|
|
26
27
|
|
|
27
28
|
&::-webkit-calendar-picker-indicator {
|
|
28
29
|
filter: invert(22%) sepia(63%) saturate(7197%) hue-rotate(353deg) brightness(106%) contrast(87%);
|
|
29
30
|
}
|
|
30
31
|
`}
|
|
31
|
-
`,
|
|
32
|
+
`, p = n.div`
|
|
32
33
|
position: absolute;
|
|
33
34
|
right: 1px;
|
|
34
|
-
top: calc(50% - ${
|
|
35
|
-
`,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
id: d,
|
|
58
|
-
$hasErrors: h,
|
|
59
|
-
required: c,
|
|
60
|
-
disabled: g,
|
|
61
|
-
onChange: (e) => n(e.target.value),
|
|
62
|
-
onBlur: b,
|
|
63
|
-
type: "time",
|
|
64
|
-
value: f
|
|
65
|
-
}
|
|
66
|
-
),
|
|
67
|
-
x && /* @__PURE__ */ t(_, { children: /* @__PURE__ */ t($, { elementId: r, errors: s?.slice() ?? [] }) })
|
|
68
|
-
] })
|
|
69
|
-
] });
|
|
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
|
+
}) })] })] });
|
|
70
58
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
//# sourceMappingURL=index.js.map
|
|
59
|
+
//#endregion
|
|
60
|
+
export { g as default };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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"],"
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/time-picker",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"url": "https://github.com/propellerads/ui-components/issues"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "tsc && vite build && rollup -c rollup.dts.config.mjs"
|
|
22
|
+
"build": "tsc && vite build && bunx rollup -c rollup.dts.config.mjs"
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
25
25
|
"private": false,
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@propellerads/error-label": "^
|
|
28
|
-
"@propellerads/label": "^
|
|
27
|
+
"@propellerads/error-label": "^7.0.0",
|
|
28
|
+
"@propellerads/label": "^5.0.0",
|
|
29
29
|
"@propellerads/stylevariables": "^2.0.2",
|
|
30
|
-
"@propellerads/theme-annotation": "^2.
|
|
30
|
+
"@propellerads/theme-annotation": "^2.1.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/react": "^19.2.14",
|
|
38
|
-
"@vitejs/plugin-react": "^
|
|
39
|
-
"rollup": "^4.
|
|
40
|
-
"rollup-plugin-dts": "^6.
|
|
41
|
-
"typescript": "^
|
|
42
|
-
"vite": "^
|
|
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.11"
|
|
43
43
|
}
|
|
44
44
|
}
|