@appcorp/stellar-solutions-modules 0.1.34 → 0.1.36
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 +128 -19
- package/components/theme-provider.d.ts +9 -0
- package/components/theme-provider.js +122 -0
- package/components/theme-switcher.d.ts +4 -0
- package/components/theme-switcher.js +60 -0
- package/components/ui/badge.d.ts +9 -0
- package/components/ui/badge.js +82 -0
- package/components/ui/button.d.ts +10 -0
- package/components/ui/button.js +91 -0
- package/components/ui/card.d.ts +9 -0
- package/components/ui/card.js +94 -0
- package/components/ui/checkbox.d.ts +9 -0
- package/components/ui/checkbox.js +87 -0
- package/components/ui/combobox.d.ts +70 -0
- package/components/ui/combobox.js +315 -0
- package/components/ui/command.d.ts +18 -0
- package/components/ui/command.js +115 -0
- package/components/ui/dialog.d.ts +15 -0
- package/components/ui/dialog.js +118 -0
- package/components/ui/drawer.d.ts +13 -0
- package/components/ui/drawer.js +115 -0
- package/components/ui/dropdown-menu.d.ts +25 -0
- package/components/ui/dropdown-menu.js +148 -0
- package/components/ui/enhanced-table-footer-action.d.ts +34 -0
- package/components/ui/enhanced-table-footer-action.js +117 -0
- package/components/ui/enhanced-table-footer-page.d.ts +32 -0
- package/components/ui/enhanced-table-footer-page.js +140 -0
- package/components/ui/enhanced-table-footer-pagination.d.ts +36 -0
- package/components/ui/enhanced-table-footer-pagination.js +122 -0
- package/components/ui/enhanced-table-header-action.d.ts +7 -0
- package/components/ui/enhanced-table-header-action.js +21 -0
- package/components/ui/enhanced-table-header-search.d.ts +12 -0
- package/components/ui/enhanced-table-header-search.js +17 -0
- package/components/ui/enhanced-table.d.ts +65 -0
- package/components/ui/enhanced-table.js +87 -0
- package/components/ui/form.d.ts +24 -0
- package/components/ui/form.js +125 -0
- package/components/ui/input.d.ts +8 -0
- package/components/ui/input.js +86 -0
- package/components/ui/label.d.ts +7 -0
- package/components/ui/label.js +68 -0
- package/components/ui/popover.d.ts +7 -0
- package/components/ui/popover.js +82 -0
- package/components/ui/select.d.ts +15 -0
- package/components/ui/select.js +127 -0
- package/components/ui/separator.d.ts +4 -0
- package/components/ui/separator.js +66 -0
- package/components/ui/sonner.d.ts +4 -0
- package/components/ui/sonner.js +54 -0
- package/components/ui/switch.d.ts +9 -0
- package/components/ui/switch.js +89 -0
- package/components/ui/table.d.ts +10 -0
- package/components/ui/table.js +101 -0
- package/components/ui/textarea.d.ts +8 -0
- package/components/ui/textarea.js +86 -0
- package/global-modules/bank/actions.d.ts +200 -0
- package/global-modules/bank/actions.js +124 -0
- package/global-modules/bank/bank.d.ts +2 -0
- package/global-modules/bank/bank.js +87 -0
- package/global-modules/bank/constants.d.ts +45 -0
- package/global-modules/bank/constants.js +98 -0
- package/global-modules/bank/context.d.ts +41 -0
- package/global-modules/bank/context.js +419 -0
- package/global-modules/bank/drawer.d.ts +31 -0
- package/global-modules/bank/drawer.js +114 -0
- package/global-modules/bank/form.d.ts +22 -0
- package/global-modules/bank/form.js +68 -0
- package/global-modules/bank/reducer.d.ts +25 -0
- package/global-modules/bank/reducer.js +161 -0
- package/global-modules/bank/types.d.ts +217 -0
- package/global-modules/bank/types.js +81 -0
- package/global-modules/bank/validate.d.ts +13 -0
- package/global-modules/bank/validate.js +22 -0
- package/global-modules/branch/actions.d.ts +154 -37
- package/global-modules/branch/actions.js +148 -6
- package/global-modules/branch/branch.d.ts +2 -2
- package/global-modules/branch/branch.js +46 -32
- package/global-modules/branch/constants.d.ts +34 -24
- package/global-modules/branch/constants.js +101 -122
- package/global-modules/branch/context.d.ts +33 -2
- package/global-modules/branch/context.js +195 -164
- package/global-modules/branch/drawer.d.ts +26 -3
- package/global-modules/branch/drawer.js +101 -6
- package/global-modules/branch/form.d.ts +15 -1
- package/global-modules/branch/form.js +54 -71
- package/global-modules/branch/reducer.d.ts +23 -2
- package/global-modules/branch/reducer.js +148 -118
- package/global-modules/branch/types.d.ts +196 -69
- package/global-modules/branch/types.js +66 -7
- package/global-modules/branch/validate.d.ts +1 -1
- package/global-modules/branch/validate.js +15 -11
- package/global-modules/payment-mode/actions.d.ts +154 -37
- package/global-modules/payment-mode/actions.js +148 -6
- package/global-modules/payment-mode/constants.d.ts +34 -17
- package/global-modules/payment-mode/constants.js +90 -66
- package/global-modules/payment-mode/context.d.ts +33 -2
- package/global-modules/payment-mode/context.js +185 -163
- package/global-modules/payment-mode/drawer.d.ts +26 -3
- package/global-modules/payment-mode/drawer.js +104 -9
- package/global-modules/payment-mode/form.d.ts +16 -2
- package/global-modules/payment-mode/form.js +45 -74
- package/global-modules/payment-mode/payment-mode.d.ts +25 -2
- package/global-modules/payment-mode/payment-mode.js +90 -23
- package/global-modules/payment-mode/reducer.d.ts +23 -2
- package/global-modules/payment-mode/reducer.js +140 -114
- package/global-modules/payment-mode/types.d.ts +327 -112
- package/global-modules/payment-mode/types.js +162 -11
- package/global-modules/payment-mode/validate.d.ts +1 -1
- package/global-modules/payment-mode/validate.js +7 -5
- package/global-modules/preferences/actions.d.ts +126 -27
- package/global-modules/preferences/actions.js +128 -4
- package/global-modules/preferences/constants.d.ts +46 -31
- package/global-modules/preferences/constants.js +129 -66
- package/global-modules/preferences/context.d.ts +2 -2
- package/global-modules/preferences/context.js +43 -43
- package/global-modules/preferences/currency.js +15 -10
- package/global-modules/preferences/preferences.d.ts +2 -2
- package/global-modules/preferences/preferences.js +3 -5
- package/global-modules/preferences/validate.d.ts +1 -1
- package/global-modules/preferences/validate.js +7 -7
- package/global-modules/tax/actions.d.ts +155 -38
- package/global-modules/tax/actions.js +149 -7
- package/global-modules/tax/constants.d.ts +31 -39
- package/global-modules/tax/constants.js +83 -114
- package/global-modules/tax/context.d.ts +33 -2
- package/global-modules/tax/context.js +146 -132
- package/global-modules/tax/drawer.d.ts +26 -3
- package/global-modules/tax/drawer.js +101 -6
- package/global-modules/tax/form.d.ts +20 -3
- package/global-modules/tax/form.js +101 -74
- package/global-modules/tax/reducer.d.ts +23 -2
- package/global-modules/tax/reducer.js +143 -24
- package/global-modules/tax/tax.d.ts +25 -2
- package/global-modules/tax/tax.js +92 -28
- package/global-modules/tax/types.d.ts +332 -102
- package/global-modules/tax/types.js +179 -11
- package/global-modules/tax/validate.d.ts +1 -1
- package/global-modules/tax/validate.js +9 -8
- package/hooks/use-rtl.d.ts +44 -0
- package/hooks/use-rtl.js +75 -0
- package/i18n/navigation.d.ts +340 -0
- package/i18n/navigation.js +9 -0
- package/i18n/request.d.ts +2 -0
- package/i18n/request.js +95 -0
- package/i18n/routing.d.ts +18 -0
- package/i18n/routing.js +9 -0
- package/index.d.ts +26 -0
- package/index.js +42 -0
- package/lib/themes.d.ts +147 -0
- package/lib/themes.js +150 -0
- package/lib/toast-utils.d.ts +44 -0
- package/lib/toast-utils.js +212 -0
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +12 -0
- package/package.json +21 -3
- package/supabase/supabase.d.ts +80 -1
- package/supabase/supabase.js +281 -6
- package/global-modules/branch/form-elements.d.ts +0 -3
- package/global-modules/branch/form-elements.js +0 -41
- package/global-modules/payment-mode/form-elements.d.ts +0 -3
- package/global-modules/payment-mode/form-elements.js +0 -41
- package/global-modules/preferences/bank.d.ts +0 -2
- package/global-modules/preferences/bank.js +0 -11
- package/global-modules/preferences/branch-drawer.js +0 -36
- package/global-modules/preferences/branch-form-elements.js +0 -30
- package/global-modules/preferences/branch-form.d.ts +0 -0
- package/global-modules/preferences/branch-form.js +0 -33
- package/global-modules/preferences/branch.d.ts +0 -0
- package/global-modules/preferences/branch.js +0 -106
- package/global-modules/preferences/payment-mode-drawer.d.ts +0 -0
- package/global-modules/preferences/payment-mode-drawer.js +0 -36
- package/global-modules/preferences/payment-mode-form-elements.d.ts +0 -0
- package/global-modules/preferences/payment-mode-form-elements.js +0 -30
- package/global-modules/preferences/payment-mode-form.d.ts +0 -0
- package/global-modules/preferences/payment-mode-form.js +0 -33
- package/global-modules/preferences/payment-mode.d.ts +0 -0
- package/global-modules/preferences/payment-mode.js +0 -94
- package/global-modules/tax/form-elements.d.ts +0 -3
- package/global-modules/tax/form-elements.js +0 -41
- /package/{global-modules/preferences/branch-drawer.d.ts → constants.d.ts} +0 -0
- /package/{global-modules/preferences/branch-form-elements.d.ts → constants.js} +0 -0
|
@@ -1,22 +1,190 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tax Module Types
|
|
4
|
+
*
|
|
5
|
+
* This module defines all TypeScript interfaces, types, and enums for the Tax feature.
|
|
6
|
+
* Provides type safety and clear contracts for all tax-related operations.
|
|
7
|
+
*
|
|
8
|
+
* Type Categories:
|
|
9
|
+
* - Context Types (React context and state management)
|
|
10
|
+
* - Entity Types (Backend data structures)
|
|
11
|
+
* - State Types (Frontend component state)
|
|
12
|
+
* - API Types (Request/response interfaces)
|
|
13
|
+
* - UI Types (Drawer and component enums)
|
|
14
|
+
* - Utility Types (Helper and computed types)
|
|
15
|
+
*
|
|
16
|
+
* Advanced Features:
|
|
17
|
+
* - Tax management with rate calculations
|
|
18
|
+
* - CRUD operations support
|
|
19
|
+
* - Enhanced search and pagination
|
|
20
|
+
*
|
|
21
|
+
* Naming Conventions:
|
|
22
|
+
* - Interfaces: PascalCase with descriptive suffixes (Type, State, Args)
|
|
23
|
+
* - Enums: UPPER_SNAKE_CASE for values, PascalCase for enum names
|
|
24
|
+
* - Types: PascalCase following interface conventions
|
|
25
|
+
*/
|
|
2
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PREFERENCE_MODAL = exports.
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
27
|
+
exports.PREFERENCE_MODAL = exports.formatTaxRate = exports.calculateTaxAmount = exports.getTaxRateAsNumber = exports.getTaxDisplayName = exports.isTaxDefault = exports.isTaxEnabled = exports.isFetchTaxesArgs = exports.isPaymentType = exports.isTaxDrawer = exports.isTaxTypeBE = exports.PAYMENT_TYPE = exports.TAX_DRAWER = void 0;
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// UI ENUMS (Component State Definitions)
|
|
30
|
+
// ============================================================================
|
|
31
|
+
/**
|
|
32
|
+
* Tax Drawer Types
|
|
33
|
+
*
|
|
34
|
+
* Enumeration of all available drawer states for tax UI.
|
|
35
|
+
*/
|
|
36
|
+
var TAX_DRAWER;
|
|
37
|
+
(function (TAX_DRAWER) {
|
|
38
|
+
TAX_DRAWER["FORM_DRAWER"] = "FORM_DRAWER";
|
|
39
|
+
})(TAX_DRAWER || (exports.TAX_DRAWER = TAX_DRAWER = {}));
|
|
40
|
+
/**
|
|
41
|
+
* Payment Types
|
|
42
|
+
*
|
|
43
|
+
* Enumeration of payment type classifications.
|
|
44
|
+
*/
|
|
10
45
|
var PAYMENT_TYPE;
|
|
11
46
|
(function (PAYMENT_TYPE) {
|
|
12
47
|
PAYMENT_TYPE["FULL_PAYMENT"] = "FULL_PAYMENT";
|
|
13
48
|
PAYMENT_TYPE["PARTIAL_PAYMENT"] = "PARTIAL_PAYMENT";
|
|
14
49
|
})(PAYMENT_TYPE || (exports.PAYMENT_TYPE = PAYMENT_TYPE = {}));
|
|
15
|
-
|
|
16
|
-
(
|
|
17
|
-
|
|
18
|
-
|
|
50
|
+
// ============================================================================
|
|
51
|
+
// TYPE GUARDS (Runtime Type Checking)
|
|
52
|
+
// ============================================================================
|
|
53
|
+
/**
|
|
54
|
+
* Type guard to check if object is a valid TaxTypeBE
|
|
55
|
+
*/
|
|
56
|
+
var isTaxTypeBE = function (obj) {
|
|
57
|
+
return (typeof obj === "object" &&
|
|
58
|
+
obj !== null &&
|
|
59
|
+
"id" in obj &&
|
|
60
|
+
"taxName" in obj &&
|
|
61
|
+
"taxRate" in obj &&
|
|
62
|
+
typeof obj.enabled === "boolean" &&
|
|
63
|
+
typeof obj.isDefault === "boolean");
|
|
64
|
+
};
|
|
65
|
+
exports.isTaxTypeBE = isTaxTypeBE;
|
|
66
|
+
/**
|
|
67
|
+
* Type guard to check if string is a valid tax drawer type
|
|
68
|
+
*/
|
|
69
|
+
var isTaxDrawer = function (value) {
|
|
70
|
+
return Object.values(TAX_DRAWER).includes(value);
|
|
71
|
+
};
|
|
72
|
+
exports.isTaxDrawer = isTaxDrawer;
|
|
73
|
+
/**
|
|
74
|
+
* Type guard to check if string is a valid payment type
|
|
75
|
+
*/
|
|
76
|
+
var isPaymentType = function (value) {
|
|
77
|
+
return Object.values(PAYMENT_TYPE).includes(value);
|
|
78
|
+
};
|
|
79
|
+
exports.isPaymentType = isPaymentType;
|
|
80
|
+
/**
|
|
81
|
+
* Type guard to check if object has valid tax filter structure
|
|
82
|
+
*/
|
|
83
|
+
var isFetchTaxesArgs = function (obj) {
|
|
84
|
+
return (typeof obj === "object" &&
|
|
85
|
+
obj !== null &&
|
|
86
|
+
typeof obj.currentPage === "number" &&
|
|
87
|
+
typeof obj.pageLimit === "number");
|
|
88
|
+
};
|
|
89
|
+
exports.isFetchTaxesArgs = isFetchTaxesArgs;
|
|
90
|
+
// ============================================================================
|
|
91
|
+
// UTILITY FUNCTIONS (Type Helpers)
|
|
92
|
+
// ============================================================================
|
|
93
|
+
/**
|
|
94
|
+
* Check if tax is enabled
|
|
95
|
+
*/
|
|
96
|
+
var isTaxEnabled = function (tax) {
|
|
97
|
+
return tax.enabled;
|
|
98
|
+
};
|
|
99
|
+
exports.isTaxEnabled = isTaxEnabled;
|
|
100
|
+
/**
|
|
101
|
+
* Check if tax is default
|
|
102
|
+
*/
|
|
103
|
+
var isTaxDefault = function (tax) {
|
|
104
|
+
return tax.isDefault;
|
|
105
|
+
};
|
|
106
|
+
exports.isTaxDefault = isTaxDefault;
|
|
107
|
+
/**
|
|
108
|
+
* Get tax display name
|
|
109
|
+
*/
|
|
110
|
+
var getTaxDisplayName = function (tax) {
|
|
111
|
+
return tax.taxName;
|
|
112
|
+
};
|
|
113
|
+
exports.getTaxDisplayName = getTaxDisplayName;
|
|
114
|
+
/**
|
|
115
|
+
* Get tax rate as number
|
|
116
|
+
*/
|
|
117
|
+
var getTaxRateAsNumber = function (tax) {
|
|
118
|
+
return parseFloat(tax.taxRate) || 0;
|
|
119
|
+
};
|
|
120
|
+
exports.getTaxRateAsNumber = getTaxRateAsNumber;
|
|
121
|
+
/**
|
|
122
|
+
* Calculate tax amount
|
|
123
|
+
*/
|
|
124
|
+
var calculateTaxAmount = function (amount, tax) {
|
|
125
|
+
var rate = (0, exports.getTaxRateAsNumber)(tax);
|
|
126
|
+
return (amount * rate) / 100;
|
|
127
|
+
};
|
|
128
|
+
exports.calculateTaxAmount = calculateTaxAmount;
|
|
129
|
+
/**
|
|
130
|
+
* Format tax rate for display
|
|
131
|
+
*/
|
|
132
|
+
var formatTaxRate = function (tax) {
|
|
133
|
+
return "".concat(tax.taxRate, "%");
|
|
134
|
+
};
|
|
135
|
+
exports.formatTaxRate = formatTaxRate;
|
|
136
|
+
/**
|
|
137
|
+
* Legacy Preference Modal Enum
|
|
138
|
+
* TODO: Move to preferences module
|
|
139
|
+
*/
|
|
19
140
|
var PREFERENCE_MODAL;
|
|
20
141
|
(function (PREFERENCE_MODAL) {
|
|
21
142
|
PREFERENCE_MODAL["DUMMY"] = "DUMMY";
|
|
22
143
|
})(PREFERENCE_MODAL || (exports.PREFERENCE_MODAL = PREFERENCE_MODAL = {}));
|
|
144
|
+
// ============================================================================
|
|
145
|
+
// OPTIMIZATION SUMMARY
|
|
146
|
+
// ============================================================================
|
|
147
|
+
/*
|
|
148
|
+
* Tax Types File Optimizations Applied:
|
|
149
|
+
*
|
|
150
|
+
* 1. **Comprehensive Documentation**
|
|
151
|
+
* - Added detailed JSDoc comments for all interfaces and types
|
|
152
|
+
* - Organized types into logical categories with clear section headers
|
|
153
|
+
* - Explained purpose and usage for each type definition
|
|
154
|
+
*
|
|
155
|
+
* 2. **Enhanced Type Safety**
|
|
156
|
+
* - Added utility types for common operations (form fields, required fields, etc.)
|
|
157
|
+
* - Implemented runtime type guards for validation
|
|
158
|
+
* - Used more specific Record<string, string> for errors
|
|
159
|
+
* - Added comprehensive API response types for better backend integration
|
|
160
|
+
*
|
|
161
|
+
* 3. **Improved Organization**
|
|
162
|
+
* - Grouped related types into logical sections (Context, Entity, State, API, UI, Utility)
|
|
163
|
+
* - Separated tax specific types from legacy types
|
|
164
|
+
* - Consistent naming conventions throughout
|
|
165
|
+
* - Clear separation between entity, state, and utility types
|
|
166
|
+
*
|
|
167
|
+
* 4. **Developer Experience**
|
|
168
|
+
* - Utility types for common development tasks
|
|
169
|
+
* - Type guards for runtime validation
|
|
170
|
+
* - Helper functions for tax manipulation (calculateTaxAmount, formatTaxRate, etc.)
|
|
171
|
+
* - Comprehensive interfaces with clear field descriptions
|
|
172
|
+
* - Better IDE support through detailed type definitions
|
|
173
|
+
*
|
|
174
|
+
* 5. **Legacy Type Management**
|
|
175
|
+
* - Moved unrelated types to legacy section with TODO comments
|
|
176
|
+
* - Clear migration path for future refactoring
|
|
177
|
+
* - Maintained backward compatibility while organizing properly
|
|
178
|
+
*
|
|
179
|
+
* 6. **Tax-Specific Enhancements**
|
|
180
|
+
* - Tax utility functions (calculateTaxAmount, formatTaxRate, isTaxEnabled, etc.)
|
|
181
|
+
* - Comprehensive API types for all operations
|
|
182
|
+
* - Enhanced form and state type definitions
|
|
183
|
+
* - Tax-specific validation and utility types
|
|
184
|
+
*
|
|
185
|
+
* 7. **Maintainability**
|
|
186
|
+
* - Modular type structure for easy extension
|
|
187
|
+
* - Clear relationships between different type categories
|
|
188
|
+
* - Self-documenting code with comprehensive comments
|
|
189
|
+
* - Consistent patterns for future type additions
|
|
190
|
+
*/
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formValidation = void 0;
|
|
4
4
|
var zod_1 = require("zod");
|
|
5
|
-
|
|
5
|
+
// Validation error messages
|
|
6
|
+
var validationMessages = {
|
|
7
|
+
taxName: "Tax name is required",
|
|
8
|
+
taxRate: "Tax rate is required",
|
|
9
|
+
preferenceId: "Preference ID is required",
|
|
10
|
+
};
|
|
6
11
|
exports.formValidation = zod_1.z.object({
|
|
7
|
-
taxName: zod_1.z
|
|
8
|
-
|
|
9
|
-
.nonempty(constants_1.validationError.taxName),
|
|
10
|
-
taxRate: zod_1.z
|
|
11
|
-
.string()
|
|
12
|
-
.nonempty(constants_1.validationError.taxRate),
|
|
12
|
+
taxName: zod_1.z.string().nonempty(validationMessages.taxName),
|
|
13
|
+
taxRate: zod_1.z.string().nonempty(validationMessages.taxRate),
|
|
13
14
|
enabled: zod_1.z.boolean(),
|
|
14
15
|
isDefault: zod_1.z.boolean(),
|
|
15
16
|
description: zod_1.z.string().optional(),
|
|
16
|
-
preferenceId: zod_1.z.string().nonempty(
|
|
17
|
+
preferenceId: zod_1.z.string().nonempty(validationMessages.preferenceId),
|
|
17
18
|
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to detect RTL (Right-to-Left) layout based on current locale
|
|
3
|
+
* @returns {boolean} true if current locale requires RTL layout (Urdu), false otherwise
|
|
4
|
+
*/
|
|
5
|
+
export declare const useRTL: () => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Hook to get RTL-aware CSS classes
|
|
8
|
+
*
|
|
9
|
+
* @returns Object containing common RTL-aware class combinations
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const rtlClasses = useRTLClasses();
|
|
14
|
+
*
|
|
15
|
+
* // For icon buttons (ensures proper centering in RTL)
|
|
16
|
+
* <Button size="icon" className={`h-8 w-8 ${rtlClasses.iconButton}`}>
|
|
17
|
+
* <Icon />
|
|
18
|
+
* </Button>
|
|
19
|
+
*
|
|
20
|
+
* // For buttons with icon and text
|
|
21
|
+
* <Button className={rtlClasses.iconWithText("left")}>
|
|
22
|
+
* <Icon />
|
|
23
|
+
* <span>Button Text</span>
|
|
24
|
+
* </Button>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const useRTLClasses: () => {
|
|
28
|
+
isRTL: boolean;
|
|
29
|
+
container: string;
|
|
30
|
+
direction: string;
|
|
31
|
+
flexRow: string;
|
|
32
|
+
flexRowReverse: string;
|
|
33
|
+
textAlign: string;
|
|
34
|
+
textAlignReverse: string;
|
|
35
|
+
marginLeft: string;
|
|
36
|
+
marginRight: string;
|
|
37
|
+
paddingLeft: (size: string) => string;
|
|
38
|
+
paddingRight: (size: string) => string;
|
|
39
|
+
gap: (size: string) => string;
|
|
40
|
+
roundedLeft: string;
|
|
41
|
+
roundedRight: string;
|
|
42
|
+
iconButton: string;
|
|
43
|
+
iconWithText: (iconPosition?: "left" | "right") => "flex items-center flex-row-reverse gap-2" | "flex items-center gap-2";
|
|
44
|
+
};
|
package/hooks/use-rtl.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRTLClasses = exports.useRTL = void 0;
|
|
4
|
+
var next_intl_1 = require("next-intl");
|
|
5
|
+
/**
|
|
6
|
+
* Hook to detect RTL (Right-to-Left) layout based on current locale
|
|
7
|
+
* @returns {boolean} true if current locale requires RTL layout (Urdu), false otherwise
|
|
8
|
+
*/
|
|
9
|
+
var useRTL = function () {
|
|
10
|
+
var locale = (0, next_intl_1.useLocale)();
|
|
11
|
+
return locale === "ur";
|
|
12
|
+
};
|
|
13
|
+
exports.useRTL = useRTL;
|
|
14
|
+
/**
|
|
15
|
+
* Hook to get RTL-aware CSS classes
|
|
16
|
+
*
|
|
17
|
+
* @returns Object containing common RTL-aware class combinations
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const rtlClasses = useRTLClasses();
|
|
22
|
+
*
|
|
23
|
+
* // For icon buttons (ensures proper centering in RTL)
|
|
24
|
+
* <Button size="icon" className={`h-8 w-8 ${rtlClasses.iconButton}`}>
|
|
25
|
+
* <Icon />
|
|
26
|
+
* </Button>
|
|
27
|
+
*
|
|
28
|
+
* // For buttons with icon and text
|
|
29
|
+
* <Button className={rtlClasses.iconWithText("left")}>
|
|
30
|
+
* <Icon />
|
|
31
|
+
* <span>Button Text</span>
|
|
32
|
+
* </Button>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
var useRTLClasses = function () {
|
|
36
|
+
var isRTL = (0, exports.useRTL)();
|
|
37
|
+
return {
|
|
38
|
+
isRTL: isRTL,
|
|
39
|
+
// Container classes
|
|
40
|
+
container: isRTL ? "rtl" : "ltr",
|
|
41
|
+
direction: isRTL ? "rtl" : "ltr",
|
|
42
|
+
// Flex classes
|
|
43
|
+
flexRow: isRTL ? "flex-row-reverse" : "flex-row",
|
|
44
|
+
flexRowReverse: isRTL ? "flex-row" : "flex-row-reverse",
|
|
45
|
+
// Text alignment
|
|
46
|
+
textAlign: isRTL ? "text-right" : "text-left",
|
|
47
|
+
textAlignReverse: isRTL ? "text-left" : "text-right",
|
|
48
|
+
// Margin classes
|
|
49
|
+
marginLeft: isRTL ? "mr-auto" : "ml-auto",
|
|
50
|
+
marginRight: isRTL ? "ml-auto" : "mr-auto",
|
|
51
|
+
// Padding classes
|
|
52
|
+
paddingLeft: function (size) { return (isRTL ? "pr-".concat(size) : "pl-".concat(size)); },
|
|
53
|
+
paddingRight: function (size) { return (isRTL ? "pl-".concat(size) : "pr-".concat(size)); },
|
|
54
|
+
// Gap and spacing
|
|
55
|
+
gap: function (size) { return "gap-".concat(size); },
|
|
56
|
+
// Border radius (for buttons, cards, etc.)
|
|
57
|
+
roundedLeft: isRTL ? "rounded-r" : "rounded-l",
|
|
58
|
+
roundedRight: isRTL ? "rounded-l" : "rounded-r",
|
|
59
|
+
// Icon button classes for proper centering in RTL
|
|
60
|
+
iconButton: "flex items-center justify-center border",
|
|
61
|
+
// Icon with text combinations
|
|
62
|
+
iconWithText: function (iconPosition) {
|
|
63
|
+
if (iconPosition === void 0) { iconPosition = "left"; }
|
|
64
|
+
if (iconPosition === "left") {
|
|
65
|
+
return isRTL
|
|
66
|
+
? "flex items-center flex-row-reverse gap-2"
|
|
67
|
+
: "flex items-center gap-2";
|
|
68
|
+
}
|
|
69
|
+
return isRTL
|
|
70
|
+
? "flex items-center gap-2"
|
|
71
|
+
: "flex items-center flex-row-reverse gap-2";
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
exports.useRTLClasses = useRTLClasses;
|