@propellerads/time-picker 2.0.3 → 2.0.4
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/time-picker.cjs.development.js +2 -2
- 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 +2 -2
- package/dist/time-picker.esm.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +3 -3
- package/src/index.tsx +3 -3
- package/src/types.ts +1 -1
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
|
-
var React = _interopDefault(require('react'));
|
|
8
|
-
var Label = _interopDefault(require('@propellerads/label'));
|
|
9
7
|
var ErrorLabel = _interopDefault(require('@propellerads/error-label'));
|
|
8
|
+
var Label = _interopDefault(require('@propellerads/label'));
|
|
9
|
+
var React = _interopDefault(require('react'));
|
|
10
10
|
var styled = _interopDefault(require('styled-components'));
|
|
11
11
|
var stylevariables = require('@propellerads/stylevariables');
|
|
12
12
|
var themeAnnotation = require('@propellerads/theme-annotation');
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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,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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 +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("
|
|
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
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, {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
|
|
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Label from '@propellerads/label';
|
|
3
1
|
import ErrorLabel from '@propellerads/error-label';
|
|
2
|
+
import Label from '@propellerads/label';
|
|
3
|
+
import React from 'react';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import { gray80, gray95, errorColor, spacing } from '@propellerads/stylevariables';
|
|
6
6
|
import { themeAnnotation, Input } from '@propellerads/theme-annotation';
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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,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;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
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/time-picker",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"repository": "https://github.com/propellerads/ui-components",
|
|
5
5
|
"author": "n.milantyeva@propellerads.net",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@propellerads/stylevariables": "^2.0.2",
|
|
35
|
-
"@propellerads/error-label": "^5.0.
|
|
36
|
-
"@propellerads/label": "^4.0.
|
|
35
|
+
"@propellerads/error-label": "^5.0.2",
|
|
36
|
+
"@propellerads/label": "^4.0.4",
|
|
37
37
|
"@propellerads/theme-annotation": "1.2.1"
|
|
38
38
|
}
|
|
39
39
|
}
|
package/src/index.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ErrorLabel from '@propellerads/error-label';
|
|
2
2
|
|
|
3
3
|
import Label from '@propellerads/label';
|
|
4
|
-
import
|
|
4
|
+
import React, {ChangeEvent, FunctionComponent} from 'react';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {StyledInputTime, StyledTimeContainer, StyledTimePickerHelper} from './style';
|
|
7
7
|
import {TimePickerProps} from './types';
|
|
8
8
|
|
|
9
9
|
const DEFAULT_MIN_TIME = '00:00';
|
package/src/types.ts
CHANGED