@planningcenter/tapestry-react 4.2.1-rc.0 → 4.3.0
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.
|
@@ -3,6 +3,7 @@ import Input from '../Input/Input';
|
|
|
3
3
|
import InputBox from '../Input/InputBox';
|
|
4
4
|
import { addHoursToTime, addMinutesToTime, addTimeToDate, getTimeFromDate } from './utils';
|
|
5
5
|
type TimeFieldProps = ComponentProps<typeof Input> & ComponentProps<typeof InputBox> & {
|
|
6
|
+
controlled?: boolean;
|
|
6
7
|
ignoredKeys?: string[];
|
|
7
8
|
interval?: number;
|
|
8
9
|
isIOS?: boolean;
|
|
@@ -13,7 +14,7 @@ type TimeFieldProps = ComponentProps<typeof Input> & ComponentProps<typeof Input
|
|
|
13
14
|
value: [number, number];
|
|
14
15
|
};
|
|
15
16
|
declare const TimeField: {
|
|
16
|
-
({
|
|
17
|
+
({ twelveHourClock, controlled, ...restProps }: TimeFieldProps): JSX.Element;
|
|
17
18
|
addHoursToTime: typeof addHoursToTime;
|
|
18
19
|
addMinutesToTime: typeof addMinutesToTime;
|
|
19
20
|
addTimeToDate: typeof addTimeToDate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeField.d.ts","sourceRoot":"","sources":["../../src/TimeField/TimeField.tsx"],"names":[],"mappings":"AAAA,OAAc,EACZ,cAAc,EAKf,MAAM,OAAO,CAAA;AAGd,OAAO,KAAK,MAAM,gBAAgB,CAAA;AAClC,OAAO,QAAQ,MAAM,mBAAmB,CAAA;AAIxC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,eAAe,EAChB,MAAM,SAAS,CAAA;AAEhB,KAAK,cAAc,GAAG,cAAc,CAAC,OAAO,KAAK,CAAC,GAChD,cAAc,CAAC,OAAO,QAAQ,CAAC,GAAG;IAKhC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IAEtB,QAAQ,CAAC,EAAE,MAAM,CAAA;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 -1,2 +1,2 @@
|
|
|
1
|
-
import{__rest as e,__assign as n}from'./../ext/tslib/tslib.es6.js';import t,{
|
|
1
|
+
import{__rest as e,__assign as n}from'./../ext/tslib/tslib.es6.js';import t,{useState as r,useRef as o,useMemo as i}from"react";import{Box as a}from"../Box/Box.js";import u from"../Input/Input.js";import c from"../Input/InputBox.js";import l from"../Input/InputField.js";import d from"../NumberField/NumberField.js";import{padNumber as f,noop as m}from"../utils.js";import{addHoursToTime as s,addMinutesToTime as v,addTimeToDate as p,getTimeFromDate as w}from"./utils.js";var y="undefined"!=typeof window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),g=function(r){var o=r.twelveHourClock,i=void 0===o||o,a=r.controlled,u=void 0!==a&&a,c=e(r,["twelveHourClock","controlled"]);return u?t.createElement(k,n({twelveHourClock:i},c)):t.createElement(h,n({twelveHourClock:i},c))};g.addHoursToTime=s,g.addMinutesToTime=v,g.addTimeToDate=p,g.getTimeFromDate=w;var h=function(o){var i=o.value,a=e(o,["value"]),u=r(i),c=u[0],l=u[1];return t.createElement(k,n({},a,{onChange:l,value:c}))},k=function(r){var s=r.ignoredKeys;r.interval;var v=r.isIOS,p=void 0!==v&&v;r.max,r.min;var w=r.onChange,g=r.twelveHourClock,h=r.value,k=e(r,["ignoredKeys","interval","isIOS","max","min","onChange","twelveHourClock","value"]),A=o(null),C=h[0],I=h[1],x=i((function(){return C<12?"AM":"PM"}),[C]),M=g&&"PM"===x?12:0,b=i((function(){return g?0===C?12:C>12?C-12:C:C}),[C]),D=function(e){var n=C-e;w(n<0?function(e){return[23,e[1]]}:function(e){return[n,e[1]]})},E=function(e){var n=C+e;w((function(e){return[n%24,e[1]]}))};return y||p?t.createElement(u,n({},k,{type:"time",autoWidth:"".concat(C,":").concat(f(I,2)," ").concat(x),value:"".concat(f(C,2),":").concat(f(I,2)),onChange:function(e){var n=e.target.value.split(":"),t=n[0],r=n[1];w(t||r?[parseInt(t,10),parseInt(r,10)]:[0,0])}})):t.createElement(c,n({ref:A,inline:!0},k),t.createElement(d,{"aria-label":"Hours",autoWidth:!1,fontVariantNumeric:"tabular-nums",grow:0,max:g?12:23,min:0,moveFocusOnMax:!0,onBlur:function(e){var n=parseInt(e.target.value,10);w((function(e){return[n+M,e[1]]}))},onChange:function(e){var n="string"==typeof e?parseInt(e,10):e;w((function(e){return[n+M,e[1]]}))},onKeyDown:function(e){var n;s&&s.includes(e.key)||("Backspace"===e.key&&e.preventDefault(),"ArrowRight"===e.key&&(null===(n=A.current)||void 0===n?void 0:n.node.children[2]).focus(),"ArrowUp"===e.key&&E(1),"ArrowDown"===e.key&&D(1))},pad:2,textAlign:"center",value:b,width:"2ch",ignoredKeys:s}),t.createElement(a,{as:"span",width:.5,textAlign:"center",userSelect:"none"},":"),t.createElement(d,{"aria-label":"Minutes",autoWidth:!1,fontVariantNumeric:"tabular-nums",grow:0,max:59,min:0,moveFocusOnMax:!0,onChange:function(e){return w((function(n){return[n[0],"string"==typeof e?parseInt(e,10):e]}))},onKeyDown:function(e){var n,t,r;"ArrowLeft"===e.key&&(null===(n=A.current)||void 0===n?void 0:n.node.children[0]).focus(),"ArrowRight"===e.key&&(null===(t=A.current)||void 0===t?void 0:t.node.children[3]).focus(),"ArrowUp"===e.key&&((r=I+1)<=59?w((function(e){return[e[0],r]})):(w((function(e){return[e[0],0]})),E(1))),"ArrowDown"===e.key&&function(e){var n=I-e;n>=0?w((function(e){return[e[0],n]})):(w((function(e){return[e[0],59]})),D(1))}(1)},pad:2,textAlign:"center",value:I,width:"2ch",ignoredKeys:s}),g&&t.createElement(l,{"aria-label":"AM/PM",grow:0,highlightOnInteraction:!0,onChange:m,onKeyDown:function(e){var n;s&&s.includes(e.key)||("Tab"===e.key||e.metaKey&&"r"===e.key||e.preventDefault(),"ArrowLeft"===e.key&&(null===(n=A.current)||void 0===n?void 0:n.node.children[2]).focus(),("a"===e.key.toLowerCase()&&"PM"===x||"p"===e.key.toLowerCase()&&"AM"===x||"ArrowUp"===e.key||"ArrowDown"===e.key)&&w("AM"===x?function(e){return[e[0]+12,e[1]]}:function(e){return[e[0]-12,e[1]]}))},textAlign:"center",value:x,width:"2em"}))};export{g as default};
|
|
2
2
|
//# sourceMappingURL=TimeField.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/tapestry-react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "A collection of flexible React components to help you build resilient, accessible user interfaces quickly and effectively.",
|
|
5
5
|
"author": "Front End Systems Engineering <frontend@pco.bz>",
|
|
6
6
|
"main": "./dist/index.js",
|