@phillips/seldon 1.6.0 → 1.7.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.
@@ -1,8 +1,6 @@
1
- var o = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2
- function l(e) {
3
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
1
+ function e(t) {
2
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
4
3
  }
5
4
  export {
6
- o as commonjsGlobal,
7
- l as getDefaultExportFromCjs
5
+ e as getDefaultExportFromCjs
8
6
  };
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ export interface ErrorBoundaryProps {
3
+ /**
4
+ * Optional fallback component to render in case an error is thrown in the wrapped component
5
+ */
6
+ fallback?: React.ReactNode;
7
+ /**
8
+ * Optional logging method to call when error is thrown
9
+ */
10
+ logger: (error: Error, info: string) => void;
11
+ /**
12
+ * Wrapped component(s)
13
+ */
14
+ children: React.ReactNode;
15
+ }
16
+ interface State {
17
+ hasError: boolean;
18
+ }
19
+ declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, State> {
20
+ static defaultProps: {
21
+ logger: {
22
+ (...data: any[]): void;
23
+ (message?: any, ...optionalParams: any[]): void;
24
+ };
25
+ };
26
+ state: State;
27
+ static getDerivedStateFromError(): {
28
+ hasError: boolean;
29
+ };
30
+ componentDidCatch(error: Error, info: React.ErrorInfo): void;
31
+ render(): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | null | undefined;
32
+ }
33
+ export default ErrorBoundary;
@@ -0,0 +1,29 @@
1
+ var n = Object.defineProperty;
2
+ var i = (e, r, t) => r in e ? n(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
+ var o = (e, r, t) => (i(e, typeof r != "symbol" ? r + "" : r, t), t);
4
+ import { jsx as c } from "react/jsx-runtime";
5
+ import * as l from "react";
6
+ class p extends l.Component {
7
+ constructor() {
8
+ super(...arguments);
9
+ o(this, "state", {
10
+ hasError: !1
11
+ });
12
+ }
13
+ static getDerivedStateFromError() {
14
+ return { hasError: !0 };
15
+ }
16
+ componentDidCatch(t, a) {
17
+ var s;
18
+ (s = this.props) == null || s.logger(t, a.componentStack);
19
+ }
20
+ render() {
21
+ return this.state.hasError ? this.props.fallback || /* @__PURE__ */ c("h2", { children: "Sorry... An error occurred and we are looking into it" }) : this.props.children;
22
+ }
23
+ }
24
+ o(p, "defaultProps", {
25
+ logger: console.log
26
+ });
27
+ export {
28
+ p as default
29
+ };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { default as Button } from './components/Button/Button';
2
- export { default as DatePicker } from './components/DatePicker/DatePicker';
2
+ export { default as ErrorBoundary } from './components/ErrorBoundary/ErrorBoundary';
3
3
  export { default as Header } from './components/Header/Header';
4
4
  export { default as HeroBanner } from './components/HeroBanner/HeroBanner';
5
5
  export { default as Input } from './components/Input/Input';
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { default as a } from "./components/Button/Button.js";
2
- import { default as o } from "./components/DatePicker/DatePicker.js";
2
+ import { default as t } from "./components/ErrorBoundary/ErrorBoundary.js";
3
3
  import { default as u } from "./components/Header/Header.js";
4
4
  import { default as l } from "./components/HeroBanner/HeroBanner.js";
5
5
  import { default as m } from "./components/Input/Input.js";
6
6
  import { default as x } from "./components/Select/Select.js";
7
- import { default as c } from "./pages/Page.js";
7
+ import { default as B } from "./pages/Page.js";
8
8
  export {
9
9
  a as Button,
10
- o as DatePicker,
10
+ t as ErrorBoundary,
11
11
  u as Header,
12
12
  l as HeroBanner,
13
13
  m as Input,
14
- c as Page,
14
+ B as Page,
15
15
  x as Select
16
16
  };
@@ -1,13 +1,12 @@
1
1
  import { jsx as s } from "react/jsx-runtime";
2
- const a = "phillips", p = () => {
3
- };
4
- function u({
2
+ const n = "phillips";
3
+ function c({
5
4
  disabled: l = !1,
6
5
  id: r,
7
6
  invalid: d = !1,
8
7
  invalidText: t = "invalid",
9
8
  readOnly: o = !1,
10
- type: n,
9
+ type: a,
11
10
  warn: v = !1,
12
11
  warnText: e
13
12
  }) {
@@ -15,7 +14,7 @@ function u({
15
14
  disabled: !o && l,
16
15
  invalid: !o && !l && d,
17
16
  invalidId: `${r}-error-msg`,
18
- type: n === "toggle" ? "checkbox" : n,
17
+ type: a === "toggle" ? "checkbox" : a,
19
18
  warn: !o && !l && !d && v,
20
19
  warnId: `${r}-warn-msg`,
21
20
  validation: null
@@ -23,21 +22,20 @@ function u({
23
22
  return i.invalid && (i.validation = /* @__PURE__ */ s(
24
23
  "div",
25
24
  {
26
- className: `${a}-input__validation ${a}-${n}-input--invalid`,
25
+ className: `${n}-input__validation ${n}-${a}-input--invalid`,
27
26
  id: i.invalidId,
28
27
  children: t
29
28
  }
30
29
  )), i.warn && (i.validation = /* @__PURE__ */ s(
31
30
  "div",
32
31
  {
33
- className: `${a}-input__validation ${a}-${n}-input--warn`,
32
+ className: `${n}-input__validation ${n}-${a}-input--warn`,
34
33
  id: i.warnId,
35
34
  children: e
36
35
  }
37
36
  )), i;
38
37
  }
39
38
  export {
40
- p as noOP,
41
- a as px,
42
- u as useNormalizedInputProps
39
+ n as px,
40
+ c as useNormalizedInputProps
43
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phillips/seldon",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,4 +0,0 @@
1
- var e = { exports: {} };
2
- export {
3
- e as __module
4
- };
@@ -1,90 +0,0 @@
1
- import * as React from 'react';
2
- import flatpickr from 'flatpickr';
3
- import { InputProps } from '../Input/Input';
4
- export interface DatePickerProps extends Omit<InputProps, 'defaultValue'>, Record<string, unknown> {
5
- /**
6
- * Optionally allow manual entry to the date input
7
- */
8
- allowInput?: boolean;
9
- /**
10
- * Optionally provide the default value of the `<input>`. Should not be passed into controlled input!
11
- */
12
- defaultValue?: (Date | string)[];
13
- /**
14
- * Booolean to specify whether the `<input>` should be disabled
15
- */
16
- disabled?: boolean;
17
- /**
18
- * Render time picker on dropdown
19
- */
20
- enableTime?: boolean;
21
- /**
22
- * Boolean to specify whether you want the underlying label to be visually hidden
23
- */
24
- hideLabel?: boolean;
25
- /**
26
- * A custom `id` for the `<input>`
27
- */
28
- id: string;
29
- /**
30
- * Boolean to dictate whether input is inline with the label or not. `true` to use the inline version.
31
- */
32
- inline?: boolean;
33
- /**
34
- * Boolean to specify whether the control is currently invalid
35
- */
36
- invalid?: boolean;
37
- /**
38
- * Validation text that is displayed when the control is in an invalid state
39
- */
40
- invalidText?: React.ReactNode;
41
- /**
42
- * Text that will be read by a screen reader when visiting this control
43
- */
44
- labelText: string;
45
- /**
46
- * Locatiion you want the calendar to render for
47
- */
48
- locale: string;
49
- /**
50
- * Optional `onChange` handler that is called whenever flatpickr is updated
51
- * @param {array} selectedDates
52
- * @param {string} dateStr
53
- * @param {object} instance
54
- */
55
- onChange?: flatpickr.Options.Hook;
56
- /**
57
- * Optional `onClick` handler that is called whenever the `<input>` is clicked
58
- */
59
- onClick?: (event: React.MouseEvent<HTMLElement>) => void;
60
- /**
61
- * Optional text to be used for the placeholder attribute of the `<input>`
62
- */
63
- placeholder?: string;
64
- /**
65
- * Boolean to deterimine whether the input should be read-only
66
- */
67
- readOnly?: boolean;
68
- /**
69
- * Enum to determine the height of the Text Input. Currently supports the following:
70
- */
71
- size?: 'sm' | 'md' | 'lg';
72
- /**
73
- * Enum to determine whether component is a range or range and time
74
- */
75
- type?: 'single' | 'range';
76
- /**
77
- * Specify the value of the `<input>` for controlled inputs
78
- */
79
- value?: string | number | undefined;
80
- /**
81
- * Boolean to specify whether the control is currently in warning state
82
- */
83
- warn?: boolean;
84
- /**
85
- * Text that is displayed when the control is in warning state
86
- */
87
- warnText?: React.ReactNode;
88
- }
89
- declare const DatePicker: React.ForwardRefExoticComponent<Omit<DatePickerProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
90
- export default DatePicker;
@@ -1,92 +0,0 @@
1
- import { jsx as G } from "react/jsx-runtime";
2
- import * as d from "react";
3
- import O from "../../node_modules/flatpickr/dist/esm/index.js";
4
- import k from "../../node_modules/flatpickr/dist/l10n/index.js";
5
- import { noOP as R, useNormalizedInputProps as J } from "../../utils/index.js";
6
- import Q from "../Input/Input.js";
7
- k.en.weekdays.shorthand.forEach((u, o) => {
8
- const c = k.en.weekdays.shorthand;
9
- c[o] === "Thu" || c[o] === "Th" ? c[o] = "Th" : c[o] = c[o].charAt(0);
10
- });
11
- const W = d.forwardRef(({
12
- allowInput: u = !1,
13
- className: o,
14
- defaultValue: c = [],
15
- disabled: S,
16
- enableTime: p = !1,
17
- hideLabel: z,
18
- id: a,
19
- inline: A,
20
- invalid: y,
21
- invalidText: g,
22
- labelText: H,
23
- locale: D = "en",
24
- onChange: f = R,
25
- onClick: M = R,
26
- placeholder: U,
27
- readOnly: P,
28
- size: _ = "md",
29
- type: l = "range",
30
- value: $,
31
- warn: b,
32
- warnText: j,
33
- ...q
34
- }, e) => {
35
- const m = J({ disabled: S, id: a, invalid: y, invalidText: g, readOnly: P, type: l, warn: b, warnText: j }), t = d.useRef(), s = d.useRef(), r = d.useRef();
36
- d.useEffect(
37
- () => {
38
- const n = {
39
- allowInput: u,
40
- clickOpens: !m.disabled,
41
- defaultDate: c,
42
- enableTime: p,
43
- locale: k[D],
44
- mode: l,
45
- onChange: f
46
- };
47
- return typeof e == "object" && (e != null && e.current) && (t.current = O(e.current, n)), e === null && typeof s == "object" && s != null && s.current && (t.current = O(s == null ? void 0 : s.current, n)), () => {
48
- t.current && t.current.destroy && t.current.destroy();
49
- };
50
- },
51
- [u, c, m.disabled, p, a, D, f, e, l]
52
- );
53
- const v = (n) => {
54
- var i;
55
- u && /[0-9-/:]+/g.test(n.key) && (r.current = (i = t == null ? void 0 : t.current) == null ? void 0 : i.selectedDates);
56
- }, F = (n) => {
57
- var i, E, N, T, B, K, L;
58
- if (!(!u || n.relatedTarget instanceof HTMLElement && ((i = n.relatedTarget) != null && i.classList.value.includes("flatpickr"))) && "current" in r && (E = r == null ? void 0 : r.current) != null && E.length && ((N = r == null ? void 0 : r.current) == null ? void 0 : N.length) > 0 && ((T = r == null ? void 0 : r.current) == null ? void 0 : T.join().toString()) !== ((B = t == null ? void 0 : t.current) == null ? void 0 : B.selectedDates.join().toString())) {
59
- const h = (K = t.current) == null ? void 0 : K.element;
60
- r.current = [], f((L = t.current) == null ? void 0 : L.selectedDates, h == null ? void 0 : h.value, t.current);
61
- }
62
- };
63
- return /* @__PURE__ */ G(
64
- Q,
65
- {
66
- className: `${o} flatpickr`,
67
- "data-testid": a,
68
- disabled: m.disabled,
69
- hideLabel: z,
70
- id: a,
71
- inline: A,
72
- invalid: y,
73
- invalidText: g,
74
- labelText: H,
75
- onClick: M,
76
- placeholder: U,
77
- readOnly: P,
78
- ref: e || s,
79
- size: _,
80
- value: $,
81
- warn: b,
82
- warnText: j,
83
- onKeyUp: v,
84
- onBlur: F,
85
- ...q
86
- }
87
- );
88
- });
89
- W.displayName = "DatePicker";
90
- export {
91
- W as default
92
- };