@uva-glass/component-library 1.28.0 → 1.29.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.
@@ -1 +1 @@
1
- ._input-field_16tae_1{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:1px solid;border-radius:.5rem;color:var(--color-black);font-family:inherit;font-size:inherit;height:2.75rem;margin:0;padding:0 .5rem;text-align:inherit}._input-field--large_16tae_15{height:3rem}._input-field_16tae_1:disabled{color:var(--color-scarpa-flow)}
1
+ ._input-field-wrapper_hh88t_1{align-items:center;display:flex;position:relative}._input-field_hh88t_1{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:1px solid;border-radius:.5rem;color:var(--color-black);flex:1;font-family:inherit;font-size:inherit;height:2.75rem;margin:0;padding:0 1rem;text-align:inherit}._input-field--large_hh88t_22{height:3rem}._input-field_hh88t_1:disabled{color:var(--color-scarpa-flow)}._input-field__clear-button_hh88t_30{background:none;border:none;cursor:pointer;max-height:1.5rem;padding:0 1rem 0 .5rem;position:absolute;right:0}
@@ -1,8 +1,9 @@
1
- import { InputHTMLAttributes } from 'react';
1
+ import { InputHTMLAttributes, ReactNode } from 'react';
2
2
 
3
3
  export interface InputFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'className' | 'style'> {
4
4
  variant?: 'large';
5
5
  type?: 'text' | 'search' | 'password' | 'email';
6
6
  id: string;
7
+ clearTrigger?: ReactNode;
7
8
  }
8
9
  export declare const InputField: import('react').ForwardRefExoticComponent<InputFieldProps & import('react').RefAttributes<HTMLInputElement>>;
