@recursica/mantine-adapter 0.7.0 → 0.9.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/mantine-adapter.cjs +1 -1
  3. package/dist/mantine-adapter.cjs.map +1 -1
  4. package/dist/mantine-adapter.css +1 -1
  5. package/dist/mantine-adapter.js +963 -639
  6. package/dist/mantine-adapter.js.map +1 -1
  7. package/dist/src/components/Container/Container.d.ts +14 -0
  8. package/dist/src/components/Dropdown/Dropdown.d.ts +10 -2
  9. package/dist/src/components/Flex/Flex.d.ts +17 -0
  10. package/dist/src/components/Group/Group.d.ts +17 -0
  11. package/dist/src/components/Stack/Stack.d.ts +15 -0
  12. package/dist/src/components/TextArea/TextArea.d.ts +14 -2
  13. package/dist/src/components/index.d.ts +6 -0
  14. package/package.json +1 -1
  15. package/src/components/Accordion/Accordion.module.css +29 -8
  16. package/src/components/Checkbox/CheckboxGroup.tsx +1 -1
  17. package/src/components/Container/CONTAINER_IMPLEMENTATION_NOTES.md +4 -0
  18. package/src/components/Container/Container.module.css +7 -0
  19. package/src/components/Container/Container.stories.tsx +102 -0
  20. package/src/components/Container/Container.tsx +63 -0
  21. package/src/components/Dropdown/DROPDOWN_IMPLEMENTATION_NOTES.md +7 -0
  22. package/src/components/Dropdown/Dropdown.module.css +272 -0
  23. package/src/components/Dropdown/Dropdown.stories.tsx +77 -5
  24. package/src/components/Dropdown/Dropdown.tsx +171 -5
  25. package/src/components/Flex/FLEX_IMPLEMENTATION_NOTES.md +4 -0
  26. package/src/components/Flex/Flex.module.css +7 -0
  27. package/src/components/Flex/Flex.stories.tsx +125 -0
  28. package/src/components/Flex/Flex.tsx +68 -0
  29. package/src/components/Group/GROUP_IMPLEMENTATION_NOTES.md +4 -0
  30. package/src/components/Group/Group.module.css +7 -0
  31. package/src/components/Group/Group.stories.tsx +117 -0
  32. package/src/components/Group/Group.tsx +68 -0
  33. package/src/components/Stack/STACK_IMPLEMENTATION_NOTES.md +4 -0
  34. package/src/components/Stack/Stack.module.css +7 -0
  35. package/src/components/Stack/Stack.stories.tsx +105 -0
  36. package/src/components/Stack/Stack.tsx +66 -0
  37. package/src/components/TextArea/TEXTAREA_IMPLEMENTATION_NOTES.md +7 -0
  38. package/src/components/TextArea/TextArea.module.css +225 -0
  39. package/src/components/TextArea/TextArea.stories.tsx +77 -5
  40. package/src/components/TextArea/TextArea.tsx +149 -5
  41. package/src/components/index.ts +6 -0
@@ -1,22 +1,94 @@
1
+ import React from "react";
1
2
  import type { Meta, StoryObj } from "@storybook/react";
2
3
  import { TextArea } from "./TextArea";
3
- import { ComingSoon } from "@recursica/storybook-template";
4
+ import { formControlArgTypes } from "../../../.storybook/commonArgTypes";
4
5
 
