@phillips/seldon 1.150.1 → 1.151.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.
@@ -12,6 +12,26 @@ export interface TextAreaProps extends ComponentProps<'textarea'> {
12
12
  * Text that will be read by a screen reader when visiting this control
13
13
  */
14
14
  labelText: React.ReactNode;
15
+ /**
16
+ * Boolean to specify whether the control is disabled
17
+ */
18
+ disabled?: boolean;
19
+ /**
20
+ * Boolean to specify whether the control is currently in an invalid state
21
+ */
22
+ invalid?: boolean;
23
+ /**
24
+ * Text that is displayed when the control is in an invalid state
25
+ */
26
+ invalidText?: React.ReactNode;
27
+ /**
28
+ * Boolean to specify whether the control is currently in warning state
29
+ */
30
+ warn?: boolean;
31
+ /**
32
+ * Text that is displayed when the control is in warning state
33
+ */
34
+ warnText?: React.ReactNode;
15
35
  }
16
36
  /**
17
37
  * ## Overview
@@ -1,43 +1,73 @@
1
- import { jsxs as f, jsx as t } from "react/jsx-runtime";
2
- import { forwardRef as $, useId as u } from "react";
1
+ import { jsxs as n, Fragment as w, jsx as s } from "react/jsx-runtime";
2
+ import { forwardRef as I, useId as A } from "react";
3
3
  import l from "../../node_modules/classnames/index.js";
4
- import { px as r } from "../../utils/index.js";
5
- import N from "../Icon/Icon.js";
6
- const _ = $(
7
- ({ className: m, id: e, isSkeletonLoading: o, labelText: n, maxLength: c = 3e3, name: i, rows: d = 2, ...p }, x) => {
8
- const s = `${r}-text-area`, a = u();
9
- return /* @__PURE__ */ f("div", { className: l(`${s}__wrapper`), children: [
10
- /* @__PURE__ */ t(
11
- "label",
12
- {
13
- "data-testid": `text-area-${e ?? a}-label`,
14
- htmlFor: e ?? a,
15
- className: l(`${r}-input__label`, {
16
- [`${r}-skeleton`]: o
17
- }),
18
- children: n
19
- }
20
- ),
21
- /* @__PURE__ */ t(
22
- "textarea",
23
- {
24
- ...p,
25
- className: l(s, m, {
26
- [`${r}-skeleton`]: o
27
- }),
28
- id: e ?? a,
29
- rows: d,
30
- maxLength: c,
31
- name: i,
32
- ref: x,
33
- "data-testid": `text-area-${e ?? a}-input`
34
- }
35
- ),
36
- /* @__PURE__ */ t("div", { className: `${s}-resizer__icon`, children: /* @__PURE__ */ t(N, { icon: "Menu" }) })
4
+ import { px as a, useNormalizedInputProps as j } from "../../utils/index.js";
5
+ import y from "../Icon/Icon.js";
6
+ const z = I(
7
+ ({
8
+ className: o,
9
+ id: t,
10
+ isSkeletonLoading: d,
11
+ labelText: m,
12
+ maxLength: c = 3e3,
13
+ name: p,
14
+ rows: x = 2,
15
+ disabled: $,
16
+ warn: _,
17
+ warnText: N,
18
+ invalid: b,
19
+ invalidText: f,
20
+ ...u
21
+ }, v) => {
22
+ const i = `${a}-text-area`, r = A(), e = j({
23
+ disabled: $,
24
+ id: t ?? r,
25
+ invalid: b,
26
+ invalidText: f,
27
+ type: "text-area",
28
+ warn: _,
29
+ warnText: N
30
+ }), h = l(`${i}__wrapper`, {
31
+ [`${a}-text-area--disabled`]: e.disabled,
32
+ [`${a}-text-area--invalid`]: e.invalid,
33
+ [`${a}-text-area--warn`]: e.warn
34
+ });
35
+ return /* @__PURE__ */ n(w, { children: [
36
+ /* @__PURE__ */ n("div", { className: h, children: [
37
+ /* @__PURE__ */ s(
38
+ "label",
39
+ {
40
+ "data-testid": `text-area-${t ?? r}-label`,
41
+ htmlFor: t ?? r,
42
+ className: l(`${a}-text-area__label`, {
43
+ [`${a}-skeleton`]: d
44
+ }),
45
+ children: m
46
+ }
47
+ ),
48
+ /* @__PURE__ */ s(
49
+ "textarea",
50
+ {
51
+ ...u,
52
+ className: l(i, o, `${a}-text-area__input`, {
53
+ [`${a}-skeleton`]: d
54
+ }),
55
+ id: t ?? r,
56
+ rows: x,
57
+ maxLength: c,
58
+ name: p,
59
+ ref: v,
60
+ "data-testid": `text-area-${t ?? r}-input`,
61
+ disabled: e.disabled
62
+ }
63
+ ),
64
+ /* @__PURE__ */ s(y, { icon: "Menu", className: `${i}-resizer__icon` })
65
+ ] }),
66
+ /* @__PURE__ */ s("div", { children: e.validation ?? /* @__PURE__ */ s("div", { className: `${a}-text-area__validation`, id: e.invalidId }) })
37
67
  ] });
38
68
  }
39
69
  );
40
- _.displayName = "TextArea";
70
+ z.displayName = "TextArea";
41
71
  export {
42
- _ as default
72
+ z as default
43
73
  };
@@ -7,7 +7,7 @@ export default meta;
7
7
  export declare const Playground: {
8
8
  (props: TextAreaProps): import("react/jsx-runtime").JSX.Element;
9
9
  args: {
10
- children: string;
10
+ defaultValue: string;
11
11
  labelText: string;
12
12
  rows: number;
13
13
  isSkeletonLoading: boolean;
@@ -40,5 +40,30 @@ export declare const Playground: {
40
40
  type: string;
41
41
  };
42
42
  };
43
+ disabled: {
44
+ control: {
45
+ type: string;
46
+ };
47
+ };
48
+ invalid: {
49
+ control: {
50
+ type: string;
51
+ };
52
+ };
53
+ invalidText: {
54
+ control: {
55
+ type: string;
56
+ };
57
+ };
58
+ warn: {
59
+ control: {
60
+ type: string;
61
+ };
62
+ };
63
+ warnText: {
64
+ control: {
65
+ type: string;
66
+ };
67
+ };
43
68
  };
44
69
  };
@@ -47,6 +47,63 @@
47
47
  word-break: break-word;
48
48
  }
49
49
 
50
+ &__validation {
51
+ -webkit-box-orient: vertical;
52
+ display: -webkit-box;
53
+ -webkit-line-clamp: 2;
54
+ line-clamp: 2;
55
+ line-height: $spacing-md;
56
+ min-height: 2em;
57
+ overflow: hidden;
58
+ }
59
+
60
+ &--disabled {
61
+ color: $keyline-gray;
62
+ cursor: default;
63
+
64
+ .#{$px}-text-area__label,
65
+ .#{$px}-text-area__input {
66
+ color: inherit;
67
+ }
68
+ .#{$px}-text-area__label:hover,
69
+ .#{$px}-text-area__input:hover {
70
+ cursor: default;
71
+ }
72
+ }
73
+
74
+ &--invalid {
75
+ color: $error-red;
76
+
77
+ label {
78
+ color: $error-red;
79
+ }
80
+
81
+ .#{$px}-text-area__input,
82
+ .#{$px}-text-area__input::placeholder,
83
+ .#{$px}-input__validation {
84
+ color: $pure-black;
85
+ }
86
+
87
+ .#{$px}-text-area__input {
88
+ border: 1px solid $error-red;
89
+ box-shadow: inset 0 0 3px 3px $error-pink;
90
+
91
+ &:focus-within {
92
+ outline: 1px solid $error-red;
93
+ }
94
+ }
95
+ }
96
+
97
+ &--warn {
98
+ .#{$px}-text-area__label {
99
+ position: relative;
100
+ }
101
+ }
102
+
103
+ .#{$px}-input__validation {
104
+ animation: reveal 0.45s linear forwards;
105
+ }
106
+
50
107
  &::-webkit-resizer {
51
108
  bottom: 0;
52
109
  height: 28px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phillips/seldon",
3
- "version": "1.150.1",
3
+ "version": "1.151.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/PhillipsAuctionHouse/seldon"