@kirill.konshin/mui 0.0.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.
package/.ctirc ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "addNewline": true,
3
+ "fileExcludePatterns": [
4
+ "*.stories.*",
5
+ "*.test.*",
6
+ "*.fixture.*"
7
+ ],
8
+ "verbose": false,
9
+ "withoutBackupFile": true,
10
+ "withoutComment": true
11
+ }
@@ -0,0 +1,2 @@
1
+ import config from '../../utils-private/.storybook/main';
2
+ export default config;
@@ -0,0 +1,2 @@
1
+ import preview from '../../utils-private/.storybook/preview';
2
+ export default preview;
@@ -0,0 +1,16 @@
1
+ vite v7.0.6 building SSR bundle for production...
2
+ create succeeded: /home/runner/work/utils/utils/packages/mui/src
3
+ transforming...
4
+ ✓ 5 modules transformed.
5
+ rendering chunks...
6
+
7
+ [vite:dts] Start generate declaration files...
8
+ dist/readOnly.js 0.31 kB │ map: 0.54 kB
9
+ dist/index.js 0.33 kB │ map: 0.09 kB
10
+ dist/formLabelLegend.js 0.38 kB │ map: 0.66 kB
11
+ dist/genericControl.js 0.50 kB │ map: 1.01 kB
12
+ dist/formControlFieldset.js 0.64 kB │ map: 1.22 kB
13
+ [vite:dts] Declaration files built in 2888ms.
14
+
15
+ ✓ built in 3.55s
16
+ Updated package.json with exports
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { GenericControlProps } from './genericControl';
3
+ export type FormControlFieldsetProps = GenericControlProps;
4
+ export declare const FormControlFieldset: FC<FormControlFieldsetProps>;
5
+ //# sourceMappingURL=formControlFieldset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formControlFieldset.d.ts","sourceRoot":"","sources":["../src/formControlFieldset.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvE,MAAM,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAE3D,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CAmB5D,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { GenericControl } from "./genericControl.js";
3
+ import { inputClasses } from "@mui/material/Input";
4
+ const FormControlFieldset = function FormControlFieldset2({
5
+ children,
6
+ sx,
7
+ ...props
8
+ }) {
9
+ return /* @__PURE__ */ jsx(
10
+ GenericControl,
11
+ {
12
+ ...props,
13
+ component: "fieldset",
14
+ sx: {
15
+ ...sx,
16
+ [`legend + .${inputClasses.root}`]: {
17
+ marginTop: 2
18
+ //FIXME 16px, hardcoded from @mui/material/Input/Input.js @ 59
19
+ }
20
+ },
21
+ children
22
+ }
23
+ );
24
+ };
25
+ export {
26
+ FormControlFieldset
27
+ };
28
+ //# sourceMappingURL=formControlFieldset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formControlFieldset.js","sources":["../src/formControlFieldset.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport { GenericControl, GenericControlProps } from './genericControl';\nimport { inputClasses } from '@mui/material/Input';\n\nexport type FormControlFieldsetProps = GenericControlProps;\n\nexport const FormControlFieldset: FC<FormControlFieldsetProps> = function FormControlFieldset({\n children,\n sx,\n ...props\n}) {\n return (\n <GenericControl\n {...props}\n component=\"fieldset\"\n sx={{\n ...sx,\n [`legend + .${inputClasses.root}`]: {\n marginTop: 2, //FIXME 16px, hardcoded from @mui/material/Input/Input.js @ 59\n },\n }}\n >\n {children}\n </GenericControl>\n );\n};\n"],"names":["FormControlFieldset"],"mappings":";;;AAMO,MAAM,sBAAoD,SAASA,qBAAoB;AAAA,EAC1F;AAAA,EACA;AAAA,EACA,GAAG;AACP,GAAG;AACC,SACI;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAG;AAAA,MACJ,WAAU;AAAA,MACV,IAAI;AAAA,QACA,GAAG;AAAA,QACH,CAAC,aAAa,aAAa,IAAI,EAAE,GAAG;AAAA,UAChC,WAAW;AAAA;AAAA,QAAA;AAAA,MACf;AAAA,MAGH;AAAA,IAAA;AAAA,EAAA;AAGb;"}
@@ -0,0 +1,7 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { GenericControl } from './genericControl';
3
+ declare const meta: Meta<typeof GenericControl>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ //# sourceMappingURL=formControlFieldset.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formControlFieldset.stories.d.ts","sourceRoot":"","sources":["../src/formControlFieldset.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIvD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMlD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,cAAc,CA6CC,CAAC;AAExC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAQnC,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { InputLabelProps } from '@mui/material/InputLabel';
3
+ export declare const FormLabelLegend: FC<InputLabelProps>;
4
+ //# sourceMappingURL=formLabelLegend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formLabelLegend.d.ts","sourceRoot":"","sources":["../src/formLabelLegend.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAyB,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAElF,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,eAAe,CAO/C,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import InputLabel from "@mui/material/InputLabel";
3
+ const FormLabelLegend = ({ children, ...props }) => {
4
+ return (
5
+ // sx={(theme) => theme.typography.caption}
6
+ /* @__PURE__ */ jsx(InputLabel, { ...props, shrink: true, component: "legend", children })
7
+ );
8
+ };
9
+ export {
10
+ FormLabelLegend
11
+ };
12
+ //# sourceMappingURL=formLabelLegend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formLabelLegend.js","sources":["../src/formLabelLegend.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport { default as InputLabel, InputLabelProps } from '@mui/material/InputLabel';\n\nexport const FormLabelLegend: FC<InputLabelProps> = ({ children, ...props }) => {\n return (\n // sx={(theme) => theme.typography.caption}\n <InputLabel {...props} shrink={true} component={'legend' as any}>\n {children}\n </InputLabel>\n );\n};\n"],"names":[],"mappings":";;AAGO,MAAM,kBAAuC,CAAC,EAAE,UAAU,GAAG,YAAY;AAC5E;AAAA;AAAA,IAEI,oBAAC,cAAY,GAAG,OAAO,QAAQ,MAAM,WAAW,UAC3C,SAAA,CACL;AAAA;AAER;"}
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ import { FormControlProps } from '@mui/material/FormControl';
3
+ export type GenericControlProps = FormControlProps & {
4
+ children: any;
5
+ };
6
+ export declare const GenericControl: FC<GenericControlProps>;
7
+ //# sourceMappingURL=genericControl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genericControl.d.ts","sourceRoot":"","sources":["../src/genericControl.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAA0B,MAAM,2BAA2B,CAAC;AAGrF,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,GAAG;IAAE,QAAQ,EAAE,GAAG,CAAA;CAAE,CAAC;AAEvE,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAalD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import FormControl from "@mui/material/FormControl";
3
+ import { inputClasses } from "@mui/material/Input";
4
+ const GenericControl = ({ children, sx, ...props }) => /* @__PURE__ */ jsx(
5
+ FormControl,
6
+ {
7
+ variant: "standard",
8
+ sx: {
9
+ ...sx,
10
+ [`& .${inputClasses.root}`]: {
11
+ "&:before, &:after": { display: "none" }
12
+ }
13
+ },
14
+ ...props,
15
+ children
16
+ }
17
+ );
18
+ export {
19
+ GenericControl
20
+ };
21
+ //# sourceMappingURL=genericControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genericControl.js","sources":["../src/genericControl.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport { FormControlProps, default as FormControl } from '@mui/material/FormControl';\nimport { inputClasses } from '@mui/material/Input';\n\nexport type GenericControlProps = FormControlProps & { children: any };\n\nexport const GenericControl: FC<GenericControlProps> = ({ children, sx, ...props }) => (\n <FormControl\n variant=\"standard\"\n sx={{\n ...sx,\n [`& .${inputClasses.root}`]: {\n '&:before, &:after': { display: 'none' },\n },\n }}\n {...props}\n >\n {children}\n </FormControl>\n);\n"],"names":[],"mappings":";;;AAMO,MAAM,iBAA0C,CAAC,EAAE,UAAU,IAAI,GAAG,YACvE;AAAA,EAAC;AAAA,EAAA;AAAA,IACG,SAAQ;AAAA,IACR,IAAI;AAAA,MACA,GAAG;AAAA,MACH,CAAC,MAAM,aAAa,IAAI,EAAE,GAAG;AAAA,QACzB,qBAAqB,EAAE,SAAS,OAAA;AAAA,MAAO;AAAA,IAC3C;AAAA,IAEH,GAAG;AAAA,IAEH;AAAA,EAAA;AACL;"}
@@ -0,0 +1,5 @@
1
+ export * from './formControlFieldset';
2
+ export * from './formLabelLegend';
3
+ export * from './genericControl';
4
+ export * from './readOnly';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { FormControlFieldset } from "./formControlFieldset.js";
2
+ import { FormLabelLegend } from "./formLabelLegend.js";
3
+ import { GenericControl } from "./genericControl.js";
4
+ import { ReadOnly } from "./readOnly.js";
5
+ export {
6
+ FormControlFieldset,
7
+ FormLabelLegend,
8
+ GenericControl,
9
+ ReadOnly
10
+ };
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ import { InputProps } from '@mui/material/Input';
3
+ export declare const ReadOnly: FC<InputProps & {
4
+ children: any;
5
+ }>;
6
+ //# sourceMappingURL=readOnly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readOnly.d.ts","sourceRoot":"","sources":["../src/readOnly.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAoB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEnE,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,UAAU,GAAG;IAAE,QAAQ,EAAE,GAAG,CAAA;CAAE,CAEvD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import Input from "@mui/material/Input";
3
+ const ReadOnly = ({ children, inputProps, ...props }) => /* @__PURE__ */ jsx(Input, { ...props, inputComponent: "div", inputProps: { ...inputProps, children } });
4
+ export {
5
+ ReadOnly
6
+ };
7
+ //# sourceMappingURL=readOnly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readOnly.js","sources":["../src/readOnly.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport { default as Input, InputProps } from '@mui/material/Input';\n\nexport const ReadOnly: FC<InputProps & { children: any }> = ({ children, inputProps, ...props }) => (\n <Input {...props} inputComponent={'div' as any} inputProps={{ ...inputProps, children }}></Input>\n);\n"],"names":[],"mappings":";;AAGO,MAAM,WAA+C,CAAC,EAAE,UAAU,YAAY,GAAG,YACpF,oBAAC,SAAO,GAAG,OAAO,gBAAgB,OAAc,YAAY,EAAE,GAAG,YAAY,WAAS,CAAG;"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@kirill.konshin/mui",
3
+ "description": "Utilities",
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "scripts": {
7
+ "----- BUILD -----": "",
8
+ "clean": "rm -rf dist .tscache tsconfig.tsbuildinfo",
9
+ "build": "vite build",
10
+ "build:index": "cti create ./src",
11
+ "build:check-types": "attw --pack .",
12
+ "start": "yarn build --watch",
13
+ "wait": "wait-on ./dist/index.js",
14
+ "----- TEST -----": "",
15
+ "test:disabled": "vitest run --coverage",
16
+ "test:watch": "vitest watch --coverage",
17
+ "----- STORYBOOK -----": "",
18
+ "storybook:start": "storybook dev -p 6006",
19
+ "storybook:build": "storybook build"
20
+ },
21
+ "devDependencies": {
22
+ "@emotion/react": "^11.14.0",
23
+ "@emotion/styled": "^11.14.0",
24
+ "@kirill.konshin/utils-private": "*",
25
+ "@mui/material": "^7.3.0",
26
+ "react": "^19.1.1"
27
+ },
28
+ "peerDependencies": {
29
+ "@mui/material": "^7",
30
+ "react": "^19"
31
+ },
32
+ "peerDependenciesMeta": {
33
+ "@mui/material": {
34
+ "optional": true
35
+ },
36
+ "react": {
37
+ "optional": true
38
+ }
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "author": "Kirill Konshin <kirill@konshin.org> (https://konshin.org)",
44
+ "license": "MIT",
45
+ "exports": {
46
+ ".": {
47
+ "import": {
48
+ "import": "./dist/index.js",
49
+ "types": "./dist/index.d.ts"
50
+ }
51
+ }
52
+ },
53
+ "main": "./dist/index.js",
54
+ "module": "./dist/index.js",
55
+ "types": "./dist/index.d.ts"
56
+ }
package/src/README.md ADDED
@@ -0,0 +1,3 @@
1
+ ## Prior Art
2
+
3
+ https://codesandbox.io/p/sandbox/l7vykxl57q MUI v4
@@ -0,0 +1,71 @@
1
+ import React from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+
4
+ import { TextField, Stack, InputLabel, RadioGroup, Radio, FormControlLabel, Box } from '@mui/material';
5
+
6
+ import { GenericControl } from './genericControl';
7
+ import { ReadOnly } from './readOnly';
8
+ import { FormControlFieldset } from './formControlFieldset';
9
+ import { FormLabelLegend } from './formLabelLegend';
10
+
11
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
12
+ const meta: Meta<typeof GenericControl> = {
13
+ title: 'MUI / FormControlFieldset',
14
+ parameters: {
15
+ layout: 'centered',
16
+ },
17
+ tags: ['autodocs'],
18
+ argTypes: {},
19
+ render: function Render() {
20
+ return (
21
+ <Box sx={{ position: 'relative' }}>
22
+ <Rule top={12} />
23
+ <Rule top={37} />
24
+ <Rule top={48} />
25
+ <Stack direction="row" gap={3} sx={{ alignItems: 'flex-start' }}>
26
+ <FormControlFieldset>
27
+ <FormLabelLegend>Radios</FormLabelLegend>
28
+ <ReadOnly>
29
+ {/* TODO The size of the component. small is equivalent to the dense radio styling. */}
30
+ <RadioGroup row defaultValue="female" name="radio-buttons-group" sx={{ mt: -1 }}>
31
+ <FormControlLabel value="female" label="Female" control={<Radio size="small" />} />
32
+ <FormControlLabel value="male" label="Male" control={<Radio size="small" />} />
33
+ <FormControlLabel value="other" label="Other" control={<Radio size="small" />} />
34
+ </RadioGroup>
35
+ </ReadOnly>
36
+ </FormControlFieldset>
37
+
38
+ <GenericControl>
39
+ <InputLabel shrink>GenericControl</InputLabel>
40
+ <ReadOnly>
41
+ This is a <code>div</code>, not an input with <code>readOnly</code>
42
+ </ReadOnly>
43
+ </GenericControl>
44
+
45
+ <FormControlFieldset>
46
+ <FormLabelLegend>FormLabelLegend</FormLabelLegend>
47
+ <ReadOnly>
48
+ This is a <code>div</code>, not an input with <code>readOnly</code>
49
+ </ReadOnly>
50
+ </FormControlFieldset>
51
+
52
+ <TextField label="TextField" defaultValue="Bar" variant="standard" />
53
+ </Stack>
54
+ </Box>
55
+ );
56
+ },
57
+ } satisfies Meta<typeof GenericControl>;
58
+
59
+ export default meta;
60
+
61
+ type Story = StoryObj<typeof meta>;
62
+
63
+ function Rule({ top }) {
64
+ return (
65
+ <Box sx={{ background: 'red', position: 'absolute', left: 0, top: `${top}px`, width: '100%', height: '1px' }} />
66
+ );
67
+ }
68
+
69
+ export const Default: Story = {
70
+ args: {},
71
+ };
@@ -0,0 +1,26 @@
1
+ import React, { FC } from 'react';
2
+ import { GenericControl, GenericControlProps } from './genericControl';
3
+ import { inputClasses } from '@mui/material/Input';
4
+
5
+ export type FormControlFieldsetProps = GenericControlProps;
6
+
7
+ export const FormControlFieldset: FC<FormControlFieldsetProps> = function FormControlFieldset({
8
+ children,
9
+ sx,
10
+ ...props
11
+ }) {
12
+ return (
13
+ <GenericControl
14
+ {...props}
15
+ component="fieldset"
16
+ sx={{
17
+ ...sx,
18
+ [`legend + .${inputClasses.root}`]: {
19
+ marginTop: 2, //FIXME 16px, hardcoded from @mui/material/Input/Input.js @ 59
20
+ },
21
+ }}
22
+ >
23
+ {children}
24
+ </GenericControl>
25
+ );
26
+ };
@@ -0,0 +1,11 @@
1
+ import React, { FC } from 'react';
2
+ import { default as InputLabel, InputLabelProps } from '@mui/material/InputLabel';
3
+
4
+ export const FormLabelLegend: FC<InputLabelProps> = ({ children, ...props }) => {
5
+ return (
6
+ // sx={(theme) => theme.typography.caption}
7
+ <InputLabel {...props} shrink={true} component={'legend' as any}>
8
+ {children}
9
+ </InputLabel>
10
+ );
11
+ };
@@ -0,0 +1,20 @@
1
+ import React, { FC } from 'react';
2
+ import { FormControlProps, default as FormControl } from '@mui/material/FormControl';
3
+ import { inputClasses } from '@mui/material/Input';
4
+
5
+ export type GenericControlProps = FormControlProps & { children: any };
6
+
7
+ export const GenericControl: FC<GenericControlProps> = ({ children, sx, ...props }) => (
8
+ <FormControl
9
+ variant="standard"
10
+ sx={{
11
+ ...sx,
12
+ [`& .${inputClasses.root}`]: {
13
+ '&:before, &:after': { display: 'none' },
14
+ },
15
+ }}
16
+ {...props}
17
+ >
18
+ {children}
19
+ </FormControl>
20
+ );
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './formControlFieldset';
2
+ export * from './formLabelLegend';
3
+ export * from './genericControl';
4
+ export * from './readOnly';
@@ -0,0 +1,6 @@
1
+ import React, { FC } from 'react';
2
+ import { default as Input, InputProps } from '@mui/material/Input';
3
+
4
+ export const ReadOnly: FC<InputProps & { children: any }> = ({ children, inputProps, ...props }) => (
5
+ <Input {...props} inputComponent={'div' as any} inputProps={{ ...inputProps, children }}></Input>
6
+ );
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../utils-private/tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist",
6
+ "declarationDir": "dist"
7
+ },
8
+ "include": ["src"],
9
+ "exclude": []
10
+ }
package/turbo.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://turbo.build/schema.json",
3
+ "extends": ["//"],
4
+ "tasks": {
5
+ "build": {
6
+ "dependsOn": ["^build"],
7
+ "outputs": ["src/**/*/index.ts", "package.json", "dist/**/*"]
8
+ }
9
+ }
10
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,2 @@
1
+ import config from '../utils-private/vite.config';
2
+ export default config;