math-main-components 0.0.207 → 0.0.209

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.
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ import type { StoryObj } from '@storybook/react';
3
+ import { Dropdown } from '.';
4
+ declare const meta: {
5
+ title: string;
6
+ component: <Type extends string>({ options, unit, onChange, ...props }: {
7
+ options: Dropdown<Type>[];
8
+ onChange?: ((value: Type) => void) | undefined;
9
+ unit?: string | undefined;
10
+ } & import("react").InputHTMLAttributes<HTMLInputElement>) => import("react").JSX.Element;
11
+ parameters: {
12
+ layout: string;
13
+ };
14
+ tags: string[];
15
+ };
16
+ export default meta;
17
+ type Story = StoryObj<typeof meta>;
18
+ export declare const Primary: Story;
@@ -0,0 +1,10 @@
1
+ import React, { InputHTMLAttributes } from 'react';
2
+ export type Dropdown<Type> = {
3
+ value: Type;
4
+ label: string;
5
+ };
6
+ export declare const Dropdown: <Type extends string>({ options, unit, onChange, ...props }: {
7
+ options: Dropdown<Type>[];
8
+ onChange?: ((value: Type) => void) | undefined;
9
+ unit?: string | undefined;
10
+ } & React.InputHTMLAttributes<HTMLInputElement>) => React.JSX.Element;
@@ -1,9 +1,11 @@
1
- import React from 'react';
2
- export declare function InputMail({ id, placeholder, title, name, width, available, ...props }: {
1
+ import React, { ChangeEvent } from 'react';
2
+ export declare function InputMail({ id, placeholder, title, name, width, available, defaultValue, onInput, ...props }: {
3
3
  id: string;
4
4
  placeholder?: string;
5
5
  title?: string;
6
6
  name?: string;
7
7
  width?: string;
8
8
  available?: boolean;
9
+ defaultValue?: string;
10
+ onInput?: (event: ChangeEvent<HTMLInputElement>) => void;
9
11
  } & React.InputHTMLAttributes<HTMLInputElement>): React.JSX.Element;
package/dist/index.cjs.js CHANGED
@@ -9611,11 +9611,15 @@ var css_248z$k = ".styles-module_input__-GKhx {\n padding: 14px 20px;\n font-s
9611
9611
  var styles$k = {"input":"styles-module_input__-GKhx","not_available":"styles-module_not_available__XD1kR","container":"styles-module_container__--4rV","label":"styles-module_label__mGzwP","label_text":"styles-module_label_text__d0eMb","with_title":"styles-module_with_title__CGOEs","valid":"styles-module_valid__uj8g-"};
9612
9612
  styleInject(css_248z$k);
9613
9613
 
9614
- function InputMail({ id, placeholder = "E-Mail-Adresse", title = "E-Mail-Adresse", name = "email", width = "100%", available = true, ...props }) {
9615
- const [value, setValue] = React.useState("");
9614
+ function InputMail({ id, placeholder = "E-Mail-Adresse", title = "E-Mail-Adresse", name = "email", width = "100%", available = true, defaultValue = "", onInput = () => { }, ...props }) {
9615
+ const [value, setValue] = React.useState(defaultValue);
9616
+ React.useEffect(() => setValue(defaultValue), [defaultValue]);
9616
9617
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
9617
9618
  React__default["default"].createElement("div", { className: styles$k.container, style: { width: width } },
9618
- React__default["default"].createElement("input", { className: `${styles$k.input} ${title != undefined ? styles$k.with_title : styles$k.without_title} ${value.length > 0 ? styles$k.valid : styles$k.not_valid} ${available ? styles$k.available : styles$k.not_available}`, name: name, placeholder: placeholder, type: "email", onInput: (event) => setValue(event.target.value), id: id, ...props }),
9619
+ React__default["default"].createElement("input", { className: `${styles$k.input} ${title != undefined ? styles$k.with_title : styles$k.without_title} ${value.length > 0 ? styles$k.valid : styles$k.not_valid} ${available ? styles$k.available : styles$k.not_available}`, name: name, placeholder: placeholder, type: "email", id: id, onInput: (event) => {
9620
+ setValue(event.target.value);
9621
+ onInput(event);
9622
+ }, ...props }),
9619
9623
  React__default["default"].createElement("label", { htmlFor: "text", className: styles$k.label },
9620
9624
  React__default["default"].createElement("span", { className: styles$k.label_text }, title)))));
9621
9625
  }
@@ -9770,8 +9774,9 @@ var css_248z$f = ".styles-module_container__zcXGF {\n display: flex;\n width:
9770
9774
  var styles$f = {"container":"styles-module_container__zcXGF","input":"styles-module_input__Tpth8","not_available":"styles-module_not_available__CRXjB","label":"styles-module_label__appHO","label_text":"styles-module_label_text__-sKjY","with_title":"styles-module_with_title__L3eGj","valid":"styles-module_valid__zWcOz"};
9771
9775
  styleInject(css_248z$f);
9772
9776
 
9773
- function InputText({ id, title, name, placeholder = "", defaultValue = "", autoFocus = false, type = "text", width = "100%", marginBottom, autoComplete = "off", available = true, onInput = (event) => { } }) {
9777
+ function InputText({ id, title, name, placeholder = "", defaultValue = "", autoFocus = false, type = "text", width = "100%", marginBottom, autoComplete = "off", available = true, onInput = () => { } }) {
9774
9778
  const [value, setValue] = React.useState(defaultValue);
9779
+ React.useEffect(() => setValue(defaultValue), [defaultValue]);
9775
9780
  const inputElement = React.useCallback((element) => {
9776
9781
  if (element && autoFocus)
9777
9782
  element.focus();
@@ -9780,8 +9785,7 @@ function InputText({ id, title, name, placeholder = "", defaultValue = "", autoF
9780
9785
  React__default["default"].createElement("div", { className: styles$f.container, style: { width, marginBottom } },
9781
9786
  React__default["default"].createElement("input", { className: `${styles$f.input} ${title != undefined ? styles$f.with_title : styles$f.without_title} ${value.length > 0 || defaultValue.length > 0 ? styles$f.valid : styles$f.not_valid} ${available ? styles$f.available : styles$f.not_available}`, name: name, id: id, type: type, placeholder: placeholder, autoComplete: autoComplete, ref: inputElement, defaultValue: defaultValue, onInput: (event) => {
9782
9787
  setValue(event.target.value);
9783
- if (onInput)
9784
- onInput(event);
9788
+ onInput(event);
9785
9789
  } }),
9786
9790
  React__default["default"].createElement("label", { htmlFor: "text", className: styles$f.label },
9787
9791
  React__default["default"].createElement("span", { className: styles$f.label_text }, title)))));
package/dist/index.esm.js CHANGED
@@ -9585,11 +9585,15 @@ var css_248z$k = ".styles-module_input__-GKhx {\n padding: 14px 20px;\n font-s
9585
9585
  var styles$k = {"input":"styles-module_input__-GKhx","not_available":"styles-module_not_available__XD1kR","container":"styles-module_container__--4rV","label":"styles-module_label__mGzwP","label_text":"styles-module_label_text__d0eMb","with_title":"styles-module_with_title__CGOEs","valid":"styles-module_valid__uj8g-"};
9586
9586
  styleInject(css_248z$k);
9587
9587
 
9588
- function InputMail({ id, placeholder = "E-Mail-Adresse", title = "E-Mail-Adresse", name = "email", width = "100%", available = true, ...props }) {
9589
- const [value, setValue] = useState("");
9588
+ function InputMail({ id, placeholder = "E-Mail-Adresse", title = "E-Mail-Adresse", name = "email", width = "100%", available = true, defaultValue = "", onInput = () => { }, ...props }) {
9589
+ const [value, setValue] = useState(defaultValue);
9590
+ useEffect(() => setValue(defaultValue), [defaultValue]);
9590
9591
  return (React__default.createElement(React__default.Fragment, null,
9591
9592
  React__default.createElement("div", { className: styles$k.container, style: { width: width } },
9592
- React__default.createElement("input", { className: `${styles$k.input} ${title != undefined ? styles$k.with_title : styles$k.without_title} ${value.length > 0 ? styles$k.valid : styles$k.not_valid} ${available ? styles$k.available : styles$k.not_available}`, name: name, placeholder: placeholder, type: "email", onInput: (event) => setValue(event.target.value), id: id, ...props }),
9593
+ React__default.createElement("input", { className: `${styles$k.input} ${title != undefined ? styles$k.with_title : styles$k.without_title} ${value.length > 0 ? styles$k.valid : styles$k.not_valid} ${available ? styles$k.available : styles$k.not_available}`, name: name, placeholder: placeholder, type: "email", id: id, onInput: (event) => {
9594
+ setValue(event.target.value);
9595
+ onInput(event);
9596
+ }, ...props }),
9593
9597
  React__default.createElement("label", { htmlFor: "text", className: styles$k.label },
9594
9598
  React__default.createElement("span", { className: styles$k.label_text }, title)))));
9595
9599
  }
@@ -9744,8 +9748,9 @@ var css_248z$f = ".styles-module_container__zcXGF {\n display: flex;\n width:
9744
9748
  var styles$f = {"container":"styles-module_container__zcXGF","input":"styles-module_input__Tpth8","not_available":"styles-module_not_available__CRXjB","label":"styles-module_label__appHO","label_text":"styles-module_label_text__-sKjY","with_title":"styles-module_with_title__L3eGj","valid":"styles-module_valid__zWcOz"};
9745
9749
  styleInject(css_248z$f);
9746
9750
 
9747
- function InputText({ id, title, name, placeholder = "", defaultValue = "", autoFocus = false, type = "text", width = "100%", marginBottom, autoComplete = "off", available = true, onInput = (event) => { } }) {
9751
+ function InputText({ id, title, name, placeholder = "", defaultValue = "", autoFocus = false, type = "text", width = "100%", marginBottom, autoComplete = "off", available = true, onInput = () => { } }) {
9748
9752
  const [value, setValue] = useState(defaultValue);
9753
+ useEffect(() => setValue(defaultValue), [defaultValue]);
9749
9754
  const inputElement = useCallback((element) => {
9750
9755
  if (element && autoFocus)
9751
9756
  element.focus();
@@ -9754,8 +9759,7 @@ function InputText({ id, title, name, placeholder = "", defaultValue = "", autoF
9754
9759
  React__default.createElement("div", { className: styles$f.container, style: { width, marginBottom } },
9755
9760
  React__default.createElement("input", { className: `${styles$f.input} ${title != undefined ? styles$f.with_title : styles$f.without_title} ${value.length > 0 || defaultValue.length > 0 ? styles$f.valid : styles$f.not_valid} ${available ? styles$f.available : styles$f.not_available}`, name: name, id: id, type: type, placeholder: placeholder, autoComplete: autoComplete, ref: inputElement, defaultValue: defaultValue, onInput: (event) => {
9756
9761
  setValue(event.target.value);
9757
- if (onInput)
9758
- onInput(event);
9762
+ onInput(event);
9759
9763
  } }),
9760
9764
  React__default.createElement("label", { htmlFor: "text", className: styles$f.label },
9761
9765
  React__default.createElement("span", { className: styles$f.label_text }, title)))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-main-components",
3
- "version": "0.0.207",
3
+ "version": "0.0.209",
4
4
  "author": "Emilian Scheel",
5
5
  "files": [
6
6
  "dist/**/*",