@krrli/cm-designsystem 1.34.12 → 1.35.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.
@@ -33,23 +33,19 @@ declare const formStyles: import('tailwind-variants').TVReturnType<{
33
33
  }, undefined, unknown, unknown, undefined>>;
34
34
  type FormVariants = VariantProps<typeof formStyles>;
35
35
  interface FormProps extends FormVariants {
36
- children?: React.ReactNode;
37
- }
38
- export declare const Form: React.FC<FormProps> & {
39
- Fields: typeof FormFields;
40
- Action: typeof FormAction;
41
- };
42
- export declare function FormFields({ children }: {
43
- children: React.ReactNode;
44
- }): React.ReactNode;
45
- export declare namespace FormFields {
46
- var displayName: string;
47
- }
48
- export declare function FormAction({ children }: {
49
- children: React.ReactElement;
50
- }): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
51
- export declare namespace FormAction {
52
- var displayName: string;
36
+ /**
37
+ * Form fields
38
+ */
39
+ fields: React.ReactNode;
40
+ /**
41
+ * Submit button
42
+ */
43
+ action: React.ReactElement;
44
+ /**
45
+ * Submit handler
46
+ */
47
+ onSubmit?: (event: React.FormEvent<HTMLFormElement>) => void;
53
48
  }
49
+ export declare const Form: React.FC<FormProps>;
54
50
  export {};
55
51
  //# sourceMappingURL=Form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE1D,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAKd,CAAC;AAEH,KAAK,YAAY,GAAG,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,UAAU,SAAU,SAAQ,YAAY;IACtC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG;IACvC,MAAM,EAAE,OAAO,UAAU,CAAC;IAC1B,MAAM,EAAE,OAAO,UAAU,CAAC;CA0B3B,CAAC;AAGF,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,mBAErE;yBAFe,UAAU;;;AAK1B,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAA;CAAE,0EAExE;yBAFe,UAAU"}
1
+ {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE1D,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAKd,CAAC;AAEH,KAAK,YAAY,GAAG,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,UAAU,SAAU,SAAQ,YAAY;IACtC;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;CAC9D;AAED,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAcpC,CAAC"}
@@ -1,6 +1,5 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import * as RadixForm from "@radix-ui/react-form";
3
- import React from "react";
4
3
  import { tv } from "tailwind-variants";
5
4
  const formStyles = tv({
6
5
  slots: {
@@ -8,38 +7,18 @@ const formStyles = tv({
8
7
  fields: ["gap-4", "flex", "flex-col"]
9
8
  }
10
9
  });
11
- const Form = (props) => {
12
- const { base, fields } = formStyles(props);
13
- let fieldElements = null;
14
- let actionElement = null;
15
- React.Children.forEach(props.children, (child) => {
16
- if (!React.isValidElement(child)) return;
17
- switch (child.type) {
18
- case FormFields:
19
- fieldElements = child;
20
- break;
21
- case FormAction:
22
- actionElement = child;
23
- break;
24
- }
25
- });
26
- return /* @__PURE__ */ jsxs(RadixForm.Root, { className: base(), children: [
27
- /* @__PURE__ */ jsx("div", { className: fields(), children: fieldElements }),
28
- /* @__PURE__ */ jsx(RadixForm.Submit, { asChild: true, children: actionElement })
10
+ const Form = ({
11
+ fields,
12
+ action,
13
+ onSubmit,
14
+ ...variantProps
15
+ }) => {
16
+ const { base, fields: fieldsClass } = formStyles(variantProps);
17
+ return /* @__PURE__ */ jsxs(RadixForm.Root, { className: base(), onSubmit, children: [
18
+ /* @__PURE__ */ jsx("div", { className: fieldsClass(), children: fields }),
19
+ /* @__PURE__ */ jsx(RadixForm.Submit, { asChild: true, children: action })
29
20
  ] });
30
21
  };
31
- FormFields.displayName = "FormField";
32
- function FormFields({ children }) {
33
- return children;
34
- }
35
- FormAction.displayName = "ModalActions";
36
- function FormAction({ children }) {
37
- return children;
38
- }
39
- Form.Fields = FormFields;
40
- Form.Action = FormAction;
41
22
  export {
42
- Form,
43
- FormAction,
44
- FormFields
23
+ Form
45
24
  };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { BrandingGallery } from "./components/branding/BrandingGallery.js";
3
3
  import { Button } from "./components/button/Button.js";
4
4
  import { ColorDoc } from "./components/color/ColorDoc.js";
5
5
  import { FileUpload } from "./components/file-upload/FileUpload.js";
6
- import { Form, FormAction, FormFields } from "./components/form/Form.js";
6
+ import { Form } from "./components/form/Form.js";
7
7
  import { IconButton } from "./components/icon-button/IconButton.js";
8
8
  import { IconBase } from "./components/icons/IconBase.js";
9
9
  import { ArrowDown } from "./components/icons/generated/ArrowDown.js";
@@ -75,8 +75,6 @@ export {
75
75
  Eye,
76
76
  FileUpload,
77
77
  Form,
78
- FormAction,
79
- FormFields,
80
78
  Fullscreen,
81
79
  Heading,
82
80
  HeartFilled,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@krrli/cm-designsystem",
3
3
  "repository": "https://github.com/ost-cas-fea-25-26/cm-designsystem",
4
- "version": "1.34.12",
4
+ "version": "1.35.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -19,10 +19,12 @@
19
19
  "types": "./dist/tailwind.preset.d.ts",
20
20
  "import": "./dist/tailwind.preset.js"
21
21
  },
22
+ "./styles.css": "./dist/styles.css",
22
23
  "./base.css": "./src/base.css"
23
24
  },
24
25
  "files": [
25
26
  "dist",
27
+ "dist/styles.css",
26
28
  "src/base.css"
27
29
  ],
28
30
  "sideEffects": false,