@semiont/react-ui 0.5.6 → 0.5.8
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/README.md +1 -1
- package/dist/{PdfAnnotationCanvas.client-NIMALXNZ.js → PdfAnnotationCanvas.client-U4EVBZEV.js} +6 -52
- package/dist/PdfAnnotationCanvas.client-U4EVBZEV.js.map +1 -0
- package/dist/{ar-U2EXWUMQ.js → ar-WA47UUWA.js} +4 -8
- package/dist/ar-WA47UUWA.js.map +1 -0
- package/dist/{bn-DRJGV772.js → bn-5ANDRIU6.js} +4 -8
- package/dist/bn-5ANDRIU6.js.map +1 -0
- package/dist/chunk-O2MD7TGE.js +42 -0
- package/dist/chunk-O2MD7TGE.js.map +1 -0
- package/dist/chunk-QT7LYM72.js +234 -0
- package/dist/chunk-QT7LYM72.js.map +1 -0
- package/dist/{chunk-3Q3TUKWP.js → chunk-WHUGODTB.js} +31 -31
- package/dist/chunk-XUDKYAVC.js +21 -0
- package/dist/chunk-XUDKYAVC.js.map +1 -0
- package/dist/{chunk-K6BJDL2I.js → chunk-YBGN4ACY.js} +6 -2
- package/dist/{cs-PTWDM23V.js → cs-3RU7F4JX.js} +4 -8
- package/dist/cs-3RU7F4JX.js.map +1 -0
- package/dist/{da-KSNIKYSS.js → da-GSW5P5HG.js} +7 -11
- package/dist/da-GSW5P5HG.js.map +1 -0
- package/dist/{de-F2XBEWFY.js → de-JUAUYF4Z.js} +4 -8
- package/dist/de-JUAUYF4Z.js.map +1 -0
- package/dist/{el-DLD2GWAP.js → el-JNLWCKEC.js} +4 -8
- package/dist/el-JNLWCKEC.js.map +1 -0
- package/dist/{en-L45VK7BS.js → en-RBN2GUHF.js} +2 -2
- package/dist/{es-WLPYWGB5.js → es-WPOX225H.js} +12 -16
- package/dist/es-WPOX225H.js.map +1 -0
- package/dist/{fa-BAXHSDZG.js → fa-TAEP6N77.js} +4 -8
- package/dist/fa-TAEP6N77.js.map +1 -0
- package/dist/{fi-FCHSYVOT.js → fi-ZVZHANSP.js} +4 -8
- package/dist/fi-ZVZHANSP.js.map +1 -0
- package/dist/{fr-3UERBSL6.js → fr-VLZW7M4N.js} +4 -8
- package/dist/fr-VLZW7M4N.js.map +1 -0
- package/dist/{he-F6F3FV2K.js → he-QFAFYA77.js} +4 -8
- package/dist/he-QFAFYA77.js.map +1 -0
- package/dist/{hi-4BK6IK7Q.js → hi-AO3DQPCV.js} +4 -8
- package/dist/hi-AO3DQPCV.js.map +1 -0
- package/dist/{id-7ECCWP3J.js → id-GTXF42WM.js} +4 -8
- package/dist/id-GTXF42WM.js.map +1 -0
- package/dist/index.css +97 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +52 -23
- package/dist/index.js +2835 -3015
- package/dist/index.js.map +1 -1
- package/dist/integrations/css-modules-helper.d.ts +118 -0
- package/dist/integrations/css-modules-helper.js +117 -0
- package/dist/integrations/css-modules-helper.js.map +1 -0
- package/dist/integrations/styled-components-theme.d.ts +258 -0
- package/dist/integrations/styled-components-theme.js +1774 -0
- package/dist/integrations/styled-components-theme.js.map +1 -0
- package/dist/{it-234Z6XK6.js → it-AS5GM232.js} +4 -8
- package/dist/it-AS5GM232.js.map +1 -0
- package/dist/{ja-PJWQI4OQ.js → ja-GZ4HLUOF.js} +4 -8
- package/dist/ja-GZ4HLUOF.js.map +1 -0
- package/dist/{ko-APUEW2RS.js → ko-A4XUXFGJ.js} +4 -8
- package/dist/ko-A4XUXFGJ.js.map +1 -0
- package/dist/{ms-PJBZWZWD.js → ms-YBAO3S6K.js} +4 -8
- package/dist/ms-YBAO3S6K.js.map +1 -0
- package/dist/{nl-L4C3ZBCU.js → nl-3TJGIIIU.js} +5 -12
- package/dist/nl-3TJGIIIU.js.map +1 -0
- package/dist/{no-QE5N5KNG.js → no-4AXIQPRQ.js} +21 -25
- package/dist/no-4AXIQPRQ.js.map +1 -0
- package/dist/{pl-5Q2D23PD.js → pl-5GP6GKXO.js} +4 -8
- package/dist/pl-5GP6GKXO.js.map +1 -0
- package/dist/{pt-AIGUOIOC.js → pt-26Y6JFG5.js} +119 -123
- package/dist/pt-26Y6JFG5.js.map +1 -0
- package/dist/{ro-T56CSHTY.js → ro-C7UXFRWJ.js} +4 -8
- package/dist/ro-C7UXFRWJ.js.map +1 -0
- package/dist/{sv-L4TJQ2UH.js → sv-44DVD76T.js} +44 -48
- package/dist/sv-44DVD76T.js.map +1 -0
- package/dist/test-utils.js +3 -3
- package/dist/test-utils.js.map +1 -1
- package/dist/{th-6O7Y6O2Q.js → th-GIQRTBOY.js} +4 -8
- package/dist/th-GIQRTBOY.js.map +1 -0
- package/dist/{tr-D4CQCSNO.js → tr-WMQWO4D6.js} +4 -8
- package/dist/tr-WMQWO4D6.js.map +1 -0
- package/dist/{uk-2HMQG6ND.js → uk-I7ML6RGG.js} +4 -8
- package/dist/uk-I7ML6RGG.js.map +1 -0
- package/dist/{vi-XVJ4RUEJ.js → vi-FGWECASQ.js} +4 -8
- package/dist/vi-FGWECASQ.js.map +1 -0
- package/dist/{zh-K2KDPGHK.js → zh-L5FN73XC.js} +4 -8
- package/dist/zh-L5FN73XC.js.map +1 -0
- package/package.json +7 -6
- package/src/components/ProtectedErrorBoundary.css +119 -0
- package/src/components/ProtectedErrorBoundary.tsx +18 -13
- package/src/components/modals/__tests__/ResourceSearchModal.test.tsx +1 -1
- package/src/components/modals/__tests__/SearchModal.search-wiring.test.tsx +1 -1
- package/src/components/resource/AnnotateView.tsx +35 -37
- package/src/components/resource/BrowseView.tsx +31 -31
- package/src/components/resource/__tests__/AnnotationHistory.test.tsx +0 -1
- package/src/components/resource/__tests__/BrowseView.test.tsx +4 -8
- package/src/components/resource/__tests__/HistoryEvent.test.tsx +0 -1
- package/src/components/resource/__tests__/event-formatting.test.ts +1 -1
- package/src/components/resource/panels/CollaborationPanel.tsx +1 -1
- package/src/components/resource/panels/JsonLdPanel.tsx +33 -16
- package/src/components/resource/panels/__tests__/AssessmentEntry.test.tsx +1 -1
- package/src/components/resource/panels/__tests__/AssessmentPanel.test.tsx +1 -1
- package/src/components/resource/panels/__tests__/CommentEntry.test.tsx +1 -1
- package/src/components/resource/panels/__tests__/CommentsPanel.test.tsx +1 -1
- package/src/components/resource/panels/__tests__/HighlightEntry.test.tsx +1 -1
- package/src/components/resource/panels/__tests__/JsonLdPanel.test.tsx +95 -424
- package/src/components/resource/panels/__tests__/ResourceInfoPanel.test.tsx +1 -1
- package/src/components/resource/panels/__tests__/TagEntry.test.tsx +1 -1
- package/src/components/resource/panels/__tests__/TaggingPanel.test.tsx +1 -1
- package/src/features/admin-exchange/__tests__/AdminExchangePage.test.tsx +7 -10
- package/src/features/admin-exchange/__tests__/ImportProgress.test.tsx +38 -27
- package/src/features/admin-exchange/components/ImportProgress.tsx +28 -34
- package/src/features/moderation-linked-data/__tests__/LinkedDataPage.test.tsx +11 -9
- package/src/features/resource-compose/components/ResourceComposePage.tsx +36 -9
- package/src/features/resource-compose/state/compose-page-state-unit.ts +5 -8
- package/src/features/resource-viewer/components/ResourceViewerPage.tsx +7 -5
- package/src/features/resource-viewer/state/__tests__/resource-viewer-page-state-unit.test.ts +37 -0
- package/src/features/resource-viewer/state/resource-viewer-page-state-unit.ts +9 -5
- package/src/styles/features/exchange.css +0 -30
- package/src/styles/index.css +1 -0
- package/translations/ar.json +1 -3
- package/translations/bn.json +1 -3
- package/translations/cs.json +1 -3
- package/translations/da.json +4 -6
- package/translations/de.json +1 -3
- package/translations/el.json +1 -3
- package/translations/es.json +9 -11
- package/translations/fa.json +1 -3
- package/translations/fi.json +1 -3
- package/translations/fr.json +1 -3
- package/translations/he.json +1 -3
- package/translations/hi.json +1 -3
- package/translations/id.json +1 -3
- package/translations/it.json +1 -3
- package/translations/ja.json +1 -3
- package/translations/ko.json +1 -3
- package/translations/ms.json +1 -3
- package/translations/nl.json +2 -7
- package/translations/no.json +18 -20
- package/translations/pl.json +1 -3
- package/translations/pt.json +116 -118
- package/translations/ro.json +1 -3
- package/translations/sv.json +41 -43
- package/translations/th.json +1 -3
- package/translations/tr.json +1 -3
- package/translations/uk.json +1 -3
- package/translations/vi.json +1 -3
- package/translations/zh.json +1 -3
- package/dist/PdfAnnotationCanvas.client-NIMALXNZ.js.map +0 -1
- package/dist/ar-U2EXWUMQ.js.map +0 -1
- package/dist/bn-DRJGV772.js.map +0 -1
- package/dist/cs-PTWDM23V.js.map +0 -1
- package/dist/da-KSNIKYSS.js.map +0 -1
- package/dist/de-F2XBEWFY.js.map +0 -1
- package/dist/el-DLD2GWAP.js.map +0 -1
- package/dist/es-WLPYWGB5.js.map +0 -1
- package/dist/fa-BAXHSDZG.js.map +0 -1
- package/dist/fi-FCHSYVOT.js.map +0 -1
- package/dist/fr-3UERBSL6.js.map +0 -1
- package/dist/he-F6F3FV2K.js.map +0 -1
- package/dist/hi-4BK6IK7Q.js.map +0 -1
- package/dist/id-7ECCWP3J.js.map +0 -1
- package/dist/it-234Z6XK6.js.map +0 -1
- package/dist/ja-PJWQI4OQ.js.map +0 -1
- package/dist/ko-APUEW2RS.js.map +0 -1
- package/dist/ms-PJBZWZWD.js.map +0 -1
- package/dist/nl-L4C3ZBCU.js.map +0 -1
- package/dist/no-QE5N5KNG.js.map +0 -1
- package/dist/pl-5Q2D23PD.js.map +0 -1
- package/dist/pt-AIGUOIOC.js.map +0 -1
- package/dist/ro-T56CSHTY.js.map +0 -1
- package/dist/sv-L4TJQ2UH.js.map +0 -1
- package/dist/th-6O7Y6O2Q.js.map +0 -1
- package/dist/tr-D4CQCSNO.js.map +0 -1
- package/dist/uk-2HMQG6ND.js.map +0 -1
- package/dist/vi-XVJ4RUEJ.js.map +0 -1
- package/dist/zh-K2KDPGHK.js.map +0 -1
- /package/dist/{chunk-3Q3TUKWP.js.map → chunk-WHUGODTB.js.map} +0 -0
- /package/dist/{chunk-K6BJDL2I.js.map → chunk-YBGN4ACY.js.map} +0 -0
- /package/dist/{en-L45VK7BS.js.map → en-RBN2GUHF.js.map} +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CSS Modules Helper for Semiont Components
|
|
5
|
+
*
|
|
6
|
+
* This helper provides utilities for integrating Semiont components
|
|
7
|
+
* with CSS Modules while preserving the data-attribute architecture.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Creates a className builder for Semiont components with CSS Modules
|
|
12
|
+
*
|
|
13
|
+
* @param styles - The CSS Modules styles object
|
|
14
|
+
* @param baseClass - The base Semiont class name (e.g., 'semiont-button')
|
|
15
|
+
* @returns A function that builds the className string
|
|
16
|
+
*/
|
|
17
|
+
declare function createSemiontClassName(styles: Record<string, string>, baseClass: string): (_dataAttributes: Record<string, string | boolean | undefined>, additionalClasses?: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Helper to generate data attributes object from component props
|
|
20
|
+
*
|
|
21
|
+
* @param props - Component props
|
|
22
|
+
* @returns Data attributes object
|
|
23
|
+
*/
|
|
24
|
+
declare function generateDataAttributes(props: {
|
|
25
|
+
variant?: string;
|
|
26
|
+
size?: string;
|
|
27
|
+
loading?: boolean;
|
|
28
|
+
fullWidth?: boolean;
|
|
29
|
+
iconOnly?: boolean;
|
|
30
|
+
active?: boolean;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
orientation?: string;
|
|
33
|
+
attached?: boolean;
|
|
34
|
+
spacing?: string;
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}): Record<string, string | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Merges data attributes into props object
|
|
39
|
+
*
|
|
40
|
+
* @param props - Original props
|
|
41
|
+
* @param dataAttributes - Data attributes to merge
|
|
42
|
+
* @returns Merged props object
|
|
43
|
+
*/
|
|
44
|
+
declare function mergeDataAttributes<T extends Record<string, any>>(props: T, dataAttributes: Record<string, string | undefined>): T;
|
|
45
|
+
/**
|
|
46
|
+
* Example wrapper component for CSS Modules integration
|
|
47
|
+
*
|
|
48
|
+
* Usage:
|
|
49
|
+
* ```tsx
|
|
50
|
+
* import styles from './CustomButton.module.css';
|
|
51
|
+
* import { Button } from '@semiont/react-ui';
|
|
52
|
+
* import { withCSSModules } from '@semiont/react-ui/integrations';
|
|
53
|
+
*
|
|
54
|
+
* const CustomButton = withCSSModules(Button, styles, 'button');
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function withCSSModules<P extends {
|
|
58
|
+
className?: string;
|
|
59
|
+
}>(Component: React.ComponentType<P>, styles: Record<string, string>, baseClassName: string): (props: P) => React.JSX.Element;
|
|
60
|
+
/**
|
|
61
|
+
* CSS Modules configuration helper for build tools
|
|
62
|
+
*
|
|
63
|
+
* This provides the necessary configuration for CSS Modules
|
|
64
|
+
* to work with Semiont's data-attribute selectors
|
|
65
|
+
*/
|
|
66
|
+
declare const cssModulesConfig: {
|
|
67
|
+
postcss: {
|
|
68
|
+
plugins: {
|
|
69
|
+
postcssPlugin: string;
|
|
70
|
+
Once(root: any): void;
|
|
71
|
+
}[];
|
|
72
|
+
};
|
|
73
|
+
webpack: {
|
|
74
|
+
cssLoader: {
|
|
75
|
+
modules: {
|
|
76
|
+
localIdentName: string;
|
|
77
|
+
getLocalIdent: (_context: any, _localIdentName: string, localName: string) => string | null;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
vite: {
|
|
82
|
+
css: {
|
|
83
|
+
modules: {
|
|
84
|
+
generateScopedName: string;
|
|
85
|
+
scopeBehaviour: "local";
|
|
86
|
+
globalModulePaths: RegExp[];
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Type definitions for CSS Modules with Semiont components
|
|
93
|
+
*/
|
|
94
|
+
interface SemiontCSSModules {
|
|
95
|
+
button?: string;
|
|
96
|
+
'button-content'?: string;
|
|
97
|
+
'button-icon'?: string;
|
|
98
|
+
'button-icon-left'?: string;
|
|
99
|
+
'button-icon-right'?: string;
|
|
100
|
+
'button-spinner'?: string;
|
|
101
|
+
'button-group'?: string;
|
|
102
|
+
[key: string]: string | undefined;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Helper to type CSS Modules imports
|
|
106
|
+
*
|
|
107
|
+
* Usage:
|
|
108
|
+
* ```tsx
|
|
109
|
+
* import { defineCSSModules } from '@semiont/react-ui/integrations';
|
|
110
|
+
* import rawStyles from './Button.module.css';
|
|
111
|
+
*
|
|
112
|
+
* const styles = defineCSSModules<SemiontCSSModules>(rawStyles);
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
declare function defineCSSModules<T extends SemiontCSSModules>(styles: Record<string, string>): T;
|
|
116
|
+
|
|
117
|
+
export { createSemiontClassName, cssModulesConfig, defineCSSModules, generateDataAttributes, mergeDataAttributes, withCSSModules };
|
|
118
|
+
export type { SemiontCSSModules };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
clsx
|
|
4
|
+
} from "../chunk-XUDKYAVC.js";
|
|
5
|
+
import "../chunk-YBGN4ACY.js";
|
|
6
|
+
|
|
7
|
+
// src/integrations/css-modules-helper.tsx
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function createSemiontClassName(styles, baseClass) {
|
|
10
|
+
return function buildClassName(_dataAttributes, additionalClasses) {
|
|
11
|
+
const classes = [baseClass];
|
|
12
|
+
if (styles[baseClass]) {
|
|
13
|
+
classes.push(styles[baseClass]);
|
|
14
|
+
}
|
|
15
|
+
if (additionalClasses) {
|
|
16
|
+
classes.push(additionalClasses);
|
|
17
|
+
}
|
|
18
|
+
return clsx(...classes);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function generateDataAttributes(props) {
|
|
22
|
+
return {
|
|
23
|
+
"data-variant": props.variant,
|
|
24
|
+
"data-size": props.size,
|
|
25
|
+
"data-loading": props.loading ? "true" : void 0,
|
|
26
|
+
"data-full-width": props.fullWidth ? "true" : void 0,
|
|
27
|
+
"data-icon-only": props.iconOnly ? "true" : void 0,
|
|
28
|
+
"data-active": props.active ? "true" : void 0,
|
|
29
|
+
"data-disabled": props.disabled ? "true" : void 0,
|
|
30
|
+
"data-orientation": props.orientation,
|
|
31
|
+
"data-attached": props.attached ? "true" : void 0,
|
|
32
|
+
"data-spacing": props.attached ? void 0 : props.spacing
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function mergeDataAttributes(props, dataAttributes) {
|
|
36
|
+
const merged = { ...props };
|
|
37
|
+
Object.entries(dataAttributes).forEach(([key, value]) => {
|
|
38
|
+
if (value !== void 0) {
|
|
39
|
+
merged[key] = value;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return merged;
|
|
43
|
+
}
|
|
44
|
+
function withCSSModules(Component, styles, baseClassName) {
|
|
45
|
+
return function WrappedComponent(props) {
|
|
46
|
+
const className = clsx(
|
|
47
|
+
baseClassName,
|
|
48
|
+
styles[baseClassName],
|
|
49
|
+
props.className
|
|
50
|
+
);
|
|
51
|
+
return /* @__PURE__ */ jsx(Component, { ...props, className });
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var cssModulesConfig = {
|
|
55
|
+
// PostCSS config for CSS Modules
|
|
56
|
+
postcss: {
|
|
57
|
+
plugins: [
|
|
58
|
+
// Preserve data-attribute selectors
|
|
59
|
+
{
|
|
60
|
+
postcssPlugin: "preserve-data-attributes",
|
|
61
|
+
Once(root) {
|
|
62
|
+
root.walkRules((rule) => {
|
|
63
|
+
if (rule.selector.includes("[data-")) {
|
|
64
|
+
rule.selector = rule.selector.replace(
|
|
65
|
+
/\.([a-zA-Z][a-zA-Z0-9-_]*)/g,
|
|
66
|
+
(_match, className) => {
|
|
67
|
+
return `:global(.${className})`;
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
// Webpack config for CSS Modules
|
|
77
|
+
webpack: {
|
|
78
|
+
cssLoader: {
|
|
79
|
+
modules: {
|
|
80
|
+
// Custom naming for CSS Modules
|
|
81
|
+
localIdentName: "[name]__[local]___[hash:base64:5]",
|
|
82
|
+
// Preserve data-attribute selectors
|
|
83
|
+
getLocalIdent: (_context, _localIdentName, localName) => {
|
|
84
|
+
if (localName.startsWith("semiont-")) {
|
|
85
|
+
return localName;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
// Vite config for CSS Modules
|
|
93
|
+
vite: {
|
|
94
|
+
css: {
|
|
95
|
+
modules: {
|
|
96
|
+
// Custom naming for CSS Modules
|
|
97
|
+
generateScopedName: "[name]__[local]___[hash:base64:5]",
|
|
98
|
+
// Preserve specific selectors
|
|
99
|
+
scopeBehaviour: "local",
|
|
100
|
+
// Global patterns
|
|
101
|
+
globalModulePaths: [/semiont-.*\.css$/]
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
function defineCSSModules(styles) {
|
|
107
|
+
return styles;
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
createSemiontClassName,
|
|
111
|
+
cssModulesConfig,
|
|
112
|
+
defineCSSModules,
|
|
113
|
+
generateDataAttributes,
|
|
114
|
+
mergeDataAttributes,
|
|
115
|
+
withCSSModules
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=css-modules-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/css-modules-helper.tsx"],"sourcesContent":["/**\n * CSS Modules Helper for Semiont Components\n *\n * This helper provides utilities for integrating Semiont components\n * with CSS Modules while preserving the data-attribute architecture.\n */\n\nimport React from 'react';\nimport { clsx } from 'clsx';\n\n/**\n * Creates a className builder for Semiont components with CSS Modules\n *\n * @param styles - The CSS Modules styles object\n * @param baseClass - The base Semiont class name (e.g., 'semiont-button')\n * @returns A function that builds the className string\n */\nexport function createSemiontClassName(\n styles: Record<string, string>,\n baseClass: string\n) {\n return function buildClassName(\n _dataAttributes: Record<string, string | boolean | undefined>,\n additionalClasses?: string\n ): string {\n const classes = [baseClass];\n\n // Map the base class to its CSS Module equivalent if it exists\n if (styles[baseClass]) {\n classes.push(styles[baseClass]);\n }\n\n // Add any additional classes\n if (additionalClasses) {\n classes.push(additionalClasses);\n }\n\n return clsx(...classes);\n };\n}\n\n/**\n * Helper to generate data attributes object from component props\n *\n * @param props - Component props\n * @returns Data attributes object\n */\nexport function generateDataAttributes(props: {\n variant?: string;\n size?: string;\n loading?: boolean;\n fullWidth?: boolean;\n iconOnly?: boolean;\n active?: boolean;\n disabled?: boolean;\n orientation?: string;\n attached?: boolean;\n spacing?: string;\n [key: string]: any;\n}): Record<string, string | undefined> {\n return {\n 'data-variant': props.variant,\n 'data-size': props.size,\n 'data-loading': props.loading ? 'true' : undefined,\n 'data-full-width': props.fullWidth ? 'true' : undefined,\n 'data-icon-only': props.iconOnly ? 'true' : undefined,\n 'data-active': props.active ? 'true' : undefined,\n 'data-disabled': props.disabled ? 'true' : undefined,\n 'data-orientation': props.orientation,\n 'data-attached': props.attached ? 'true' : undefined,\n 'data-spacing': props.attached ? undefined : props.spacing,\n };\n}\n\n/**\n * Merges data attributes into props object\n *\n * @param props - Original props\n * @param dataAttributes - Data attributes to merge\n * @returns Merged props object\n */\nexport function mergeDataAttributes<T extends Record<string, any>>(\n props: T,\n dataAttributes: Record<string, string | undefined>\n): T {\n const merged: Record<string, any> = { ...props };\n\n Object.entries(dataAttributes).forEach(([key, value]) => {\n if (value !== undefined) {\n merged[key] = value;\n }\n });\n\n return merged as T;\n}\n\n/**\n * Example wrapper component for CSS Modules integration\n *\n * Usage:\n * ```tsx\n * import styles from './CustomButton.module.css';\n * import { Button } from '@semiont/react-ui';\n * import { withCSSModules } from '@semiont/react-ui/integrations';\n *\n * const CustomButton = withCSSModules(Button, styles, 'button');\n * ```\n */\nexport function withCSSModules<P extends { className?: string }>(\n Component: React.ComponentType<P>,\n styles: Record<string, string>,\n baseClassName: string\n) {\n return function WrappedComponent(props: P) {\n const className = clsx(\n baseClassName,\n styles[baseClassName],\n props.className\n );\n\n return <Component {...props} className={className} />;\n };\n}\n\n/**\n * CSS Modules configuration helper for build tools\n *\n * This provides the necessary configuration for CSS Modules\n * to work with Semiont's data-attribute selectors\n */\nexport const cssModulesConfig = {\n // PostCSS config for CSS Modules\n postcss: {\n plugins: [\n // Preserve data-attribute selectors\n {\n postcssPlugin: 'preserve-data-attributes',\n Once(root: any) {\n root.walkRules((rule: any) => {\n // Don't hash data-attribute selectors\n if (rule.selector.includes('[data-')) {\n rule.selector = rule.selector.replace(\n /\\.([a-zA-Z][a-zA-Z0-9-_]*)/g,\n (_match: string, className: string) => {\n // Keep the class name but mark it as global\n return `:global(.${className})`;\n }\n );\n }\n });\n },\n },\n ],\n },\n\n // Webpack config for CSS Modules\n webpack: {\n cssLoader: {\n modules: {\n // Custom naming for CSS Modules\n localIdentName: '[name]__[local]___[hash:base64:5]',\n // Preserve data-attribute selectors\n getLocalIdent: (\n _context: any,\n _localIdentName: string,\n localName: string\n ) => {\n // Don't hash Semiont base classes\n if (localName.startsWith('semiont-')) {\n return localName;\n }\n // Use default hashing for other classes\n return null;\n },\n },\n },\n },\n\n // Vite config for CSS Modules\n vite: {\n css: {\n modules: {\n // Custom naming for CSS Modules\n generateScopedName: '[name]__[local]___[hash:base64:5]',\n // Preserve specific selectors\n scopeBehaviour: 'local' as const,\n // Global patterns\n globalModulePaths: [/semiont-.*\\.css$/],\n },\n },\n },\n};\n\n/**\n * Type definitions for CSS Modules with Semiont components\n */\nexport interface SemiontCSSModules {\n button?: string;\n 'button-content'?: string;\n 'button-icon'?: string;\n 'button-icon-left'?: string;\n 'button-icon-right'?: string;\n 'button-spinner'?: string;\n 'button-group'?: string;\n [key: string]: string | undefined;\n}\n\n/**\n * Helper to type CSS Modules imports\n *\n * Usage:\n * ```tsx\n * import { defineCSSModules } from '@semiont/react-ui/integrations';\n * import rawStyles from './Button.module.css';\n *\n * const styles = defineCSSModules<SemiontCSSModules>(rawStyles);\n * ```\n */\nexport function defineCSSModules<T extends SemiontCSSModules>(\n styles: Record<string, string>\n): T {\n return styles as T;\n}"],"mappings":";;;;;;;AAwHW;AAvGJ,SAAS,uBACd,QACA,WACA;AACA,SAAO,SAAS,eACd,iBACA,mBACQ;AACR,UAAM,UAAU,CAAC,SAAS;AAG1B,QAAI,OAAO,SAAS,GAAG;AACrB,cAAQ,KAAK,OAAO,SAAS,CAAC;AAAA,IAChC;AAGA,QAAI,mBAAmB;AACrB,cAAQ,KAAK,iBAAiB;AAAA,IAChC;AAEA,WAAO,KAAK,GAAG,OAAO;AAAA,EACxB;AACF;AAQO,SAAS,uBAAuB,OAYA;AACrC,SAAO;AAAA,IACL,gBAAgB,MAAM;AAAA,IACtB,aAAa,MAAM;AAAA,IACnB,gBAAgB,MAAM,UAAU,SAAS;AAAA,IACzC,mBAAmB,MAAM,YAAY,SAAS;AAAA,IAC9C,kBAAkB,MAAM,WAAW,SAAS;AAAA,IAC5C,eAAe,MAAM,SAAS,SAAS;AAAA,IACvC,iBAAiB,MAAM,WAAW,SAAS;AAAA,IAC3C,oBAAoB,MAAM;AAAA,IAC1B,iBAAiB,MAAM,WAAW,SAAS;AAAA,IAC3C,gBAAgB,MAAM,WAAW,SAAY,MAAM;AAAA,EACrD;AACF;AASO,SAAS,oBACd,OACA,gBACG;AACH,QAAM,SAA8B,EAAE,GAAG,MAAM;AAE/C,SAAO,QAAQ,cAAc,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACvD,QAAI,UAAU,QAAW;AACvB,aAAO,GAAG,IAAI;AAAA,IAChB;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAcO,SAAS,eACd,WACA,QACA,eACA;AACA,SAAO,SAAS,iBAAiB,OAAU;AACzC,UAAM,YAAY;AAAA,MAChB;AAAA,MACA,OAAO,aAAa;AAAA,MACpB,MAAM;AAAA,IACR;AAEA,WAAO,oBAAC,aAAW,GAAG,OAAO,WAAsB;AAAA,EACrD;AACF;AAQO,IAAM,mBAAmB;AAAA;AAAA,EAE9B,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP;AAAA,QACE,eAAe;AAAA,QACf,KAAK,MAAW;AACd,eAAK,UAAU,CAAC,SAAc;AAE5B,gBAAI,KAAK,SAAS,SAAS,QAAQ,GAAG;AACpC,mBAAK,WAAW,KAAK,SAAS;AAAA,gBAC5B;AAAA,gBACA,CAAC,QAAgB,cAAsB;AAErC,yBAAO,YAAY,SAAS;AAAA,gBAC9B;AAAA,cACF;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA,EAGA,SAAS;AAAA,IACP,WAAW;AAAA,MACT,SAAS;AAAA;AAAA,QAEP,gBAAgB;AAAA;AAAA,QAEhB,eAAe,CACb,UACA,iBACA,cACG;AAEH,cAAI,UAAU,WAAW,UAAU,GAAG;AACpC,mBAAO;AAAA,UACT;AAEA,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA,EAGA,MAAM;AAAA,IACJ,KAAK;AAAA,MACH,SAAS;AAAA;AAAA,QAEP,oBAAoB;AAAA;AAAA,QAEpB,gBAAgB;AAAA;AAAA,QAEhB,mBAAmB,CAAC,kBAAkB;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AACF;AA2BO,SAAS,iBACd,QACG;AACH,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import * as styled_components from 'styled-components';
|
|
2
|
+
import { DefaultTheme } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Semiont Design Tokens
|
|
6
|
+
*
|
|
7
|
+
* Core design tokens for the Semiont design system.
|
|
8
|
+
* These tokens provide the foundation for all component styling
|
|
9
|
+
* and can be consumed via JavaScript or CSS variables.
|
|
10
|
+
*/
|
|
11
|
+
declare const tokens: {
|
|
12
|
+
colors: {
|
|
13
|
+
primary: {
|
|
14
|
+
50: string;
|
|
15
|
+
100: string;
|
|
16
|
+
200: string;
|
|
17
|
+
300: string;
|
|
18
|
+
400: string;
|
|
19
|
+
500: string;
|
|
20
|
+
600: string;
|
|
21
|
+
700: string;
|
|
22
|
+
800: string;
|
|
23
|
+
900: string;
|
|
24
|
+
};
|
|
25
|
+
secondary: {
|
|
26
|
+
50: string;
|
|
27
|
+
100: string;
|
|
28
|
+
200: string;
|
|
29
|
+
300: string;
|
|
30
|
+
400: string;
|
|
31
|
+
500: string;
|
|
32
|
+
600: string;
|
|
33
|
+
700: string;
|
|
34
|
+
800: string;
|
|
35
|
+
900: string;
|
|
36
|
+
};
|
|
37
|
+
semantic: {
|
|
38
|
+
error: string;
|
|
39
|
+
errorLight: string;
|
|
40
|
+
errorDark: string;
|
|
41
|
+
warning: string;
|
|
42
|
+
warningLight: string;
|
|
43
|
+
warningDark: string;
|
|
44
|
+
success: string;
|
|
45
|
+
successLight: string;
|
|
46
|
+
successDark: string;
|
|
47
|
+
info: string;
|
|
48
|
+
infoLight: string;
|
|
49
|
+
infoDark: string;
|
|
50
|
+
};
|
|
51
|
+
neutral: {
|
|
52
|
+
0: string;
|
|
53
|
+
50: string;
|
|
54
|
+
100: string;
|
|
55
|
+
200: string;
|
|
56
|
+
300: string;
|
|
57
|
+
400: string;
|
|
58
|
+
500: string;
|
|
59
|
+
600: string;
|
|
60
|
+
700: string;
|
|
61
|
+
800: string;
|
|
62
|
+
900: string;
|
|
63
|
+
950: string;
|
|
64
|
+
1000: string;
|
|
65
|
+
};
|
|
66
|
+
background: {
|
|
67
|
+
primary: string;
|
|
68
|
+
secondary: string;
|
|
69
|
+
tertiary: string;
|
|
70
|
+
inverse: string;
|
|
71
|
+
};
|
|
72
|
+
text: {
|
|
73
|
+
primary: string;
|
|
74
|
+
secondary: string;
|
|
75
|
+
tertiary: string;
|
|
76
|
+
disabled: string;
|
|
77
|
+
inverse: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
spacing: {
|
|
81
|
+
0: string;
|
|
82
|
+
xs: string;
|
|
83
|
+
sm: string;
|
|
84
|
+
md: string;
|
|
85
|
+
lg: string;
|
|
86
|
+
xl: string;
|
|
87
|
+
'2xl': string;
|
|
88
|
+
'3xl': string;
|
|
89
|
+
'4xl': string;
|
|
90
|
+
'5xl': string;
|
|
91
|
+
};
|
|
92
|
+
typography: {
|
|
93
|
+
fontFamily: {
|
|
94
|
+
sans: string;
|
|
95
|
+
mono: string;
|
|
96
|
+
};
|
|
97
|
+
fontSize: {
|
|
98
|
+
xs: string;
|
|
99
|
+
sm: string;
|
|
100
|
+
base: string;
|
|
101
|
+
lg: string;
|
|
102
|
+
xl: string;
|
|
103
|
+
'2xl': string;
|
|
104
|
+
'3xl': string;
|
|
105
|
+
'4xl': string;
|
|
106
|
+
'5xl': string;
|
|
107
|
+
};
|
|
108
|
+
fontWeight: {
|
|
109
|
+
thin: number;
|
|
110
|
+
light: number;
|
|
111
|
+
normal: number;
|
|
112
|
+
medium: number;
|
|
113
|
+
semibold: number;
|
|
114
|
+
bold: number;
|
|
115
|
+
black: number;
|
|
116
|
+
};
|
|
117
|
+
lineHeight: {
|
|
118
|
+
none: number;
|
|
119
|
+
tight: number;
|
|
120
|
+
snug: number;
|
|
121
|
+
normal: number;
|
|
122
|
+
relaxed: number;
|
|
123
|
+
loose: number;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
borderRadius: {
|
|
127
|
+
none: string;
|
|
128
|
+
sm: string;
|
|
129
|
+
base: string;
|
|
130
|
+
md: string;
|
|
131
|
+
lg: string;
|
|
132
|
+
xl: string;
|
|
133
|
+
'2xl': string;
|
|
134
|
+
'3xl': string;
|
|
135
|
+
full: string;
|
|
136
|
+
};
|
|
137
|
+
shadows: {
|
|
138
|
+
none: string;
|
|
139
|
+
xs: string;
|
|
140
|
+
sm: string;
|
|
141
|
+
base: string;
|
|
142
|
+
md: string;
|
|
143
|
+
lg: string;
|
|
144
|
+
xl: string;
|
|
145
|
+
inner: string;
|
|
146
|
+
};
|
|
147
|
+
transitions: {
|
|
148
|
+
duration: {
|
|
149
|
+
fast: string;
|
|
150
|
+
base: string;
|
|
151
|
+
slow: string;
|
|
152
|
+
slower: string;
|
|
153
|
+
};
|
|
154
|
+
timing: {
|
|
155
|
+
linear: string;
|
|
156
|
+
ease: string;
|
|
157
|
+
easeIn: string;
|
|
158
|
+
easeOut: string;
|
|
159
|
+
easeInOut: string;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
breakpoints: {
|
|
163
|
+
sm: string;
|
|
164
|
+
md: string;
|
|
165
|
+
lg: string;
|
|
166
|
+
xl: string;
|
|
167
|
+
'2xl': string;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Semiont theme object for styled-components
|
|
173
|
+
*/
|
|
174
|
+
declare const semiontTheme: DefaultTheme;
|
|
175
|
+
/**
|
|
176
|
+
* Type augmentation for styled-components DefaultTheme
|
|
177
|
+
*/
|
|
178
|
+
declare module 'styled-components' {
|
|
179
|
+
interface DefaultTheme {
|
|
180
|
+
colors: typeof tokens.colors & {
|
|
181
|
+
error: string;
|
|
182
|
+
errorLight: string;
|
|
183
|
+
errorDark: string;
|
|
184
|
+
warning: string;
|
|
185
|
+
warningLight: string;
|
|
186
|
+
warningDark: string;
|
|
187
|
+
success: string;
|
|
188
|
+
successLight: string;
|
|
189
|
+
successDark: string;
|
|
190
|
+
info: string;
|
|
191
|
+
infoLight: string;
|
|
192
|
+
infoDark: string;
|
|
193
|
+
};
|
|
194
|
+
spacing: typeof tokens.spacing;
|
|
195
|
+
typography: typeof tokens.typography;
|
|
196
|
+
borderRadius: typeof tokens.borderRadius;
|
|
197
|
+
shadows: typeof tokens.shadows;
|
|
198
|
+
transitions: typeof tokens.transitions;
|
|
199
|
+
breakpoints: typeof tokens.breakpoints;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* CSS mixins for common component patterns
|
|
204
|
+
*/
|
|
205
|
+
declare const semiontMixins: {
|
|
206
|
+
/**
|
|
207
|
+
* Button base styles
|
|
208
|
+
*/
|
|
209
|
+
buttonBase: styled_components.RuleSet<object>;
|
|
210
|
+
/**
|
|
211
|
+
* Button variant styles
|
|
212
|
+
*/
|
|
213
|
+
buttonVariant: (variant: string) => styled_components.RuleSet<object>;
|
|
214
|
+
/**
|
|
215
|
+
* Button size styles
|
|
216
|
+
*/
|
|
217
|
+
buttonSize: (size: string) => styled_components.RuleSet<object>;
|
|
218
|
+
/**
|
|
219
|
+
* Focus ring styles
|
|
220
|
+
*/
|
|
221
|
+
focusRing: (color?: string) => styled_components.RuleSet<object>;
|
|
222
|
+
/**
|
|
223
|
+
* Truncate text with ellipsis
|
|
224
|
+
*/
|
|
225
|
+
truncate: styled_components.RuleSet<object>;
|
|
226
|
+
/**
|
|
227
|
+
* Screen reader only
|
|
228
|
+
*/
|
|
229
|
+
srOnly: styled_components.RuleSet<object>;
|
|
230
|
+
/**
|
|
231
|
+
* Responsive media query helpers
|
|
232
|
+
*/
|
|
233
|
+
media: {
|
|
234
|
+
sm: (styles: any) => styled_components.RuleSet<object>;
|
|
235
|
+
md: (styles: any) => styled_components.RuleSet<object>;
|
|
236
|
+
lg: (styles: any) => styled_components.RuleSet<object>;
|
|
237
|
+
xl: (styles: any) => styled_components.RuleSet<object>;
|
|
238
|
+
'2xl': (styles: any) => styled_components.RuleSet<object>;
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Global styles for Semiont components
|
|
243
|
+
*/
|
|
244
|
+
declare const SemiontGlobalStyles: styled_components.RuleSet<object>;
|
|
245
|
+
/**
|
|
246
|
+
* Helper function to create styled Semiont components
|
|
247
|
+
*
|
|
248
|
+
* Usage:
|
|
249
|
+
* ```tsx
|
|
250
|
+
* import styled from 'styled-components';
|
|
251
|
+
* import { createStyledSemiontButton } from '@semiont/react-ui/integrations';
|
|
252
|
+
*
|
|
253
|
+
* const StyledButton = createStyledSemiontButton(styled);
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
declare function createStyledSemiontButton(styled: any): any;
|
|
257
|
+
|
|
258
|
+
export { SemiontGlobalStyles, createStyledSemiontButton, semiontMixins, semiontTheme };
|