@propellerads/time-picker 4.0.0 → 5.0.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.
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { InputProps } from '@propellerads/input';
|
|
1
|
+
import * as react from 'react';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import { InputProps } from '@propellerads/input';
|
|
4
4
|
|
|
5
5
|
/** The props of the field around the time, as `Input` has them. */
|
|
6
6
|
type FieldProps = Pick<InputProps, 'labelPosition' | 'labelWidth' | 'optional' | 'optionalText' | 'messageDisplay' | 'description' | 'error' | 'warning' | 'hintLabel' | 'aria-label'>;
|
|
@@ -36,7 +36,7 @@ type TimePickerProps = FieldProps & {
|
|
|
36
36
|
* time field: the time is typed, and a phone opens its own wheel on a tap. The
|
|
37
37
|
* clock at the end is a picture of what the field holds.
|
|
38
38
|
*/
|
|
39
|
-
declare const TimePicker: ({ elementId, onChange, value, minTime, maxTime, label, isRequired, isDisabled, isReadonly, errors, showErrorLabel: _showErrorLabel, error, ...field }: TimePickerProps) =>
|
|
39
|
+
declare const TimePicker: ({ elementId, onChange, value, minTime, maxTime, label, isRequired, isDisabled, isReadonly, errors, showErrorLabel: _showErrorLabel, error, ...field }: TimePickerProps) => react.JSX.Element;
|
|
40
40
|
|
|
41
41
|
export { TimePicker as default };
|
|
42
42
|
export type { TimePickerProps };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import e from "@propellerads/input";
|
|
2
2
|
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
-
import './index.css'
|
|
3
|
+
import './index.css';// src/index.tsx
|
|
4
4
|
var n = "00:00", r = "23:59", i = (e) => {
|
|
5
5
|
let t = e.currentTarget.closest(".input-group")?.querySelector("input:not(:disabled)");
|
|
6
6
|
t != null && (e.preventDefault(), t.focus());
|
|
@@ -37,7 +37,6 @@ var n = "00:00", r = "23:59", i = (e) => {
|
|
|
37
37
|
error: y
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
|
-
//#endregion
|
|
41
40
|
export { o as default };
|
|
42
41
|
|
|
43
42
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.tsx"],"sourcesContent":["import Input from '@propellerads/input';\nimport type {FocusEventHandler, MouseEvent} from 'react';\nimport './time-picker.css';\nimport type {TimePickerProps} from './types';\n\nconst DEFAULT_MIN_TIME = '00:00' as const;\nconst DEFAULT_MAX_TIME = '23:59' as const;\n\n/**\n * A press on the clock is a press on the field: the input takes the focus, and\n * the time is typed. The mouse-down is held back, or it would take the focus\n * away first.\n */\nconst pressField = (event: MouseEvent<SVGSVGElement>) => {\n const input = event.currentTarget.closest('.input-group')?.querySelector<HTMLInputElement>('input:not(:disabled)');\n if (input == null) {\n return;\n }\n event.preventDefault();\n input.focus();\n};\n\n/**\n * The clock of @propellerads/icon's `Time`, drawn here so the package does not\n * take styled-components with it. It only says what the field is: it is not a\n * button and a screen reader skips it; a press on it is a press on the field.\n */\nconst TimeIcon = () => (\n <svg\n className=\"time-picker__icon\"\n viewBox=\"0 0 24 24\"\n width=\"20\"\n height=\"20\"\n aria-hidden=\"true\"\n onMouseDown={pressField}\n >\n <path\n fill=\"currentColor\"\n d=\"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm-.22-13h-.06c-.4 0-.72.32-.72.72v4.72c0 .35.18.68.49.86l4.15 2.49c.34.2.78.1.98-.24.21-.34.1-.79-.25-.99l-3.87-2.3V7.72c0-.4-.32-.72-.72-.72z\"\n />\n </svg>\n);\n\n/**\n * A time of day, `HH:mm`, in the box of Input: the same height, contour, focus\n * ring and messages as every field next to it. The browser draws the hours and\n * the minutes; its clock button is hidden in time-picker.css, as in shadcn's\n * time field: the time is typed, and a phone opens its own wheel on a tap. The\n * clock at the end is a picture of what the field holds.\n */\nconst TimePicker = ({\n elementId,\n onChange,\n value,\n minTime = DEFAULT_MIN_TIME,\n maxTime = DEFAULT_MAX_TIME,\n label,\n isRequired = false,\n isDisabled,\n isReadonly = false,\n errors,\n showErrorLabel: _showErrorLabel,\n error,\n ...field\n}: TimePickerProps) => {\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 // The old errors become the field's error. The key is passed even when there\n // is none, so the field stays put while an error comes and goes.\n const fieldError = error ?? (errors !== undefined && errors.length > 0 ? errors : undefined);\n\n return (\n <Input\n {...field}\n // The id is the one a label elsewhere on the page points at.\n id={elementId}\n type=\"time\"\n value={value}\n min={minTime}\n max={maxTime}\n onChange={(event) => onChange(event.target.value)}\n onBlur={onBlurCorrectTime}\n endAddon={<TimeIcon />}\n isDisabled={isDisabled ?? isReadonly}\n isRequired={isRequired}\n groupClassName=\"time-picker\"\n // An empty label draws none, as before: Label leaves it out.\n label={label}\n error={fieldError}\n />\n );\n};\n\nexport default TimePicker;\nexport type {TimePickerProps} from './types';\n"],"mappings":";;;AAKA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["Input","DEFAULT_MIN_TIME","DEFAULT_MAX_TIME","pressField","input","event","TimeIcon","TimePicker","_showErrorLabel","field","onBlurCorrectTime","nextValue","minTime","maxTime","fieldError","error","errors","elementId","onChange","isDisabled","isReadonly"],"sources":["../src/index.tsx"],"sourcesContent":["import Input from '@propellerads/input';\nimport type {FocusEventHandler, MouseEvent} from 'react';\nimport './time-picker.css';\nimport type {TimePickerProps} from './types';\n\nconst DEFAULT_MIN_TIME = '00:00' as const;\nconst DEFAULT_MAX_TIME = '23:59' as const;\n\n/**\n * A press on the clock is a press on the field: the input takes the focus, and\n * the time is typed. The mouse-down is held back, or it would take the focus\n * away first.\n */\nconst pressField = (event: MouseEvent<SVGSVGElement>) => {\n const input = event.currentTarget.closest('.input-group')?.querySelector<HTMLInputElement>('input:not(:disabled)');\n if (input == null) {\n return;\n }\n event.preventDefault();\n input.focus();\n};\n\n/**\n * The clock of @propellerads/icon's `Time`, drawn here so the package does not\n * take styled-components with it. It only says what the field is: it is not a\n * button and a screen reader skips it; a press on it is a press on the field.\n */\nconst TimeIcon = () => (\n <svg\n className=\"time-picker__icon\"\n viewBox=\"0 0 24 24\"\n width=\"20\"\n height=\"20\"\n aria-hidden=\"true\"\n onMouseDown={pressField}\n >\n <path\n fill=\"currentColor\"\n d=\"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm-.22-13h-.06c-.4 0-.72.32-.72.72v4.72c0 .35.18.68.49.86l4.15 2.49c.34.2.78.1.98-.24.21-.34.1-.79-.25-.99l-3.87-2.3V7.72c0-.4-.32-.72-.72-.72z\"\n />\n </svg>\n);\n\n/**\n * A time of day, `HH:mm`, in the box of Input: the same height, contour, focus\n * ring and messages as every field next to it. The browser draws the hours and\n * the minutes; its clock button is hidden in time-picker.css, as in shadcn's\n * time field: the time is typed, and a phone opens its own wheel on a tap. The\n * clock at the end is a picture of what the field holds.\n */\nconst TimePicker = ({\n elementId,\n onChange,\n value,\n minTime = DEFAULT_MIN_TIME,\n maxTime = DEFAULT_MAX_TIME,\n label,\n isRequired = false,\n isDisabled,\n isReadonly = false,\n errors,\n showErrorLabel: _showErrorLabel,\n error,\n ...field\n}: TimePickerProps) => {\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 // The old errors become the field's error. The key is passed even when there\n // is none, so the field stays put while an error comes and goes.\n const fieldError = error ?? (errors !== undefined && errors.length > 0 ? errors : undefined);\n\n return (\n <Input\n {...field}\n // The id is the one a label elsewhere on the page points at.\n id={elementId}\n type=\"time\"\n value={value}\n min={minTime}\n max={maxTime}\n onChange={(event) => onChange(event.target.value)}\n onBlur={onBlurCorrectTime}\n endAddon={<TimeIcon />}\n isDisabled={isDisabled ?? isReadonly}\n isRequired={isRequired}\n groupClassName=\"time-picker\"\n // An empty label draws none, as before: Label leaves it out.\n label={label}\n error={fieldError}\n />\n );\n};\n\nexport default TimePicker;\nexport type {TimePickerProps} from './types';\n"],"mappings":";;;AAKA,IAAMC,IAAmB,SACnBC,IAAmB,SAOnBC,KAAc,MAAqC;CACvD,IAAMC,IAAQC,EAAM,cAAc,QAAQ,cAAc,CAAC,EAAE,cAAgC,sBAAsB;CACjH,AAAID,KAAS,SAGbC,EAAM,eAAe,GACrBD,EAAM,MAAM;AACd,GAOME,UACJ,kBAAC,OAAD;CACE,WAAU;CACV,SAAQ;CACR,OAAM;CACN,QAAO;CACP,eAAY;CACZ,aAAaH;CAEb,UAAA,kBAAC,QAAD;EACE,MAAK;EACL,GAAE;CACH,CAAA;AACE,CAAA,GAUDI,KAAc,EAClB,cACA,aACA,UACA,aAAUN,GACV,aAAUC,GACV,UACA,gBAAa,IACb,eACA,gBAAa,IACb,WACA,gBAAgBM,GAChB,UACA,GAAGC,QACkB;CACrB,IAAMC,KAA0D,MAAU;EACxE,IAAM,EAAC,OAAOC,MAAaN,EAAM;EAGjC,EAFoBM,IAAYC,IAAUA,IAAUD,IAAYE,IAAUA,IAAUF,CAEhE;CACtB,GAIMG,IAAaC,MAAUC,MAAW,KAAA,KAAaA,EAAO,SAAS,IAAIA,IAAS,KAAA;CAElF,OACE,kBAAChB,GAAD;EACE,GAAIS;EAEJ,IAAIQ;EACJ,MAAK;EACE;EACP,KAAKL;EACL,KAAKC;EACL,WAAW,MAAUK,EAASb,EAAM,OAAO,KAAK;EAChD,QAAQK;EACR,UAAU,kBAACJ,GAAD,CAAW,CAAA;EACrB,YAAYa,KAAcC;EACd;EACZ,gBAAe;EAER;EACP,OAAON;CACR,CAAA;AAEL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/time-picker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/index.css",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"url": "https://github.com/propellerads/ui-components/issues"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsc && vite build &&
|
|
27
|
+
"build": "tsc && vite build && rollup -c rollup.dts.config.mjs"
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
30
30
|
"private": false,
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@propellerads/input": "^
|
|
32
|
+
"@propellerads/input": "^3.0.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@propellerads/tokens": ">=0.
|
|
35
|
+
"@propellerads/tokens": ">=0.5.0",
|
|
36
36
|
"react": "^18.0.0 || ^19.0.0",
|
|
37
37
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
38
38
|
},
|