@purpurds/text-field 5.10.1 → 5.11.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 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAU,MAAM,OAAO,CAAC;AAEjD,eAAO,MAAM,mBAAmB,aAAc,CAAC,KAAG,iBAAiB,CAAC,CAEnE,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAU,MAAM,OAAO,CAAC;AAEjD,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,CAAC,KAAG,gBAAgB,CAAC,CAAC,CAEnE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpurds/text-field",
3
- "version": "5.10.1",
3
+ "version": "5.11.1",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "./dist/text-field.cjs.js",
6
6
  "types": "./dist/text-field.d.ts",
@@ -15,36 +15,36 @@
15
15
  "source": "src/text-field.tsx",
16
16
  "dependencies": {
17
17
  "classnames": "~2.5.0",
18
- "@purpurds/field-error-text": "5.10.1",
19
- "@purpurds/button": "5.10.1",
20
- "@purpurds/field-helper-text": "5.10.1",
21
- "@purpurds/icon": "5.10.1",
22
- "@purpurds/label": "5.10.1",
23
- "@purpurds/spinner": "5.10.1",
24
- "@purpurds/tokens": "5.10.1"
18
+ "@purpurds/button": "5.11.1",
19
+ "@purpurds/field-error-text": "5.11.1",
20
+ "@purpurds/field-helper-text": "5.11.1",
21
+ "@purpurds/icon": "5.11.1",
22
+ "@purpurds/label": "5.11.1",
23
+ "@purpurds/tokens": "5.11.1",
24
+ "@purpurds/spinner": "5.11.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@rushstack/eslint-patch": "~1.10.0",
28
- "@storybook/blocks": "~7.6.0",
29
- "@storybook/client-api": "~7.6.0",
30
- "@storybook/react": "~7.6.0",
28
+ "@storybook/preview-api": "^8.2.6",
29
+ "@storybook/react": "^8.2.6",
31
30
  "@telia/base-rig": "~8.2.0",
32
31
  "@telia/react-rig": "~3.2.0",
33
32
  "@testing-library/dom": "~9.3.3",
34
33
  "@testing-library/jest-dom": "~6.4.0",
35
34
  "@testing-library/react": "~14.3.0",
36
35
  "@types/node": "20.12.12",
37
- "@types/react-dom": "~18.3.0",
38
- "@types/react": "~18.3.0",
36
+ "@types/react-dom": "^18.3.0",
37
+ "@types/react": "^18.3.3",
39
38
  "eslint-plugin-testing-library": "~6.2.0",
40
- "eslint": "~8.57.0",
39
+ "eslint": "^8.57.0",
41
40
  "jsdom": "~22.1.0",
42
41
  "lint-staged": "~10.5.3",
43
42
  "prettier": "~2.8.8",
44
- "react-dom": "~18.3.0",
45
- "react": "~18.3.0",
46
- "typescript": "~5.4.2",
47
- "vite": "~5.2.2",
43
+ "react-dom": "^18.3.1",
44
+ "react": "^18.3.1",
45
+ "storybook": "^8.2.6",
46
+ "typescript": "^5.5.4",
47
+ "vite": "5.3.4",
48
48
  "vitest": "~1.5.0",
49
49
  "@purpurds/component-rig": "1.0.0"
50
50
  },
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { useArgs } from "@storybook/client-api";
2
+ import { useArgs } from "@storybook/preview-api";
3
3
  import type { Meta, StoryObj } from "@storybook/react";
4
4
 
5
5
  import "@purpurds/label/styles";
@@ -10,15 +10,25 @@ import "@purpurds/icon/styles";
10
10
  import "@purpurds/spinner/styles";
11
11
  import { TextField } from "./text-field";
12
12
 