@@ -1,25 +1,54 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { forwardRef as o } from "react";
3
- import { c as a } from "../../clsx-DB4S2d7J.js";
4
- import '../../assets/InputField.css';const e = {
5
- "input-field": "_input-field_16tae_1",
6
- "input-field--large": "_input-field--large_16tae_15"
7
- }, m = o(
8
- ({ autoComplete: t = "off", id: i, variant: r, type: f = "text", ...l }, p) => /* @__PURE__ */ n(
9
- "input",
10
- {
11
- ...l,
12
- autoComplete: t,
13
- ref: p,
14
- id: i,
15
- className: a(e["input-field"], {
16
- [e["input-field--large"]]: r === "large"
17
- }),
18
- type: f
19
- }
20
- )
1
+ import { jsxs as b, jsx as a } from "react/jsx-runtime";
2
+ import { forwardRef as x, useState as s, useRef as C, useEffect as v } from "react";
3
+ import { c as y } from "../../clsx-DB4S2d7J.js";
4
+ import '../../assets/InputField.css';const n = {
5
+ "input-field-wrapper": "_input-field-wrapper_hh88t_1",
6
+ "input-field": "_input-field_hh88t_1",
7
+ "input-field--large": "_input-field--large_hh88t_22",
8
+ "input-field__clear-button": "_input-field__clear-button_hh88t_30"
9
+ }, j = x(
10
+ ({ autoComplete: c = "off", id: u, variant: o, type: p = "text", clearTrigger: i, ...f }, t) => {
11
+ const [e, r] = s(""), [h, _] = s(0), l = C(null);
12
+ v(() => {
13
+ l.current && _(l.current.offsetWidth);
14
+ }, [e]);
15
+ const d = () => {
16
+ r(""), t && "current" in t && t.current && t.current.focus();
17
+ }, m = (g) => {
18
+ r(g.target.value);
19
+ };
20
+ return /* @__PURE__ */ b("div", { className: n["input-field-wrapper"], children: [
21
+ /* @__PURE__ */ a(
22
+ "input",
23
+ {
24
+ ...f,
25
+ autoComplete: c,
26
+ ref: t,
27
+ id: u,
28
+ className: y(n["input-field"], {
29
+ [n["input-field--large"]]: o === "large"
30
+ }),
31
+ type: p,
32
+ value: e,
33
+ onChange: m,
34
+ style: { paddingRight: e && i ? h : void 0 }
35
+ }
36
+ ),
37
+ e && i && /* @__PURE__ */ a(
38
+ "button",
39
+ {
40
+ type: "button",
41
+ className: n["input-field__clear-button"],
42
+ onClick: d,
43
+ ref: l,
44
+ "aria-label": `clear trigger for ${u}`,
45
+ children: i
46
+ }
47
+ )
48
+ ] });
49
+ }
21
50
  );
22
51
  export {
23
- m as InputField
52
+ j as InputField
24
53
  };
25
54
  //# sourceMappingURL=InputField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InputField.js","sources":["../../../src/components/InputField/InputField.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport { clsx } from 'clsx';\n\nimport type { InputHTMLAttributes } from 'react';\n\nimport styles from './InputField.module.css';\n\nexport interface InputFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'className' | 'style'> {\n variant?: 'large';\n type?: 'text' | 'search' | 'password' | 'email';\n id: string;\n}\n\nexport const InputField = forwardRef<HTMLInputElement, InputFieldProps>(\n ({ autoComplete = 'off', id, variant, type = 'text', ...restProps }: InputFieldProps, forwardedRef) => {\n return (\n <input\n {...restProps}\n autoComplete={autoComplete}\n ref={forwardedRef}\n id={id}\n className={clsx(styles['input-field'], {\n [styles['input-field--large']]: variant === 'large',\n })}\n type={type}\n />\n );\n }\n);\n"],"names":["InputField","forwardRef","autoComplete","id","variant","type","restProps","forwardedRef","jsx","clsx","styles"],"mappings":";;;;;;GAaaA,IAAaC;AAAA,EACxB,CAAC,EAAE,cAAAC,IAAe,OAAO,IAAAC,GAAI,SAAAC,GAAS,MAAAC,IAAO,QAAQ,GAAGC,EAAU,GAAoBC,MAElF,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAGF;AAAA,MACJ,cAAAJ;AAAA,MACA,KAAKK;AAAA,MACL,IAAAJ;AAAA,MACA,WAAWM,EAAKC,EAAO,aAAa,GAAG;AAAA,QACrC,CAACA,EAAO,oBAAoB,CAAC,GAAGN,MAAY;AAAA,MAAA,CAC7C;AAAA,MACD,MAAAC;AAAA,IAAA;AAAA,EAAA;AAIR;"}
1
+ {"version":3,"file":"InputField.js","sources":["../../../src/components/InputField/InputField.tsx"],"sourcesContent":["import { forwardRef, useState, useEffect, useRef } from 'react';\nimport { clsx } from 'clsx';\n\nimport type { InputHTMLAttributes, ReactNode } from 'react';\n\nimport styles from './InputField.module.css';\n\nexport interface InputFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'className' | 'style'> {\n variant?: 'large';\n type?: 'text' | 'search' | 'password' | 'email';\n id: string;\n clearTrigger?: ReactNode;\n}\n\nexport const InputField = forwardRef<HTMLInputElement, InputFieldProps>(\n ({ autoComplete = 'off', id, variant, type = 'text', clearTrigger, ...restProps }: InputFieldProps, forwardedRef) => {\n const [value, setValue] = useState<string>('');\n const [clearButtonWidth, setClearButtonWidth] = useState<number>(0);\n const clearButtonRef = useRef<HTMLButtonElement>(null);\n\n useEffect(() => {\n if (clearButtonRef.current) {\n setClearButtonWidth(clearButtonRef.current.offsetWidth);\n }\n }, [value]);\n\n const handleClear = () => {\n setValue('');\n if (forwardedRef && 'current' in forwardedRef && forwardedRef.current) {\n forwardedRef.current.focus();\n }\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n setValue(event.target.value);\n };\n\n return (\n <div className={styles['input-field-wrapper']}>\n <input\n {...restProps}\n autoComplete={autoComplete}\n ref={forwardedRef}\n id={id}\n className={clsx(styles['input-field'], {\n [styles['input-field--large']]: variant === 'large',\n })}\n type={type}\n value={value}\n onChange={handleChange}\n style={{ paddingRight: value && clearTrigger ? clearButtonWidth : undefined }}\n />\n {value && clearTrigger && (\n <button\n type=\"button\"\n className={styles['input-field__clear-button']}\n onClick={handleClear}\n ref={clearButtonRef}\n aria-label={`clear trigger for ${id}`}\n >\n {clearTrigger}\n </button>\n )}\n </div>\n );\n }\n);\n"],"names":["InputField","forwardRef","autoComplete","id","variant","type","clearTrigger","restProps","forwardedRef","value","setValue","useState","clearButtonWidth","setClearButtonWidth","clearButtonRef","useRef","useEffect","handleClear","handleChange","event","jsxs","styles","jsx","clsx"],"mappings":";;;;;;;;GAcaA,IAAaC;AAAA,EACxB,CAAC,EAAE,cAAAC,IAAe,OAAO,IAAAC,GAAI,SAAAC,GAAS,MAAAC,IAAO,QAAQ,cAAAC,GAAc,GAAGC,EAAU,GAAoBC,MAAiB;AACnH,UAAM,CAACC,GAAOC,CAAQ,IAAIC,EAAiB,EAAE,GACvC,CAACC,GAAkBC,CAAmB,IAAIF,EAAiB,CAAC,GAC5DG,IAAiBC,EAA0B,IAAI;AAErD,IAAAC,EAAU,MAAM;AACd,MAAIF,EAAe,WACGD,EAAAC,EAAe,QAAQ,WAAW;AAAA,IACxD,GACC,CAACL,CAAK,CAAC;AAEV,UAAMQ,IAAc,MAAM;AACxB,MAAAP,EAAS,EAAE,GACPF,KAAgB,aAAaA,KAAgBA,EAAa,WAC5DA,EAAa,QAAQ;IACvB,GAGIU,IAAe,CAACC,MAA+C;AAC1D,MAAAT,EAAAS,EAAM,OAAO,KAAK;AAAA,IAAA;AAG7B,WACG,gBAAAC,EAAA,OAAA,EAAI,WAAWC,EAAO,qBAAqB,GAC1C,UAAA;AAAA,MAAA,gBAAAC;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAGf;AAAA,UACJ,cAAAL;AAAA,UACA,KAAKM;AAAA,UACL,IAAAL;AAAA,UACA,WAAWoB,EAAKF,EAAO,aAAa,GAAG;AAAA,YACrC,CAACA,EAAO,oBAAoB,CAAC,GAAGjB,MAAY;AAAA,UAAA,CAC7C;AAAA,UACD,MAAAC;AAAA,UACA,OAAAI;AAAA,UACA,UAAUS;AAAA,UACV,OAAO,EAAE,cAAcT,KAASH,IAAeM,IAAmB,OAAU;AAAA,QAAA;AAAA,MAC9E;AAAA,MACCH,KAASH,KACR,gBAAAgB;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAWD,EAAO,2BAA2B;AAAA,UAC7C,SAASJ;AAAA,UACT,KAAKH;AAAA,UACL,cAAY,qBAAqBX,CAAE;AAAA,UAElC,UAAAG;AAAA,QAAA;AAAA,MACH;AAAA,IAEJ,EAAA,CAAA;AAAA,EAEJ;AACF;"}
@@ -3,3 +3,5 @@ import { InputFieldProps } from './InputField';
3
3
  declare const _default: import('@storybook/types').ComponentAnnotations<import('@storybook/react').ReactRenderer, InputFieldProps>;
4
4
  export default _default;
5
5
  export declare const InputFieldExample: import('@storybook/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, InputFieldProps>;
6
+ export declare const WithStringClearTrigger: import('@storybook/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, InputFieldProps>;
7
+ export declare const WithIconClearTrigger: import('@storybook/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, InputFieldProps>;
@@ -1,11 +1,20 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { InputField as o } from "./InputField.js";
3
- import '../../assets/InputField2.css';const a = (t) => {
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { useRef as a } from "react";
3
+ import { InputField as n } from "./InputField.js";
4
+ import { Container as s } from "../storyComponents/Container/Container.js";
5
+ import { Icon as p } from "../Icon/Icon.js";
6
+ import "../Button/Button.js";
7
+ import "../OverlayCloseButton/OverlayCloseButton.js";
8
+ import "../IconButton/IconButton.js";
9
+ import "../Input/Input.js";
10
+ import "../SelectListbox/SelectListbox.js";
11
+ import "../SelectListbox/SelectProvider.js";
12
+ const l = (t) => {
4
13
  const r = t.variant ?? [];
5
14
  return { ...t, variant: r.toString() };
6
- }, d = {
15
+ }, A = {
7
16
  title: "Atoms/InputField",
8
- component: o,
17
+ component: n,
9
18
  argTypes: {
10
19
  variant: {
11
20
  options: ["large"],
@@ -24,14 +33,31 @@ import '../../assets/InputField2.css';const a = (t) => {
24
33
  }
25
34
  }
26
35
  }
27
- }, i = (t) => /* @__PURE__ */ e("div", { className: "form", children: /* @__PURE__ */ e("div", { className: "form-field", children: /* @__PURE__ */ e(o, { ...a(t) }) }) }), n = i.bind({});
28
- n.args = {
36
+ }, e = (t) => {
37
+ const r = a(null);
38
+ return /* @__PURE__ */ o(s, { children: /* @__PURE__ */ o(n, { ...l(t), ref: r }) });
39
+ }, i = {
29
40
  type: "text",
30
41
  variant: void 0,
31
42
  id: "4f9ca77d"
43
+ }, m = e.bind({});
44
+ m.args = {
45
+ ...i
46
+ };
47
+ const c = e.bind({});
48
+ c.args = {
49
+ ...i,
50
+ clearTrigger: "Clear"
51
+ };
52
+ const d = e.bind({});
53
+ d.args = {
54
+ ...i,
55
+ clearTrigger: /* @__PURE__ */ o(p, { name: "Cross" })
32
56
  };
33
57
  export {
34
- n as InputFieldExample,
35
- d as default
58
+ m as InputFieldExample,
59
+ d as WithIconClearTrigger,
60
+ c as WithStringClearTrigger,
61
+ A as default
36
62
  };
37
63
  //# sourceMappingURL=InputField.stories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InputField.stories.js","sources":["../../../src/components/InputField/InputField.stories.tsx"],"sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport type { InputFieldProps } from './InputField';\n\nimport './InputField.stories.css';\n\nimport { InputField } from './InputField';\n\nconst transformArgs = (args: InputFieldProps) => {\n // args.variant is provided as an array because the control type is set to a checkbox. So this transforms the selected value into its proper value: a string\n const variantArray = (args.variant as unknown as string[]) ?? [];\n return { ...args, ...{ variant: variantArray.toString() } } as InputFieldProps;\n};\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n title: 'Atoms/InputField',\n component: InputField,\n argTypes: {\n variant: {\n options: ['large'],\n control: 'check',\n },\n type: {\n control: 'radio',\n options: ['text', 'search', 'password', 'email'],\n },\n id: {\n control: 'text',\n },\n autoComplete: {\n table: {\n disable: true,\n },\n },\n },\n} as Meta<InputFieldProps>;\n\nconst Template: StoryFn<InputFieldProps> = (args) => (\n <div className=\"form\">\n <div className=\"form-field\">\n <InputField {...transformArgs(args)} />\n </div>\n </div>\n);\n\nexport const InputFieldExample = Template.bind({});\nInputFieldExample.args = {\n type: 'text',\n variant: undefined,\n id: '4f9ca77d',\n};\n"],"names":["transformArgs","args","variantArray","InputField_stories","InputField","Template","jsx","InputFieldExample"],"mappings":";;AAOA,MAAMA,IAAgB,CAACC,MAA0B;AAEzC,QAAAC,IAAgBD,EAAK,WAAmC;AACvD,SAAA,EAAE,GAAGA,GAAW,SAASC,EAAa,SAAS;AACxD,GAGeC,IAAA;AAAA,EACb,OAAO;AAAA,EACP,WAAWC;AAAA,EACX,UAAU;AAAA,IACR,SAAS;AAAA,MACP,SAAS,CAAC,OAAO;AAAA,MACjB,SAAS;AAAA,IACX;AAAA,IACA,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,SAAS,CAAC,QAAQ,UAAU,YAAY,OAAO;AAAA,IACjD;AAAA,IACA,IAAI;AAAA,MACF,SAAS;AAAA,IACX;AAAA,IACA,cAAc;AAAA,MACZ,OAAO;AAAA,QACL,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF,GAEMC,IAAqC,CAACJ,wBACzC,OAAI,EAAA,WAAU,QACb,UAAC,gBAAAK,EAAA,OAAA,EAAI,WAAU,cACb,4BAACF,GAAY,EAAA,GAAGJ,EAAcC,CAAI,EAAG,CAAA,GACvC,EACF,CAAA,GAGWM,IAAoBF,EAAS,KAAK,EAAE;AACjDE,EAAkB,OAAO;AAAA,EACvB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,IAAI;AACN;"}
1
+ {"version":3,"file":"InputField.stories.js","sources":["../../../src/components/InputField/InputField.stories.tsx"],"sourcesContent":["import { useRef } from 'react';\n\nimport type { Meta, StoryFn } from '@storybook/react';\nimport type { InputFieldProps } from './InputField';\n\nimport { InputField } from './InputField';\n\nimport { Container } from 'components/storyComponents/Container';\nimport { Icon } from 'components';\n\nconst transformArgs = (args: InputFieldProps) => {\n // args.variant is provided as an array because the control type is set to a checkbox. So this transforms the selected value into its proper value: a string\n const variantArray = (args.variant as unknown as string[]) ?? [];\n return { ...args, ...{ variant: variantArray.toString() } } as InputFieldProps;\n};\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n title: 'Atoms/InputField',\n component: InputField,\n argTypes: {\n variant: {\n options: ['large'],\n control: 'check',\n },\n type: {\n control: 'radio',\n options: ['text', 'search', 'password', 'email'],\n },\n id: {\n control: 'text',\n },\n autoComplete: {\n table: {\n disable: true,\n },\n },\n },\n} as Meta<InputFieldProps>;\n\nconst Template: StoryFn<InputFieldProps> = (args) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n return (\n <Container>\n <InputField {...transformArgs(args)} ref={inputRef} />\n </Container>\n );\n};\n\nconst defaultArgs: Partial<InputFieldProps> = {\n type: 'text',\n variant: undefined,\n id: '4f9ca77d',\n};\n\nexport const InputFieldExample = Template.bind({});\nInputFieldExample.args = {\n ...defaultArgs,\n};\n\nexport const WithStringClearTrigger = Template.bind({});\nWithStringClearTrigger.args = {\n ...defaultArgs,\n clearTrigger: 'Clear',\n};\n\nexport const WithIconClearTrigger = Template.bind({});\nWithIconClearTrigger.args = {\n ...defaultArgs,\n clearTrigger: <Icon name=\"Cross\" />,\n};\n"],"names":["transformArgs","args","variantArray","InputField_stories","InputField","Template","inputRef","useRef","jsx","Container","defaultArgs","InputFieldExample","WithStringClearTrigger","WithIconClearTrigger","Icon"],"mappings":";;;;;;;;;;;AAUA,MAAMA,IAAgB,CAACC,MAA0B;AAEzC,QAAAC,IAAgBD,EAAK,WAAmC;AACvD,SAAA,EAAE,GAAGA,GAAW,SAASC,EAAa,SAAS;AACxD,GAGeC,IAAA;AAAA,EACb,OAAO;AAAA,EACP,WAAWC;AAAA,EACX,UAAU;AAAA,IACR,SAAS;AAAA,MACP,SAAS,CAAC,OAAO;AAAA,MACjB,SAAS;AAAA,IACX;AAAA,IACA,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,SAAS,CAAC,QAAQ,UAAU,YAAY,OAAO;AAAA,IACjD;AAAA,IACA,IAAI;AAAA,MACF,SAAS;AAAA,IACX;AAAA,IACA,cAAc;AAAA,MACZ,OAAO;AAAA,QACL,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF,GAEMC,IAAqC,CAACJ,MAAS;AAC7C,QAAAK,IAAWC,EAAyB,IAAI;AAG5C,SAAA,gBAAAC,EAACC,GACC,EAAA,UAAA,gBAAAD,EAACJ,GAAY,EAAA,GAAGJ,EAAcC,CAAI,GAAG,KAAKK,EAAU,CAAA,EACtD,CAAA;AAEJ,GAEMI,IAAwC;AAAA,EAC5C,MAAM;AAAA,EACN,SAAS;AAAA,EACT,IAAI;AACN,GAEaC,IAAoBN,EAAS,KAAK,EAAE;AACjDM,EAAkB,OAAO;AAAA,EACvB,GAAGD;AACL;AAEO,MAAME,IAAyBP,EAAS,KAAK,EAAE;AACtDO,EAAuB,OAAO;AAAA,EAC5B,GAAGF;AAAA,EACH,cAAc;AAChB;AAEO,MAAMG,IAAuBR,EAAS,KAAK,EAAE;AACpDQ,EAAqB,OAAO;AAAA,EAC1B,GAAGH;AAAA,EACH,cAAc,gBAAAF,EAACM,GAAK,EAAA,MAAK,QAAQ,CAAA;AACnC;"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uva-glass/component-library",
3
3
  "author": "Team Glass - Frontend vrienden",
4
4
  "private": false,
5
- "version": "1.28.0",
5
+ "version": "1.29.0",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
@@ -58,8 +58,8 @@
58
58
  "@types/node": "^20.14.2",
59
59
  "@types/react": "^18.3.3",
60
60
  "@types/react-dom": "^18.3.0",
61
- "@typescript-eslint/eslint-plugin": "^7.12.0",
62
- "@typescript-eslint/parser": "^7.12.0",
61
+ "@typescript-eslint/eslint-plugin": "^7.13.0",
62
+ "@typescript-eslint/parser": "^7.13.0",
63
63
  "@uva-glass/eslint-config": "^1.2.0",
64
64
  "@uva-glass/stylelint-config": "^1.1.0",
65
65
  "@vitejs/plugin-react": "^4.3.1",
@@ -1 +0,0 @@
1
- .form{width:20%}.form-field{display:flex;flex-direction:column;gap:.5rem 1rem}