@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
- ({ ignoredKeys, interval, isIOS, max, min, onChange, twelveHourClock, value, ...restProps }: TimeFieldProps): JSX.Element;
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;IAKjB,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf,GAAG,C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,2 +1,2 @@
1
- import{__rest as e,__assign as n}from'./../ext/tslib/tslib.es6.js';import t,{useRef as r,useState as o,useEffect as i}from"react";import{Box as a}from"../Box/Box.js";import u from"../Input/Input.js";import l from"../Input/InputBox.js";import c from"../Input/InputField.js";import d from"../NumberField/NumberField.js";import{padNumber as s,noop as m}from"../utils.js";import{addHoursToTime as v,addMinutesToTime as f,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(v){var f=v.ignoredKeys;v.interval;var p=v.isIOS,w=void 0!==p&&p;v.max,v.min;var g=v.onChange,h=v.twelveHourClock,A=void 0===h||h,k=v.value,M=e(v,["ignoredKeys","interval","isIOS","max","min","onChange","twelveHourClock","value"]),I=r(null),x=o(k[0]),b=x[0],C=x[1],D=o(k[1]),j=D[0],K=D[1],P=o(b<12?"AM":"PM"),T=P[0],B=P[1],E=o(A&&b>12?b-12:b),O=E[0],F=E[1],H=function(e){var n=b-e;A?n>12?(C(n),F(n-12)):n<=12&&n>0?(C(n),F(n)):0===n?(C(n),F(12)):(C(23),F(11)):n<0?(C(23),F(23)):(C(n),F(n))},L=function(e){var n=b+e;A?n>0&&n<=12?(C(n),F(n)):n>12&&n<24?(C(n),F(n-12)):(C(0),F(12)):n<24?(C(n),F(n)):(C(0),F(0))};return i((function(){B(b<12?"AM":"PM"),function(e){var n=e[0],t=e[1];g([n,t])}([b,j])}),[b,j]),y||w?t.createElement(u,n({},M,{type:"time",autoWidth:"".concat(b,":").concat(s(j,2)," ").concat(T),value:"".concat(s(b,2),":").concat(s(j,2)),onChange:function(e){var n=e.target.value.split(":"),t=n[0],r=n[1];t||r?(C(parseInt(t,10)),K(parseInt(r,10))):(C(0),K(0))}})):t.createElement(l,n({ref:I,inline:!0},M),t.createElement(d,{"aria-label":"Hours",autoWidth:!1,fontVariantNumeric:"tabular-nums",grow:0,max:A?12:23,min:0,moveFocusOnMax:!0,onBlur:function(e){var n=parseInt(e.target.value);A?0===n?(C(0),F(12)):b<=12?(C(n),F(n)):12===n?(C(12),F(12)):(C(n+12),F(n)):(C(n),F(n))},onChange:function(e){var n="string"==typeof e?parseInt(e,10):e;F(n),!A&&C(n)},onKeyDown:function(e){var n;f&&f.includes(e.key)||("Backspace"===e.key&&e.preventDefault(),"ArrowRight"===e.key&&(null===(n=I.current)||void 0===n?void 0:n.node.children[2]).focus(),"ArrowUp"===e.key&&L(1),"ArrowDown"===e.key&&H(1))},pad:2,textAlign:"center",value:O,width:"2ch",ignoredKeys:f}),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 K("string"==typeof e?parseInt(e,10):e)},onKeyDown:function(e){var n,t,r;"ArrowLeft"===e.key&&(null===(n=I.current)||void 0===n?void 0:n.node.children[0]).focus(),"ArrowRight"===e.key&&(null===(t=I.current)||void 0===t?void 0:t.node.children[3]).focus(),"ArrowUp"===e.key&&((r=j+1)<=59?K(r):(K(0),L(1))),"ArrowDown"===e.key&&function(e){var n=j-e;n>=0?K(n):(K(59),H(1))}(1)},pad:2,textAlign:"center",value:j,width:"2ch",ignoredKeys:f}),A&&t.createElement(c,{"aria-label":"AM/PM",grow:0,highlightOnInteraction:!0,onChange:m,onKeyDown:function(e){var n;f&&f.includes(e.key)||("Tab"===e.key||e.metaKey&&"r"===e.key||e.preventDefault(),"ArrowLeft"===e.key&&(null===(n=I.current)||void 0===n?void 0:n.node.children[2]).focus(),("a"===e.key.toLowerCase()&&"PM"===T||"p"===e.key.toLowerCase()&&"AM"===T||"ArrowUp"===e.key||"ArrowDown"===e.key)&&("AM"===T?(B("PM"),b>=0&&b<=12&&C(b+12)):(B("AM"),b>=12&&b<24&&C(b-12))))},textAlign:"center",value:T,width:"2em"}))};g.addHoursToTime=v,g.addMinutesToTime=f,g.addTimeToDate=p,g.getTimeFromDate=w;export{g as default};
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.2.1-rc.0",
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",