5
- const meta: Meta<typeof TextArea> = {
6
- title: "UI-Kit/🚧 TextArea",
6
+ type TextAreaStoryProps = React.ComponentProps<typeof TextArea>;
7
+
8
+ const meta: Meta<TextAreaStoryProps> = {
9
+ title: "UI-Kit/TextArea",
7
10
  component: TextArea,
8
11
  tags: ["autodocs"],
12
+ parameters: {
13
+ docs: {
14
+ description: {
15
+ component:
16
+ "TextArea provides a multi-line input field, mapping layout explicitly over the standardized FormControlWrapper.",
17
+ },
18
+ },
19
+ },
20
+ args: {
21
+ label: "Description",
22
+ assistiveText: "Enter your full description here.",
23
+ disabled: false,
24
+ required: false,
25
+ readOnly: false,
26
+ autosize: false,
27
+ },
9
28
  argTypes: {
29
+ ...formControlArgTypes,
10
30
  disabled: {
11
31
  control: "boolean",
12
32
  },
33
+ readOnly: {
34
+ control: "boolean",
35
+ },
36
+ autosize: {
37
+ control: "boolean",
38
+ },
39
+ minRows: {
40
+ control: "number",
41
+ },
42
+ maxRows: {
43
+ control: "number",
44
+ },
45
+ value: {
46
+ control: "text",
47
+ },
48
+ placeholder: {
49
+ control: "text",
50
+ },
13
51
  },
14
52
  };
15
53
 
16
54
  export default meta;
17
55
 
18
- type Story = StoryObj<typeof TextArea>;
56
+ type Story = StoryObj<TextAreaStoryProps>;
19
57
 
20
58
  export const Default: Story = {
21
- render: () => <ComingSoon componentName="TextArea" />,
59
+ args: {
60
+ placeholder: "Type something long...",
61
+ },
62
+ };
63
+
64
+ export const Autosize: Story = {
65
+ args: {
66
+ label: "Auto-sizing TextArea",
67
+ autosize: true,
68
+ minRows: 2,
69
+ maxRows: 6,
70
+ placeholder: "Type multiple lines here. Watch it grow!",
71
+ },
72
+ };
73
+
74
+ export const StaticError: Story = {
75
+ args: {
76
+ error: "This field requires a detailed explanation.",
77
+ value: "Some bad input.",
78
+ },
79
+ };
80
+
81
+ export const StaticDisabled: Story = {
82
+ args: {
83
+ disabled: true,
84
+ value: "This content is locked.",
85
+ },
86
+ };
87
+
88
+ export const StaticReadOnly: Story = {
89
+ args: {
90
+ label: "Read Only View",
91
+ readOnly: true,
92
+ value: "This text is safely frozen in read-only form.",
93
+ },
22
94
  };
@@ -1,7 +1,151 @@
1
- import React from "react";
1
+ import React, { forwardRef } from "react";
2
+ import {
3
+ Textarea as MantineTextarea,
4
+ type TextareaProps as MantineTextareaProps,
5
+ } from "@mantine/core";
6
+ import { type ReadOnlyControlProps } from "@recursica/adapter-common";
7
+ import {
8
+ filterStylingProps,
9
+ type RecursicaOverStyled,
10
+ } from "../../utils/filterStylingProps";
11
+ import { type RecursicaFormControlWrapperProps } from "../FormControlWrapper/FormControlWrapper";
12
+ import { WithReadOnlyWrapper } from "../ReadOnlyField/WithReadOnlyWrapper";
13
+ import styles from "./TextArea.module.css";
2
14
 
3
- export type TextAreaProps = React.HTMLAttributes<HTMLDivElement>;
15
+ export interface RecursicaTextAreaProps
16
+ extends Omit<
17
+ MantineTextareaProps,
18
+ "size" | "variant" | "radius" | "wrapperProps"
19
+ >,
20
+ Pick<
21
+ RecursicaFormControlWrapperProps,
22
+ | "assistiveText"
23
+ | "assistiveWithIcon"
24
+ | "formLayout"
25
+ | "labelSize"
26
+ | "labelAlignment"
27
+ | "labelOptionalText"
28
+ | "labelWithEditIcon"
29
+ | "onLabelEditClick"
30
+ >,
31
+ ReadOnlyControlProps {
32
+ /** Maximum rows for autosize textarea to grow */
33
+ maxRows?: number;
34
+ /** Minimum rows of autosize textarea */
35
+ minRows?: number;
36
+ /** If set, enables textarea height growing with its content */
37
+ autosize?: boolean;
38
+ }
4
39
 
5
- export const TextArea: React.FC<TextAreaProps> = (props) => {
6
- return <div {...props}>TextArea</div>;
7
- };
40
+ export type TextAreaProps = RecursicaOverStyled<RecursicaTextAreaProps>;
41
+
42
+ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
43
+ function TextArea(
44
+ {
45
+ overStyled = false,
46
+ formLayout = "stacked",
47
+
48
+ // Label & Wrapper Maps
49
+ labelSize,
50
+ labelAlignment,
51
+ labelOptionalText,
52
+ labelWithEditIcon,
53
+ onLabelEditClick,
54
+
55
+ label,
56
+ assistiveText,
57
+ assistiveWithIcon,
58
+ error,
59
+ required,
60
+ withAsterisk,
61
+ id,
62
+ className,
63
+ style,
64
+ disabled,
65
+ readOnly,
66
+ readOnlyComponent,
67
+ value,
68
+ defaultValue,
69
+ ...rest
70
+ },
71
+ ref,
72
+ ) {
73
+ const sanitizedProps = filterStylingProps(rest, overStyled);
74
+ const restRecord = sanitizedProps as Record<string, unknown>;
75
+
76
+ // Delete prohibited sizing hooks from bypassing variables natively
77
+ delete restRecord["size"];
78
+ delete restRecord["variant"];
79
+ delete restRecord["radius"];
80
+
81
+ // Securely map core native blocks down ensuring nested CSS modules map precisely
82
+ const mergedClassNames: Partial<Record<string, string>> = {
83
+ wrapper: styles.root, // The nested Input internal relative wrapper bounding box
84
+ input: styles.input,
85
+ };
86
+
87
+ const classNamesProp = restRecord.classNames;
88
+ if (
89
+ classNamesProp &&
90
+ typeof classNamesProp === "object" &&
91
+ !Array.isArray(classNamesProp)
92
+ ) {
93
+ const o = classNamesProp as Partial<Record<string, string>>;
94
+ mergedClassNames.wrapper = o.wrapper
95
+ ? `${styles.root} ${o.wrapper}`
96
+ : styles.root;
97
+ mergedClassNames.input = o.input
98
+ ? `${styles.input} ${o.input}`
99
+ : styles.input;
100
+ }
101
+
102
+ return (
103
+ <WithReadOnlyWrapper
104
+ className={className}
105
+ style={style as React.CSSProperties}
106
+ controlMaxWidth="var(--recursica_ui-kit_components_text-field_properties_max-width)"
107
+ controlMinWidth="var(--recursica_ui-kit_components_text-field_properties_min-width)"
108
+ overStyled={overStyled as true}
109
+ formLayout={formLayout}
110
+ labelSize={labelSize}
111
+ labelAlignment={labelAlignment}
112
+ labelOptionalText={labelOptionalText}
113
+ labelWithEditIcon={labelWithEditIcon}
114
+ onLabelEditClick={onLabelEditClick}
115
+ label={label}
116
+ assistiveText={assistiveText}
117
+ assistiveWithIcon={assistiveWithIcon}
118
+ error={error}
119
+ required={required}
120
+ withAsterisk={withAsterisk}
121
+ id={id}
122
+ readOnly={readOnly}
123
+ readOnlyComponent={readOnlyComponent}
124
+ readOnlyType="text"
125
+ readOnlyValue={value !== undefined ? value : defaultValue}
126
+ activeComponent={
127
+ /* Naked Input execution safely decoupled from Mantine's macro Input.Wrapper DOM hooks */
128
+ <MantineTextarea
129
+ ref={ref}
130
+ classNames={mergedClassNames}
131
+ disabled={disabled}
132
+ value={value}
133
+ defaultValue={defaultValue}
134
+ label={undefined}
135
+ description={undefined}
136
+ error={undefined}
137
+ required={undefined}
138
+ withAsterisk={undefined}
139
+ wrapperProps={{
140
+ "data-disabled": disabled ? "true" : undefined,
141
+ "data-error": error ? "true" : undefined,
142
+ }}
143
+ {...(sanitizedProps as unknown as MantineTextareaProps)}
144
+ />
145
+ }
146
+ />
147
+ );
148
+ },
149
+ );
150
+
151
+ TextArea.displayName = "TextArea";
@@ -7,10 +7,13 @@ export * from "./Card/Card";
7
7
  export * from "./Checkbox/Checkbox";
