injast-core 1.0.80 → 1.0.81
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/guidelines/Guidelines.md +36 -23
- package/guidelines/components/buttons.md +41 -12
- package/guidelines/components/data-display.md +39 -1
- package/guidelines/components/date-inputs.md +47 -6
- package/guidelines/components/feedback.md +78 -4
- package/guidelines/components/forms.md +170 -7
- package/guidelines/components/layout.md +106 -6
- package/guidelines/components/overview.md +23 -4
- package/guidelines/foundations/color.md +46 -23
- package/guidelines/foundations/icons.md +72 -0
- package/guidelines/foundations/spacing.md +85 -25
- package/guidelines/foundations/typography.md +41 -18
- package/guidelines/runtime.md +141 -0
- package/guidelines/setup.md +155 -11
- package/guidelines/types.md +60 -0
- package/package.json +1 -1
package/guidelines/Guidelines.md
CHANGED
|
@@ -2,24 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
## Product Character
|
|
4
4
|
|
|
5
|
-
Injast Core is an RTL-first React and Material UI design system for Persian product interfaces.
|
|
5
|
+
Injast Core is an RTL-first React and Material UI design system for Persian product interfaces. Generated screens should feel like focused product UI: mobile-first, operational, compact, and easy to scan repeatedly.
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
- Use
|
|
7
|
+
- Build Persian and RTL experiences by default.
|
|
8
|
+
- Prefer task screens, forms, tables, status feedback, and flows over marketing pages.
|
|
9
|
+
- Keep the main app canvas constrained to `max-width: 550px` with `margin-inline: auto` unless a data-heavy desktop layout clearly needs more width.
|
|
10
|
+
- Use brand color for primary actions and active states only. Do not use strong colors as large decorative backgrounds.
|
|
11
|
+
- Use measured density: compact controls, clear labels, and enough spacing around decisions and errors.
|
|
12
12
|
|
|
13
13
|
## Reading Order
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Make must read these files before writing app code with this package:
|
|
16
16
|
|
|
17
|
-
1. `guidelines/Guidelines.md`
|
|
18
|
-
2. `guidelines/setup.md`
|
|
19
|
-
3. `guidelines/foundations/color.md`
|
|
20
|
-
4. `guidelines/foundations/typography.md`
|
|
21
|
-
5. `guidelines/foundations/spacing.md`
|
|
22
|
-
6. `guidelines/
|
|
17
|
+
1. `guidelines/Guidelines.md` - product character, routing, and hard rules.
|
|
18
|
+
2. `guidelines/setup.md` - package install, CSS imports, providers, viewport, and icon package.
|
|
19
|
+
3. `guidelines/foundations/color.md` - app colors, semantic palette, and status colors.
|
|
20
|
+
4. `guidelines/foundations/typography.md` - theme typography variants and usage.
|
|
21
|
+
5. `guidelines/foundations/spacing.md` - 4px spacing scale, page shell, padding, gaps, and sizing.
|
|
22
|
+
6. `guidelines/foundations/icons.md` - Iconsax import, sizing, placement, and color rules.
|
|
23
|
+
7. `guidelines/components/overview.md` - component catalog and selection rules.
|
|
24
|
+
8. `guidelines/runtime.md` - hooks, utilities, API helpers, logging, Sentry, and app integration helpers.
|
|
25
|
+
9. `guidelines/types.md` - exported TypeScript types and when to use them.
|
|
23
26
|
|
|
24
27
|
Read focused component files before using those component groups:
|
|
25
28
|
|
|
@@ -30,6 +33,10 @@ Read focused component files before using those component groups:
|
|
|
30
33
|
- `guidelines/components/data-display.md`
|
|
31
34
|
- `guidelines/components/date-inputs.md`
|
|
32
35
|
|
|
36
|
+
Composition and app-shell rules live in `guidelines/components/layout.md`.
|
|
37
|
+
Runtime integration rules live in `guidelines/runtime.md`.
|
|
38
|
+
Type import rules live in `guidelines/types.md`.
|
|
39
|
+
|
|
33
40
|
## Package Rules
|
|
34
41
|
|
|
35
42
|
- Install and import the public package as `injast-core`.
|
|
@@ -37,19 +44,25 @@ Read focused component files before using those component groups:
|
|
|
37
44
|
- Do not import `@alimohammadiwork/injast-core`; that scoped package is not this package.
|
|
38
45
|
- Do not use `@make-kits/injast-core-make-kit` for the public npm package path.
|
|
39
46
|
- For Figma Make and Vite React apps, use `SPAThemeProvider`.
|
|
47
|
+
- For Next.js app providers, use `ThemeProvider`.
|
|
48
|
+
- Wrap generated app content with `MessageProvider` when toast/status feedback is needed.
|
|
40
49
|
- Import `injast-core/fonts.css` once near the app root.
|
|
41
|
-
- Use
|
|
50
|
+
- Use `coreFaIR` in SPA/Figma Make theme options for Persian Material UI localization.
|
|
51
|
+
- Use named imports from `injast-core` for common usage; use subpath imports only for focused entrypoints.
|
|
42
52
|
|
|
43
|
-
##
|
|
53
|
+
## Hard UI Rules
|
|
44
54
|
|
|
45
|
-
- Use
|
|
46
|
-
-
|
|
47
|
-
- Use `
|
|
48
|
-
-
|
|
49
|
-
- Use
|
|
50
|
-
- Use `
|
|
51
|
-
-
|
|
55
|
+
- Use Injast Core components before raw HTML or direct Material UI primitives.
|
|
56
|
+
- Do not use raw `<button>`, `<input>`, `<select>`, checkbox, radio, dialog, table, or image elements when an Injast component exists.
|
|
57
|
+
- Use RTL by default: provider `dir="rtl"`, Persian labels, right-aligned reading flow, and logical CSS properties such as `marginInline` or `px`.
|
|
58
|
+
- Keep the primary app surface centered with `maxWidth: 550` or CSS `max-width: 550px; margin-inline: auto;`.
|
|
59
|
+
- Do not guess unsupported component props. Use Material UI props plus documented Injast-specific props.
|
|
60
|
+
- Use `iconsax-react` for all generated app icons. Do not use Lucide, Heroicons, Font Awesome, inline SVGs, emoji icons, or `@mui/icons-material` in generated screens.
|
|
61
|
+
- Keep icon sizes consistent: 20px for input adornments, 24px for standard actions, 28px for status icons.
|
|
62
|
+
- Use `defaultColors`, `appColors`, and theme palette values instead of hardcoded colors where possible.
|
|
63
|
+
- Keep all controls reachable on mobile. Do not rely on hover-only actions for required workflows.
|
|
64
|
+
- Do not create nested cards unless the inner card is a repeated item, modal content, or a genuinely separate framed tool.
|
|
52
65
|
|
|
53
66
|
## Output Expectations
|
|
54
67
|
|
|
55
|
-
Generated screens should look like production product UI
|
|
68
|
+
Generated screens should look like production Persian product UI. Favor concise copy, clear hierarchy, stable control sizes, predictable forms, visible validation, compact data displays, and direct recovery actions for empty or error states.
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
Use `Button` for every visible action. It wraps Material UI `Button` and accepts Material UI button props plus Injast-specific sizing and loading props.
|
|
6
6
|
|
|
7
7
|
```tsx
|
|
8
|
+
import { Add } from "iconsax-react";
|
|
8
9
|
import { Button } from "injast-core";
|
|
9
10
|
|
|
10
|
-
<Button variant="contained" color="primary" buttonSize="M">
|
|
11
|
+
<Button variant="contained" color="primary" buttonSize="M" startIcon={<Add size={24} />}>
|
|
11
12
|
ثبت
|
|
12
13
|
</Button>
|
|
13
14
|
```
|
|
@@ -19,25 +20,53 @@ import { Button } from "injast-core";
|
|
|
19
20
|
| `buttonSize` | `"L" | "M" | "S" | "XS"` | `"M"` | Controls height, radius, and font size |
|
|
20
21
|
| `loading` | `boolean` | `false` | Replaces content with spinner and disables click |
|
|
21
22
|
| `loadingColor` | `string` | `neutral.50` | Spinner color |
|
|
22
|
-
| Material UI `ButtonProps` | varies | - | Use `variant`, `color`, `disabled`, `startIcon`, `endIcon`, `fullWidth` |
|
|
23
|
+
| Material UI `ButtonProps` | varies | - | Use `variant`, `color`, `disabled`, `startIcon`, `endIcon`, `fullWidth`, `onClick`, `type` |
|
|
23
24
|
|
|
24
25
|
## Sizing
|
|
25
26
|
|
|
26
|
-
| Size | Height | Use for |
|
|
27
|
-
|
|
28
|
-
| `L` | 56px | High-emphasis primary actions |
|
|
29
|
-
| `M` | 48px | Default form and page actions |
|
|
30
|
-
| `S` | 40px | Dense toolbars or secondary actions |
|
|
31
|
-
| `XS` | 32px | Compact inline actions |
|
|
27
|
+
| Size | Height | Radius | Font | Use for |
|
|
28
|
+
|---|---:|---:|---:|---|
|
|
29
|
+
| `L` | 56px | 12px | 16px / 700 | High-emphasis primary actions |
|
|
30
|
+
| `M` | 48px | 12px | 16px / 700 | Default form and page actions |
|
|
31
|
+
| `S` | 40px | 8px | 14px / 700 | Dense toolbars or secondary actions |
|
|
32
|
+
| `XS` | 32px | 8px | 12px / 700 | Compact inline actions and modal secondary actions |
|
|
33
|
+
|
|
34
|
+
Button content uses an 8px icon/text gap. Icons in normal buttons should be 20px to 24px. Large FAB-like actions can use 28px icons.
|
|
32
35
|
|
|
33
36
|
## Variant Rules
|
|
34
37
|
|
|
35
38
|
- Use `variant="contained"` and `color="primary"` for the main action.
|
|
36
39
|
- Use `variant="outlined"` for secondary actions.
|
|
37
|
-
- Use `variant="text"` only for low-emphasis actions.
|
|
40
|
+
- Use `variant="text"` only for low-emphasis actions, inline navigation, or cancel links.
|
|
38
41
|
- Keep one primary contained action per focused region.
|
|
39
|
-
- Use `
|
|
42
|
+
- Use `fullWidth` for mobile bottom actions and one-column forms.
|
|
43
|
+
- Use `loading` instead of manually swapping button text or adding a separate spinner.
|
|
44
|
+
- Do not add custom elevation or ripple behavior; the component disables elevation and ripple for a quiet product feel.
|
|
45
|
+
|
|
46
|
+
## Action Layout
|
|
47
|
+
|
|
48
|
+
- In RTL modals and drawers, place the primary action at the end of the row when actions are horizontal.
|
|
49
|
+
- Use `gap: 2` between adjacent buttons.
|
|
50
|
+
- Use a fixed bottom action area for long mobile forms when the submit action must stay visible.
|
|
51
|
+
- Use `buttonSize="M"` for the main bottom action and `buttonSize="XS"` or `S` for compact modal footer actions.
|
|
52
|
+
|
|
53
|
+
## IconButton
|
|
54
|
+
|
|
55
|
+
Use `IconButton` for compact icon-only controls such as close, remove, edit, calendar, search, and increment/decrement.
|
|
56
|
+
|
|
57
|
+
Rules:
|
|
58
|
+
|
|
59
|
+
- Use Iconsax icons only.
|
|
60
|
+
- Give unfamiliar icon-only actions a tooltip or visible adjacent label when context is not obvious.
|
|
61
|
+
- Keep common icon-only targets 40px to 48px. Compact inline controls can be 32px.
|
|
62
|
+
- Do not use text inside `IconButton`.
|
|
63
|
+
|
|
64
|
+
## Fab
|
|
65
|
+
|
|
66
|
+
Use `Fab` only for a single prominent floating action in a screen. Do not place multiple FABs in the same view.
|
|
40
67
|
|
|
41
|
-
|
|
68
|
+
Sizing:
|
|
42
69
|
|
|
43
|
-
|
|
70
|
+
- Small FAB: 20px icon.
|
|
71
|
+
- Default FAB: 24px icon.
|
|
72
|
+
- Large FAB: 28px icon.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## DataGrid
|
|
4
4
|
|
|
5
|
-
Use `DataGrid` for tabular data. It wraps
|
|
5
|
+
Use `DataGrid` for tabular operational data. It wraps `material-react-table` with RTL and Persian localization defaults.
|
|
6
6
|
|
|
7
7
|
```tsx
|
|
8
8
|
import { DataGrid, type MRT_ColumnDef } from "injast-core";
|
|
@@ -17,27 +17,65 @@ const columns: MRT_ColumnDef<Row>[] = [
|
|
|
17
17
|
<DataGrid columns={columns} data={rows} enableSorting />;
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
Default behavior and sizing:
|
|
21
|
+
|
|
22
|
+
| Setting | Default |
|
|
23
|
+
|---|---|
|
|
24
|
+
| Direction | RTL wrapper |
|
|
25
|
+
| Localization | Persian Material React Table localization |
|
|
26
|
+
| Layout mode | `grid` |
|
|
27
|
+
| Density | `compact` |
|
|
28
|
+
| Paper radius | 12px |
|
|
29
|
+
| Table container max height | `calc(100vh - 300px)` |
|
|
30
|
+
| Header background | `neutral.100` equivalent |
|
|
31
|
+
| Header font | 16px / 500 |
|
|
32
|
+
| Body cell font | 14px |
|
|
33
|
+
| Row action minimum width | 160px |
|
|
34
|
+
|
|
20
35
|
Rules:
|
|
21
36
|
|
|
22
37
|
- Define stable `columns` outside render or memoize them.
|
|
23
38
|
- Use compact density for operational pages.
|
|
24
39
|
- Use built-in MRT options for sorting, filtering, selection, row actions, and pagination.
|
|
25
40
|
- Keep row actions concise and aligned.
|
|
41
|
+
- Use right alignment for Persian text, center alignment for small status columns, and left or LTR alignment for Latin IDs when necessary.
|
|
42
|
+
- Avoid placing wide `DataGrid` tables inside the 550px mobile shell unless horizontal scrolling is intentional.
|
|
26
43
|
|
|
27
44
|
## Typography
|
|
28
45
|
|
|
29
46
|
Use `Typography` for labels, headings, metadata, and body text. Match text scale to context; do not use display styles inside dense cards or tables.
|
|
30
47
|
|
|
48
|
+
Rules:
|
|
49
|
+
|
|
50
|
+
- Use `body1` for primary row/card text.
|
|
51
|
+
- Use `body2` or `label1` for metadata.
|
|
52
|
+
- Use `h2` or `h3` for section titles inside dense app screens.
|
|
53
|
+
|
|
31
54
|
## Image
|
|
32
55
|
|
|
33
56
|
Use `Image` for image content. Always provide useful `alt` text unless the image is decorative.
|
|
34
57
|
|
|
58
|
+
Sizing:
|
|
59
|
+
|
|
60
|
+
- `src` is required.
|
|
61
|
+
- Pass explicit `width` and `height`.
|
|
62
|
+
- Default `objectFit` is `cover`.
|
|
63
|
+
- Use `contain` for logos, receipts, cards, and documents that must not crop.
|
|
64
|
+
- `fallbackSrc` exists in the prop type but current runtime fallback handling is not active; do not rely on it for critical broken-image recovery.
|
|
65
|
+
- Use `style` only for image-specific CSS such as border radius or filter, not for page layout.
|
|
66
|
+
|
|
35
67
|
## Pagination and Divider
|
|
36
68
|
|
|
37
69
|
Use `Pagination` when data is split across pages. Use `Divider` to separate adjacent content groups, not as a substitute for spacing.
|
|
38
70
|
|
|
71
|
+
Rules:
|
|
72
|
+
|
|
73
|
+
- Keep pagination close to the data it controls.
|
|
74
|
+
- Do not use dividers between every small form field; use gaps first.
|
|
75
|
+
|
|
39
76
|
## Empty and Loading States
|
|
40
77
|
|
|
41
78
|
- Use `Skeleton` when data is loading.
|
|
42
79
|
- Use a concise empty state with one primary recovery action when no data exists.
|
|
43
80
|
- Use `ProgressBar` for determinate progress.
|
|
81
|
+
- Keep empty state copy short and Persian when the app content is Persian.
|
|
@@ -14,22 +14,57 @@ Use `MobileDatePicker` for Persian calendar date entry in mobile-first or respon
|
|
|
14
14
|
/>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
Behavior and sizing:
|
|
18
|
+
|
|
19
|
+
| Property | Default or rule |
|
|
20
|
+
|---|---|
|
|
21
|
+
| Width | `100%` |
|
|
22
|
+
| Field height | 48px |
|
|
23
|
+
| Field radius | 8px through `TextField` |
|
|
24
|
+
| Calendar icon | Iconsax `Calendar`, 20px |
|
|
25
|
+
| Date shown to user | Jalali |
|
|
26
|
+
| `onChange` value | Gregorian string |
|
|
27
|
+
| Modal radius | 12px |
|
|
28
|
+
| Modal action buttons | `buttonSize="XS"` |
|
|
29
|
+
|
|
17
30
|
Rules:
|
|
18
31
|
|
|
19
|
-
- `onChange` receives the selected date converted to Gregorian format.
|
|
20
32
|
- Use `label`, `placeholder`, `error`, and `helperText` for form clarity.
|
|
21
33
|
- Pass `disabled` when the date cannot be edited.
|
|
22
|
-
-
|
|
34
|
+
- Use `minDate` and `maxDate` when the business flow has valid ranges.
|
|
35
|
+
- Use `textFieldSxProps` only for field-level `sx` overrides that cannot be expressed through layout wrappers.
|
|
36
|
+
- Ensure the app build supports CSS imports from npm packages. `MobileDatePicker` uses `react-multi-date-picker`, `react-date-object`, and the Persian calendar/locale internally.
|
|
37
|
+
- Keep date fields full width in the 550px mobile shell.
|
|
23
38
|
|
|
24
39
|
## WheelDatePicker
|
|
25
40
|
|
|
26
|
-
Use `WheelDatePicker` when a drawer-style date picker is more appropriate than the modal calendar.
|
|
41
|
+
Use `WheelDatePicker` when a drawer-style date picker is more appropriate than the modal calendar, especially for touch-heavy flows.
|
|
42
|
+
|
|
43
|
+
Behavior and sizing:
|
|
44
|
+
|
|
45
|
+
| Property | Default or rule |
|
|
46
|
+
|---|---|
|
|
47
|
+
| Field height | 48px |
|
|
48
|
+
| Field radius | 8px |
|
|
49
|
+
| Drawer max width | 550px |
|
|
50
|
+
| Drawer horizontal alignment | centered with `mx: "auto"` |
|
|
51
|
+
| Drawer body padding | `px: 3.5`, `py: 6` |
|
|
52
|
+
| Wheel item height | 44px |
|
|
53
|
+
| Visible wheel items | 3 |
|
|
54
|
+
| Confirm action | full-width contained button |
|
|
55
|
+
| Default format | Unix seconds unless `dateFormat` is set |
|
|
27
56
|
|
|
28
57
|
Rules:
|
|
29
58
|
|
|
30
|
-
- Prefer it for
|
|
31
|
-
- Keep surrounding form actions clear: cancel and confirm.
|
|
32
|
-
- Use
|
|
59
|
+
- Prefer it for mobile bottom-sheet selection.
|
|
60
|
+
- Keep surrounding form actions clear: cancel/close and confirm.
|
|
61
|
+
- Use `title` for the drawer/input label and `placeholder` for empty display text.
|
|
62
|
+
- Use `dateFormat="jalali"` when the form state should store Jalali text.
|
|
63
|
+
- Use `dateFormat="gregorian"` when the form state should store a Gregorian date string.
|
|
64
|
+
- Use `valueFormat` when the incoming `value` format differs from the desired `onChange` format.
|
|
65
|
+
- Use `onChangeDateFormat` when the emitted value format must differ from the incoming `value`.
|
|
66
|
+
- Use `defaultDate` as the initial date when `value` is empty.
|
|
67
|
+
- Use `minDate` and `maxDate` with Unix seconds when the selectable range is constrained.
|
|
33
68
|
|
|
34
69
|
## Date Utilities
|
|
35
70
|
|
|
@@ -43,3 +78,9 @@ import {
|
|
|
43
78
|
longDateFormat,
|
|
44
79
|
} from "injast-core";
|
|
45
80
|
```
|
|
81
|
+
|
|
82
|
+
Rules:
|
|
83
|
+
|
|
84
|
+
- Do not hand-roll Jalali/Gregorian conversions.
|
|
85
|
+
- Keep storage format explicit in component state and API payloads.
|
|
86
|
+
- Display dates in Persian/Jalali format for Persian users unless the product requirement says otherwise.
|
|
@@ -20,23 +20,75 @@ Valid severity values:
|
|
|
20
20
|
- `warning`
|
|
21
21
|
- `error`
|
|
22
22
|
|
|
23
|
+
Toast sizing and style:
|
|
24
|
+
|
|
25
|
+
| Property | Default or rule |
|
|
26
|
+
|---|---|
|
|
27
|
+
| Width | `90%` |
|
|
28
|
+
| Alert max width | 450px |
|
|
29
|
+
| Wide minimum width | 350px |
|
|
30
|
+
| Radius | 8px |
|
|
31
|
+
| Horizontal padding | `px: 3.5` (14px) |
|
|
32
|
+
| Vertical padding | `py: 4` (16px) |
|
|
33
|
+
| Status icon | 28px Iconsax `Bold` |
|
|
34
|
+
| Default duration | 4000ms through `MessageProvider` |
|
|
35
|
+
|
|
36
|
+
Rules:
|
|
37
|
+
|
|
38
|
+
- Prefer `MessageProvider` and `useMessage` for app-level feedback.
|
|
39
|
+
- Match icon, text, border, and background to severity.
|
|
40
|
+
- Keep toast copy short and actionable.
|
|
41
|
+
- In 550px app shells, keep toasts visually aligned to the centered app surface.
|
|
42
|
+
- Use `anchorOrigin` to change placement; default is top-left.
|
|
43
|
+
- Use `isWide` only for messages that need a wider minimum width.
|
|
44
|
+
- `handleClose` should close the toast and should be safe to call from click or timeout.
|
|
45
|
+
|
|
23
46
|
## Modal and Dialog
|
|
24
47
|
|
|
25
48
|
Use `Modal` for focused tasks, confirmations, and compact forms. Keep modal content short and actionable.
|
|
26
49
|
|
|
27
50
|
```tsx
|
|
28
51
|
<Modal open={open} onClose={handleClose} width={420}>
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
52
|
+
<Box display="grid" gap={4}>
|
|
53
|
+
<Typography variant="h2">حذف مورد</Typography>
|
|
54
|
+
<Typography variant="body1">آیا مطمئن هستید؟</Typography>
|
|
55
|
+
<Box display="flex" gap={2} justifyContent="end">
|
|
56
|
+
<Button variant="outlined" buttonSize="XS">لغو</Button>
|
|
57
|
+
<Button variant="contained" color="primary" buttonSize="XS">تایید</Button>
|
|
58
|
+
</Box>
|
|
59
|
+
</Box>
|
|
32
60
|
</Modal>
|
|
33
61
|
```
|
|
34
62
|
|
|
63
|
+
Modal sizing and style:
|
|
64
|
+
|
|
65
|
+
- Paper radius: 12px.
|
|
66
|
+
- Paper margin: 8px on small screens.
|
|
67
|
+
- Backdrop: dark translucent blur.
|
|
68
|
+
- Use explicit `width` for compact dialogs, usually 320px to 420px.
|
|
69
|
+
- Use `gap: 4` inside modal content.
|
|
70
|
+
|
|
35
71
|
Rules:
|
|
36
72
|
|
|
37
|
-
- Always provide a visible close or
|
|
73
|
+
- Always provide a visible close, cancel, or back path.
|
|
38
74
|
- Keep destructive confirmation actions explicit.
|
|
39
75
|
- Avoid putting full pages inside modals.
|
|
76
|
+
- Do not nest cards inside modal content unless they are repeated selectable items.
|
|
77
|
+
|
|
78
|
+
## Drawers
|
|
79
|
+
|
|
80
|
+
Use drawers for bottom-sheet-like mobile tasks such as date selection, filters, and short pickers.
|
|
81
|
+
|
|
82
|
+
Rules:
|
|
83
|
+
|
|
84
|
+
- Control visibility with `isDrawerOpen`.
|
|
85
|
+
- Use `onClose` for backdrop, escape, and close-button behavior.
|
|
86
|
+
- Default `anchor` is bottom; use `anchor="right"` for RTL side navigation drawers.
|
|
87
|
+
- Align drawer content to the 550px app shell when possible.
|
|
88
|
+
- Use `maxWidth: 550` and `mx: "auto"` for drawer roots or content wrappers.
|
|
89
|
+
- Use `px: 3.5`, `py: 6` for drawer body padding.
|
|
90
|
+
- Put the title and close icon in the header row.
|
|
91
|
+
- Use a full-width contained button for the main confirm action.
|
|
40
92
|
|
|
41
93
|
## Loading and Progress
|
|
42
94
|
|
|
@@ -45,3 +97,25 @@ Rules:
|
|
|
45
97
|
- Use `CircularProgress` inside small controls.
|
|
46
98
|
- Use `Skeleton` for content placeholders.
|
|
47
99
|
- Use `ProgressBar` when progress has a known percentage or status.
|
|
100
|
+
|
|
101
|
+
Sizing:
|
|
102
|
+
|
|
103
|
+
- `LoadingModal` content is 150px wide with `gap: 4`.
|
|
104
|
+
- `LoadingModal` opens with `isOpen`.
|
|
105
|
+
- Default progress bar height is 20px.
|
|
106
|
+
- Button loading spinner uses 24px.
|
|
107
|
+
|
|
108
|
+
ProgressBar props:
|
|
109
|
+
|
|
110
|
+
- `progress` is the determinate percentage value.
|
|
111
|
+
- `color` controls the filled bar color.
|
|
112
|
+
- `height` defaults to 20px.
|
|
113
|
+
- Use `disablePercentage` when the label would be redundant or cramped.
|
|
114
|
+
- Use `isRtl` when the filled direction should visually flip for RTL progress.
|
|
115
|
+
|
|
116
|
+
## Empty and Error States
|
|
117
|
+
|
|
118
|
+
- Keep empty states concise.
|
|
119
|
+
- Provide one primary recovery action when the user can fix the state.
|
|
120
|
+
- Use `danger` colors only for real errors and destructive decisions.
|
|
121
|
+
- Use `warning` for reversible risk or caution, not validation failure.
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
- Use controlled components for form values.
|
|
6
6
|
- Use `TextField` instead of raw `<input>`.
|
|
7
|
-
- Put labels on every input unless the context
|
|
7
|
+
- Put labels on every input unless the surrounding context makes the value unmistakable.
|
|
8
8
|
- Use `error` and `helperText` for validation messages.
|
|
9
9
|
- Use 48px control height for default forms.
|
|
10
10
|
- Use RTL layout for Persian forms.
|
|
11
|
+
- Use `gap: 3` to `gap: 4` between related fields.
|
|
12
|
+
- Use `gap: 1` to `gap: 2` between field labels/helper copy and the field.
|
|
13
|
+
- Do not place required fields inside collapsed accordions.
|
|
11
14
|
|
|
12
15
|
## TextField
|
|
13
16
|
|
|
@@ -20,17 +23,62 @@
|
|
|
20
23
|
| `height` | `number` | Explicit field height |
|
|
21
24
|
|
|
22
25
|
```tsx
|
|
26
|
+
import { SearchNormal1 } from "iconsax-react";
|
|
27
|
+
import { TextField, defaultColors } from "injast-core";
|
|
28
|
+
|
|
23
29
|
<TextField
|
|
24
30
|
label="نام"
|
|
25
31
|
value={name}
|
|
26
32
|
onChange={(event) => setName(event.target.value)}
|
|
27
33
|
height={48}
|
|
34
|
+
startAdornment={<SearchNormal1 size={20} color={defaultColors.neutral.main} />}
|
|
35
|
+
/>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Sizing:
|
|
39
|
+
|
|
40
|
+
- Default height: 48px.
|
|
41
|
+
- Radius: 8px.
|
|
42
|
+
- Input adornment icon: 20px.
|
|
43
|
+
- Use `fullWidth` in mobile forms and 550px app shells.
|
|
44
|
+
- Use `dir="ltr"` only for Latin codes, OTP, card numbers, phone-like numeric values, or technical identifiers.
|
|
45
|
+
|
|
46
|
+
## Form Wrappers
|
|
47
|
+
|
|
48
|
+
Use `FormControl`, `InputLabel`, `MenuItem`, and `FormControlLabel` when composing Material UI-compatible form groups.
|
|
49
|
+
|
|
50
|
+
Rules:
|
|
51
|
+
|
|
52
|
+
- Use `FormControl` to bind labels, helper text, and selection controls into one accessible group.
|
|
53
|
+
- Use `InputLabel` with `Select`, `MultiSelect`, or custom field groups that need a floating label.
|
|
54
|
+
- Use `MenuItem` only inside `Select` or menu-like option lists.
|
|
55
|
+
- Use `FormControlLabel` for `Checkbox`, `Radio`, and `Toggle` labels.
|
|
56
|
+
- In RTL forms, use `labelPlacement="start"` when the visual layout needs the control on the trailing side, as in drawer radio lists.
|
|
57
|
+
|
|
58
|
+
## Autocomplete
|
|
59
|
+
|
|
60
|
+
Use `Autocomplete` when users choose from a longer list, need search-as-you-type, or may need multiple searchable selections.
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
<Autocomplete
|
|
64
|
+
options={options}
|
|
65
|
+
getOptionLabel={(option) => option.label}
|
|
66
|
+
renderInput={(params) => (
|
|
67
|
+
<TextField {...params} label="دسته بندی" height={48} fullWidth />
|
|
68
|
+
)}
|
|
28
69
|
/>
|
|
29
70
|
```
|
|
30
71
|
|
|
72
|
+
Rules:
|
|
73
|
+
|
|
74
|
+
- Render the input with Injast `TextField`.
|
|
75
|
+
- Keep the field 48px tall unless the surrounding UI is intentionally dense.
|
|
76
|
+
- Use `multiple` only when selected values are naturally a set.
|
|
77
|
+
- Prefer `Select` for short static lists and `Autocomplete` for longer or searchable lists.
|
|
78
|
+
|
|
31
79
|
## Select and MultiSelect
|
|
32
80
|
|
|
33
|
-
Use `Select` for
|
|
81
|
+
Use `Select` for one value and `MultiSelect` for multiple values.
|
|
34
82
|
|
|
35
83
|
```tsx
|
|
36
84
|
<MultiSelect
|
|
@@ -44,15 +92,74 @@ Use `Select` for a single value and `MultiSelect` for multiple values.
|
|
|
44
92
|
/>
|
|
45
93
|
```
|
|
46
94
|
|
|
95
|
+
Rules:
|
|
96
|
+
|
|
97
|
+
- Use 48px height and 8px radius.
|
|
98
|
+
- `MultiSelect` default `minWidth` is `13rem`; override only when the layout needs a tighter or full-width control.
|
|
99
|
+
- MultiSelect chips use a neutral surface, pill radius, `px: 3`, `py: 1.5`, and compact 18px remove icons.
|
|
100
|
+
- Keep option labels short enough to scan in Persian.
|
|
101
|
+
|
|
47
102
|
## Boolean Inputs
|
|
48
103
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
104
|
+
Use `Checkbox` for independent form choices. The default checkbox icon is 24px with 4px corner radius.
|
|
105
|
+
|
|
106
|
+
Checkbox customization props:
|
|
107
|
+
|
|
108
|
+
| Prop | Use for |
|
|
109
|
+
|---|---|
|
|
110
|
+
| `iconSize` | Custom checkbox square size; default is 24px |
|
|
111
|
+
| `borderColor` | Unchecked border color override |
|
|
112
|
+
| `checkedBorderColor` | Checked border color fallback when theme primary is not available |
|
|
113
|
+
| `backgroundColor` | Checked square background override |
|
|
114
|
+
| `tickColor` | Checkmark color fallback when theme primary is not available |
|
|
115
|
+
|
|
116
|
+
Prefer theme primary and neutral colors before custom checkbox colors.
|
|
117
|
+
|
|
118
|
+
Use `RadioGroup` when the user must choose one option from a short list. Keep radio labels short and avoid more than 5 options before considering a select.
|
|
119
|
+
|
|
120
|
+
Use `Toggle` for settings that take effect as an on/off state.
|
|
121
|
+
|
|
122
|
+
Toggle sizing:
|
|
123
|
+
|
|
124
|
+
| Size | Track |
|
|
125
|
+
|---|---:|
|
|
126
|
+
| `small` | 48px by 26px |
|
|
127
|
+
| `medium` | 59px by 32px |
|
|
128
|
+
|
|
129
|
+
Toggle props:
|
|
130
|
+
|
|
131
|
+
- Use `checked` for controlled on/off state.
|
|
132
|
+
- Use `onChange` to update the controlled value.
|
|
133
|
+
- Use `disabled` when the setting cannot currently change.
|
|
134
|
+
- Use custom `color` only when the theme primary color is not appropriate.
|
|
135
|
+
|
|
136
|
+
## Slider
|
|
137
|
+
|
|
138
|
+
Use `Slider` for bounded numeric ranges where dragging is faster than typing.
|
|
139
|
+
|
|
140
|
+
Rules:
|
|
141
|
+
|
|
142
|
+
- Always provide `min`, `max`, and `step` when the domain is known.
|
|
143
|
+
- Show the current value in nearby text when precision matters.
|
|
144
|
+
- Use `NumberInput` instead when users need exact manual numeric entry.
|
|
145
|
+
- Keep horizontal sliders at least 240px wide on mobile.
|
|
146
|
+
|
|
147
|
+
## Phone Input
|
|
148
|
+
|
|
149
|
+
Use `InputPhoneNumber` for Iranian phone numbers instead of a normal `TextField`.
|
|
150
|
+
|
|
151
|
+
Rules:
|
|
152
|
+
|
|
153
|
+
- It normalizes Persian and Arabic numerals to ASCII digits.
|
|
154
|
+
- It accepts `+98`, `0098`, `98`, and 10-digit mobile numbers that start with `9`, then normalizes to a leading `0`.
|
|
155
|
+
- Default `maxDigitLength` is 11.
|
|
156
|
+
- Use `dir="rtl"` by default; use `dir="ltr"` only when the surrounding form needs Latin number alignment.
|
|
157
|
+
- Pass `inputRef` when parent logic needs focus control.
|
|
158
|
+
- Use `onBlur` for touched/validation behavior.
|
|
52
159
|
|
|
53
160
|
## Numeric Inputs
|
|
54
161
|
|
|
55
|
-
Use `NumberInput` for formatted numeric entry.
|
|
162
|
+
Use `NumberInput` for formatted numeric entry.
|
|
56
163
|
|
|
57
164
|
```tsx
|
|
58
165
|
<NumberInput
|
|
@@ -63,6 +170,62 @@ Use `NumberInput` for formatted numeric entry. Use `fungible` when decimals are
|
|
|
63
170
|
/>
|
|
64
171
|
```
|
|
65
172
|
|
|
66
|
-
|
|
173
|
+
Rules:
|
|
174
|
+
|
|
175
|
+
- Use `fungible` when decimals are allowed.
|
|
176
|
+
- `NumberInput` returns the cleaned numeric string to `onChange`.
|
|
177
|
+
- Use `unit` for currency or measurement labels.
|
|
178
|
+
- Use `hasClearButton` only when reset is a useful action.
|
|
179
|
+
- Pair `hasClearButton` with `onReset`.
|
|
180
|
+
- Use `maxLength` and `minLength` when the numeric identifier has length rules.
|
|
181
|
+
- Do not use `type="number"` raw inputs for Persian numeric forms.
|
|
182
|
+
|
|
183
|
+
## Card and OTP Inputs
|
|
184
|
+
|
|
185
|
+
Use `CardNumberInput` for Iranian bank card numbers. It displays groups with dashes and returns cleaned digits to `onChange`.
|
|
186
|
+
|
|
187
|
+
Rules:
|
|
188
|
+
|
|
189
|
+
- Use `bankLogo` for a 20px bank logo at the start of the field when detected.
|
|
190
|
+
- Use `hasClearButton` only when users often need to reset the field.
|
|
191
|
+
- Pair `hasClearButton` with `onReset`.
|
|
192
|
+
- Keep the visible field RTL context-friendly, but the card number itself behaves as numeric input.
|
|
67
193
|
|
|
68
194
|
Use `OtpInput` for verification codes, not a normal text field.
|
|
195
|
+
|
|
196
|
+
OTP sizing:
|
|
197
|
+
|
|
198
|
+
- Default cell: 54px by 54px.
|
|
199
|
+
- Cell radius: 8px.
|
|
200
|
+
- Cell padding: 8px vertical.
|
|
201
|
+
- Direction: LTR.
|
|
202
|
+
- Text alignment: center.
|
|
203
|
+
- Use 4 or 6 cells depending on the verification flow.
|
|
204
|
+
- Use `focusedBorderColor` to customize the focused cell border.
|
|
205
|
+
- Use `backgroundColor` for a custom cell background only when the product surface requires it.
|
|
206
|
+
- Use the `error` prop to show danger-colored cell borders.
|
|
207
|
+
|
|
208
|
+
Use `IosHiddenOtpInput` only as an invisible iOS one-time-code autofill bridge beside a visible `OtpInput`. It renders a 1px hidden input, focuses on iOS, normalizes Persian/Arabic digits to Latin digits, and calls `onOtpChange`.
|
|
209
|
+
|
|
210
|
+
Rules:
|
|
211
|
+
|
|
212
|
+
- Do not use `IosHiddenOtpInput` as the visible OTP UI.
|
|
213
|
+
- Keep the visible code cells in `OtpInput`.
|
|
214
|
+
- Use it only on client-side screens where `navigator.userAgent` and `document` are available.
|
|
215
|
+
|
|
216
|
+
## CounterBoxInput
|
|
217
|
+
|
|
218
|
+
Use `CounterBoxInput` for stepper-like numeric changes where increment and decrement actions are central to the workflow.
|
|
219
|
+
|
|
220
|
+
Rules:
|
|
221
|
+
|
|
222
|
+
- Default field height is 48px.
|
|
223
|
+
- Plus/minus controls are 32px square.
|
|
224
|
+
- Keep the unit visible when the number depends on currency, inventory, or quantity.
|
|
225
|
+
- Set `min`, `max`, and `step` explicitly when business rules exist.
|
|
226
|
+
- Use `allowFloat` for decimal steps.
|
|
227
|
+
- `defaultValue` is kept for API compatibility; prefer controlled `value`.
|
|
228
|
+
- Use `disabledInput` when the field should only change through plus/minus controls.
|
|
229
|
+
- Use `iconColor` and `iconBackgroundColor` sparingly; prefer neutral defaults.
|
|
230
|
+
- Use `minErrText`, `maxErrText`, and `maxAvailable` for domain-specific bounds.
|
|
231
|
+
- Use `mb` only to reserve vertical space when helper/error text is shown.
|