13
- const meta: Meta<typeof TextField> = {
13
+ const meta = {
14
14
  title: "Inputs/TextField",
15
15
  component: TextField,
16
- };
17
-
18
- export default meta;
19
- type Story = StoryObj<typeof TextField>;
20
-
21
- export const Showcase: Story = {
16
+ parameters: {
17
+ docs: {
18
+ description: {
19
+ component: `Except for the props below, [all "native" input attributs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) are also valid props. The only exceptions are:
20
+ - \`type\`- Restricted to \`"email" | "number" | "password" | "search" | "tel" | "text"\`
21
+ -\`id\`- Required`,
22
+ },
23
+ },
24
+ design: [
25
+ {
26
+ name: "TextField",
27
+ type: "figma",
28
+ url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?node-id=1528%3A1886",
29
+ },
30
+ ],
31
+ },
22
32
  args: {
23
33
  value: "Text field",
24
34
  label: "Text field label",
@@ -34,20 +44,16 @@ export const Showcase: Story = {
34
44
  },
35
45
  argTypes: {
36
46
  onChange: { action: "inputChange", table: { disable: true } },
37
- type: { options: ["email", "number", "password", "search", "tel", "text"], control: "select" },
47
+ type: {
48
+ control: "select",
49
+ options: ["email", "number", "password", "search", "tel", "text"],
50
+ table: { type: { summary: '"email" | "number" | "password" | "search" | "tel" | "text"' } },
51
+ },
38
52
  startAdornment: { table: { disable: true } },
39
53
  endAdornment: { table: { disable: true } },
40
54
  afterField: { table: { disable: true } },
41
55
  },
42
- parameters: {
43
- design: [
44
- {
45
- name: "TextField",
46
- type: "figma",
47
- url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?node-id=1528%3A1886",
48
- },
49
- ],
50
- },
56
+
51
57
  decorators: [
52
58
  (Story) => (
53
59
  <div style={{ maxWidth: "18.5rem" }}>
@@ -69,4 +75,9 @@ export const Showcase: Story = {
69
75
  />
70
76
  );
71
77
  },
72
- };
78
+ } satisfies Meta<typeof TextField>;
79
+
80
+ export default meta;
81
+ type Story = StoryObj<typeof TextField>;
82
+
83
+ export const Showcase: Story = {};
@@ -3,7 +3,10 @@ import React, {
3
3
  ForwardedRef,
4
4
  forwardRef,
5
5
  HTMLInputTypeAttribute,
6
+ isValidElement,
7
+ ReactElement,
6
8
  ReactNode,
9
+ ReactPortal,
7
10
  useId,
8
11
  } from "react";
9
12
  import { Button } from "@purpurds/button";
@@ -256,3 +259,17 @@ const TextFieldComponent = (
256
259
 
257
260
  export const TextField = forwardRef(TextFieldComponent);
258
261
  TextField.displayName = "TextField";
262
+
263
+ export const isTextField = (
264
+ child:
265
+ | ReactElement
266
+ | Iterable<ReactNode>
267
+ | ReactPortal
268
+ | string
269
+ | number
270
+ | boolean
271
+ | null
272
+ | undefined
273
+ ): child is ReactElement<TextFieldProps> =>
274
+ isValidElement<TextFieldProps>(child) &&
275
+ (child.type as any).displayName === TextField.displayName; // eslint-disable-line @typescript-eslint/no-explicit-any
package/readme.mdx DELETED
@@ -1,54 +0,0 @@
1
- import { Meta, Stories, ArgTypes, Primary, Subtitle } from "@storybook/blocks";
2
-
3
- import * as TextFieldStories from "./src/text-field.stories";
4
- import packageInfo from "./package.json";
5
-
6
- <Meta name="Docs" title="Components/TextField" of={TextFieldStories} />
7
-
8
- # TextField
9
-
10
- <Subtitle>Version {packageInfo.version}</Subtitle>
11
-
12
- ### Showcase
13
-
14
- <Primary />
15
-
16
- ### Properties
17
-
18
- Except for the props below, [all "native" input attributs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) are also valid props. The only exceptions are:
19
-
20
- - `type` - Restricted to `"email" | "number" | "password" | "search" | "tel" | "text"`
21
- - `id` - Required
22
-
23
- <ArgTypes />
24
-
25
- ### Installation
26
-
27
- #### Via NPM
28
-
29
- Add the dependency to your consumer app like `"@purpurds/purpur": "^x.y.z"`
30
-
31
- In MyApp.tsx
32
-
33
- ```tsx
34
- import "@purpurds/purpur/styles";
35
- ```
36
-
37
- In MyComponent.tsx
38
-
39
- ```tsx
40
- import { TextField } from "@purpurds/purpur";
41
-
42
- export const MyComponent = () => {
43
- const [value, setValue] = useState("");
44
-
45
- return (
46
- <TextField
47
- value={value}
48
- onChange={setValue}
49
- onClear={() => setValue("")}
50
- clearButtonAllyLabel="Clear"
51
- />
52
- );
53
- };
54
- ```