8
8
  export * from "./Checkbox/CheckboxGroup";
9
9
  export * from "./Chip/Chip";
10
+ export * from "./Container/Container";
10
11
  export * from "./DatePicker/DatePicker";
11
12
  export * from "./Dropdown/Dropdown";
12
13
  export * from "./FileInput/FileInput";
13
14
  export * from "./FileUpload/FileUpload";
15
+ export * from "./Flex/Flex";
16
+ export * from "./Group/Group";
14
17
  export * from "./HoverCard/HoverCard";
15
18
  export * from "./Link/Link";
16
19
  export * from "./Loader/Loader";
@@ -26,14 +29,17 @@ export * from "./ReadOnlyField";
26
29
  export * from "./Search/Search";
27
30
  export * from "./SegmentedControl/SegmentedControl";
28
31
  export * from "./Slider/Slider";
32
+ export * from "./Stack/Stack";
29
33
  export * from "./Stepper/Stepper";
30
34
  export * from "./Switch/Switch";
31
35
  export * from "./Table/Table";
32
36
  export * from "./Tabs/Tabs";
37
+ export * from "./Text/Text";
33
38
  export * from "./TextArea/TextArea";
34
39
  export * from "./TextField/TextField";
35
40
  export * from "./TimePicker/TimePicker";
36
41
  export * from "./Timeline/Timeline";
42
+ export * from "./Title/Title";
37
43
  export * from "./Toast/Toast";
38
44
  export * from "./Tooltip/Tooltip";
39
45
  export * from "./TransferList/TransferList";