@propellerads/time-picker 1.3.0 → 2.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/CHANGELOG.md +19 -0
- package/dist/time-picker.cjs.development.js +3 -1
- package/dist/time-picker.cjs.development.js.map +1 -1
- package/dist/time-picker.cjs.production.min.js +1 -1
- package/dist/time-picker.cjs.production.min.js.map +1 -1
- package/dist/time-picker.esm.js +3 -1
- package/dist/time-picker.esm.js.map +1 -1
- package/package.json +8 -9
- package/src/index.tsx +1 -1
- package/src/style.tsx +2 -2
package/CHANGELOG.md
ADDED
|
@@ -29,6 +29,8 @@ var DEFAULT_MIN_TIME = '00:00';
|
|
|
29
29
|
var DEFAULT_MAX_TIME = '23:59';
|
|
30
30
|
|
|
31
31
|
var TimePicker = function TimePicker(_ref) {
|
|
32
|
+
var _errors$slice;
|
|
33
|
+
|
|
32
34
|
var elementId = _ref.elementId,
|
|
33
35
|
onChange = _ref.onChange,
|
|
34
36
|
errors = _ref.errors,
|
|
@@ -66,7 +68,7 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
66
68
|
value: value
|
|
67
69
|
}), showErrorLabel && React.createElement(StyledTimePickerHelper, null, React.createElement(ErrorLabel, {
|
|
68
70
|
elementId: elementId,
|
|
69
|
-
errors: errors === null || errors === void 0 ? void 0 : errors.slice()
|
|
71
|
+
errors: (_errors$slice = errors === null || errors === void 0 ? void 0 : errors.slice()) !== null && _errors$slice !== void 0 ? _errors$slice : []
|
|
70
72
|
}))));
|
|
71
73
|
};
|
|
72
74
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-picker.cjs.development.js","sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled, {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
|
|
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 React, {ChangeEvent, FunctionComponent} from 'react';\n\nimport Label from '@propellerads/label';\nimport ErrorLabel from '@propellerads/error-label';\n\nimport {StyledTimeContainer, StyledInputTime, 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","StyledInputTime","themeAnnotation","input","gray80","gray95","errorColor","Input","StyledTimePickerHelper","spacing","DEFAULT_MIN_TIME","DEFAULT_MAX_TIME","TimePicker","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","slice"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAIO,IAAMA,mBAAmB,gBAAGC,MAAM,CAACC,GAAV,kJAAzB;AAMA,IAAMC,eAAe,gBAAGC,+BAAe,eAC5CH,MAAM,CAACI,KADqC,yhBAEtBC,qBAFsB,EASpBC,qBAToB,EAapBC,yBAboB,EAc/BA,yBAd+B,GAqB5CC,qBArB4C,CAAvC;AAwBA,IAAMC,sBAAsB,gBAAGT,MAAM,CAACC,GAA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M,cAAc,IACbS,mBAAA,CAACvB,sBAAD,MAAA,EACEuB,mBAAA,CAACS,UAAD;IAAY3B,SAAS,EAAEA;IAAWE,MAAM,mBAAEA,MAAF,aAAEA,MAAF,uBAAEA,MAAM,CAAE0B,KAAR,EAAF,yDAAqB;GAA7D,CADF,CAZJ,CAFF,CADF;AAsBD,CA/CD;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
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("react")),a=e(require("@propellerads/label")),o=e(require("@propellerads/error-label")),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=e.elementId,
|
|
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("react")),a=e(require("@propellerads/label")),o=e(require("@propellerads/error-label")),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 l.createElement(l.Fragment,null,b&&l.createElement(a,{for:h,label:b,required:v}),l.createElement(p,null,l.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&&l.createElement(m,null,l.createElement(o,{elementId:n,errors:null!==(r=null==i?void 0:i.slice())&&void 0!==r?r:[]}))))};
|
|
2
2
|
//# sourceMappingURL=time-picker.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-picker.cjs.production.min.js","sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled, {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
|
|
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 React, {ChangeEvent, FunctionComponent} from 'react';\n\nimport Label from '@propellerads/label';\nimport ErrorLabel from '@propellerads/error-label';\n\nimport {StyledTimeContainer, StyledInputTime, 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","StyledInputTime","themeAnnotation","input","gray80","gray95","errorColor","Input","StyledTimePickerHelper","spacing","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","slice"],"mappings":"maAIO,IAAMA,EAAsBC,EAAOC,+EAM7BC,EAAkBC,kBAC7BH,EAAOI,gdACeC,SAOEC,SAIAC,aACXA,cAObC,SAGWC,EAAyBT,EAAOC,sFAGf,IAAVS,2BC1BmC,kBACrDC,IAAAA,UACAC,IAAAA,SACAC,IAAAA,OACAC,IAAAA,MACAC,IAAAA,QACAC,IAAAA,QACAC,IAAAA,MACAC,IAAAA,WACAC,IAAAA,WACAC,IAAAA,eAaMC,EAAwBV,gBAE9B,OACEW,gCACGL,GAASK,gBAACC,GAAMC,IAAKH,EAAoBJ,MAAOA,EAAOQ,SAAUP,IAClEI,gBAACvB,OACCuB,gBAACpB,GACCwB,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,gBAACb,OACCa,gBAACc,GAAWzB,UAAWA,EAAWE,iBAAQA,MAAAA,SAAAA,EAAQwB,uBAAW"}
|
package/dist/time-picker.esm.js
CHANGED
|
@@ -23,6 +23,8 @@ var DEFAULT_MIN_TIME = '00:00';
|
|
|
23
23
|
var DEFAULT_MAX_TIME = '23:59';
|
|
24
24
|
|
|
25
25
|
var TimePicker = function TimePicker(_ref) {
|
|
26
|
+
var _errors$slice;
|
|
27
|
+
|
|
26
28
|
var elementId = _ref.elementId,
|
|
27
29
|
onChange = _ref.onChange,
|
|
28
30
|
errors = _ref.errors,
|
|
@@ -60,7 +62,7 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
60
62
|
value: value
|
|
61
63
|
}), showErrorLabel && React.createElement(StyledTimePickerHelper, null, React.createElement(ErrorLabel, {
|
|
62
64
|
elementId: elementId,
|
|
63
|
-
errors: errors === null || errors === void 0 ? void 0 : errors.slice()
|
|
65
|
+
errors: (_errors$slice = errors === null || errors === void 0 ? void 0 : errors.slice()) !== null && _errors$slice !== void 0 ? _errors$slice : []
|
|
64
66
|
}))));
|
|
65
67
|
};
|
|
66
68
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-picker.esm.js","sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled, {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
|
|
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 React, {ChangeEvent, FunctionComponent} from 'react';\n\nimport Label from '@propellerads/label';\nimport ErrorLabel from '@propellerads/error-label';\n\nimport {StyledTimeContainer, StyledInputTime, 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","StyledInputTime","themeAnnotation","input","gray80","gray95","errorColor","Input","StyledTimePickerHelper","spacing","DEFAULT_MIN_TIME","DEFAULT_MAX_TIME","TimePicker","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","slice"],"mappings":";;;;;;;;;;;;;;;;;AAIO,IAAMA,mBAAmB,gBAAGC,MAAM,CAACC,GAAV,kJAAzB;AAMA,IAAMC,eAAe,gBAAGC,eAAe,eAC5CH,MAAM,CAACI,KADqC,yhBAEtBC,MAFsB,EASpBC,MAToB,EAapBC,UAboB,EAc/BA,UAd+B,GAqB5CC,KArB4C,CAAvC;AAwBA,IAAMC,sBAAsB,gBAAGT,MAAM,CAACC,GAAV,8JAGfS,OAAO,GAAG,GAHK,CAA5B;;AC1BP,IA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,mBAAA,CAACS,UAAD;IAAY3B,SAAS,EAAEA;IAAWE,MAAM,mBAAEA,MAAF,aAAEA,MAAF,uBAAEA,MAAM,CAAE0B,KAAR,EAAF,yDAAqB;GAA7D,CADF,CAZJ,CAFF,CADF;AAsBD,CA/CD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/time-picker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"repository": "https://github.com/propellerads/ui-components",
|
|
5
5
|
"author": "n.milantyeva@propellerads.net",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,23 +20,22 @@
|
|
|
20
20
|
"build": "tsdx build"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@types/
|
|
24
|
-
"
|
|
25
|
-
"@types/styled-components": "5.1.1",
|
|
26
|
-
"react": "^17.0.2",
|
|
27
|
-
"react-dom": "^17.0.2",
|
|
23
|
+
"@types/styled-components": "^5.1.36",
|
|
24
|
+
"react": ">=18 <19",
|
|
28
25
|
"styled-components": "5.1.1"
|
|
29
26
|
},
|
|
30
27
|
"module": "dist/time-picker.esm.js",
|
|
31
28
|
"devDependencies": {
|
|
29
|
+
"@types/react": ">=18 <19",
|
|
32
30
|
"tsdx": "^0.13.3",
|
|
33
31
|
"tslib": "^2.0.1",
|
|
34
|
-
"typescript": "^4.
|
|
32
|
+
"typescript": "^4.9.5"
|
|
35
33
|
},
|
|
36
34
|
"dependencies": {
|
|
37
|
-
"@propellerads/stylevariables": "^1.3.0",
|
|
38
35
|
"@propellerads/error-label": "^2.4.0",
|
|
39
36
|
"@propellerads/label": "^2.1.0",
|
|
37
|
+
"@propellerads/stylevariables": "^1.3.0",
|
|
40
38
|
"@propellerads/theme-annotation": "^1.2.0"
|
|
41
|
-
}
|
|
39
|
+
},
|
|
40
|
+
"gitHead": "e9422330908dc371869ba74b992de6d295b470c0"
|
|
42
41
|
}
|
package/src/index.tsx
CHANGED
|
@@ -50,7 +50,7 @@ const TimePicker: FunctionComponent<TimePickerProps> = ({
|
|
|
50
50
|
/>
|
|
51
51
|
{showErrorLabel && (
|
|
52
52
|
<StyledTimePickerHelper>
|
|
53
|
-
<ErrorLabel elementId={elementId} errors={errors?.slice()} />
|
|
53
|
+
<ErrorLabel elementId={elementId} errors={errors?.slice() ?? []} />
|
|
54
54
|
</StyledTimePickerHelper>
|
|
55
55
|
)}
|
|
56
56
|
</StyledTimeContainer>
|
package/src/style.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import styled, {StyledComponent} from 'styled-components';
|
|
1
|
+
import styled, {AnyStyledComponent, StyledComponent} from 'styled-components';
|
|
2
2
|
import {spacing, errorColor, gray80, gray95} from '@propellerads/stylevariables';
|
|
3
3
|
import {Input, themeAnnotation} from '@propellerads/theme-annotation';
|
|
4
4
|
|
|
@@ -28,7 +28,7 @@ export const StyledInputTime = themeAnnotation(
|
|
|
28
28
|
filter: invert(22%) sepia(63%) saturate(7197%) hue-rotate(353deg) brightness(106%) contrast(87%);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
` as AnyStyledComponent,
|
|
32
32
|
Input,
|
|
33
33
|
) as StyledComponent<'input', any>;
|
|
34
34
|
|