@platform-blocks/ui 0.5.0 → 0.6.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/lib/cjs/index.js +670 -1744
- package/lib/cjs/index.js.map +1 -1
- package/lib/components/Carousel/types.d.ts +14 -0
- package/lib/components/Dialog/Dialog.d.ts +1 -1
- package/lib/components/Dialog/types.d.ts +23 -2
- package/lib/components/HoverCard/types.d.ts +5 -3
- package/lib/components/Image/Image.d.ts +1 -1
- package/lib/components/Image/types.d.ts +3 -3
- package/lib/components/Input/styles.d.ts +1 -12
- package/lib/components/Layout/Layout.d.ts +1 -0
- package/lib/components/Menu/types.d.ts +2 -2
- package/lib/components/Popover/types.d.ts +7 -5
- package/lib/components/Select/Select.types.d.ts +1 -1
- package/lib/components/Skeleton/types.d.ts +2 -2
- package/lib/components/Switch/styles.d.ts +1 -1
- package/lib/components/Table/Table.d.ts +4 -4
- package/lib/components/TextArea/styles.d.ts +1 -1
- package/lib/components/TextArea/types.d.ts +2 -2
- package/lib/components/Timeline/types.d.ts +20 -0
- package/lib/components/Video/types.d.ts +2 -2
- package/lib/components/Waveform/WaveformSkeleton.d.ts +2 -2
- package/lib/components/Waveform/types.d.ts +2 -2
- package/lib/components/index.d.ts +0 -4
- package/lib/components/types.d.ts +0 -1
- package/lib/core/providers/OverlayProvider.d.ts +1 -1
- package/lib/core/theme/PlatformBlocksProvider.d.ts +1 -5
- package/lib/core/utils/layout.d.ts +13 -16
- package/lib/core/utils/positioning-enhanced.d.ts +2 -0
- package/lib/esm/index.js +672 -1725
- package/lib/esm/index.js.map +1 -1
- package/lib/index.d.ts +0 -11
- package/package.json +67 -57
- package/lib/components/Can/Can.d.ts +0 -30
- package/lib/components/Can/PermissionDemo.d.ts +0 -2
- package/lib/components/Can/ability.d.ts +0 -89
- package/lib/components/Can/builder.d.ts +0 -113
- package/lib/components/Can/context.d.ts +0 -25
- package/lib/components/Can/index.d.ts +0 -6
- package/lib/components/Can/types.d.ts +0 -230
- package/lib/components/HoverCard/index.d.ts +0 -2
- package/lib/components/Lottie/Lottie.d.ts +0 -30
- package/lib/components/Lottie/index.d.ts +0 -2
- package/lib/components/NavigationProgress/NavigationProgress.d.ts +0 -4
- package/lib/components/NavigationProgress/defaults.d.ts +0 -8
- package/lib/components/NavigationProgress/hooks/useNavigationProgressState.d.ts +0 -1
- package/lib/components/NavigationProgress/index.d.ts +0 -2
- package/lib/components/NavigationProgress/styles/resolver.d.ts +0 -1
- package/lib/components/NavigationProgress/tokens.d.ts +0 -4
- package/lib/components/NavigationProgress/types.d.ts +0 -30
- package/lib/components/RichTextEditor/RichTextEditor.d.ts +0 -3
- package/lib/components/RichTextEditor/index.d.ts +0 -2
- package/lib/components/RichTextEditor/styles.d.ts +0 -61
- package/lib/components/RichTextEditor/types.d.ts +0 -150
package/lib/index.d.ts
CHANGED
|
@@ -66,7 +66,6 @@ export { PhoneInput } from './components/PhoneInput';
|
|
|
66
66
|
export { ColorPicker } from './components/ColorPicker';
|
|
67
67
|
export { ColorSwatch } from './components/ColorSwatch';
|
|
68
68
|
export { EmojiPicker } from './components/EmojiPicker';
|
|
69
|
-
export { RichTextEditor } from './components/RichTextEditor';
|
|
70
69
|
export { Rating } from './components/Rating';
|
|
71
70
|
export { Form, useFormContext, useOptionalFormContext } from './components/Form';
|
|
72
71
|
export { Breadcrumbs } from './components/Breadcrumbs';
|
|
@@ -95,27 +94,21 @@ export { Skeleton } from './components/Skeleton';
|
|
|
95
94
|
export { Loader } from './components/Loader';
|
|
96
95
|
export { Gauge } from './components/Gauge';
|
|
97
96
|
export { Ring } from './components/Ring';
|
|
98
|
-
export { NavigationProgress, navigationProgress } from './components/NavigationProgress';
|
|
99
97
|
export { Toast, ToastProvider, useToast, useToastApi, onToastsRequested } from './components/Toast';
|
|
100
98
|
export { Dialog, DialogProvider, DialogRenderer, useDialog, useDialogApi, useDialogs, useSimpleDialog, onDialogsRequested } from './components/Dialog';
|
|
101
99
|
export { Tooltip } from './components/Tooltip';
|
|
102
100
|
export { Overlay } from './components/Overlay';
|
|
103
101
|
export { LoadingOverlay } from './components/LoadingOverlay';
|
|
104
|
-
export { HoverCard } from './components/HoverCard';
|
|
105
102
|
export { ContextMenu } from './components/ContextMenu';
|
|
106
103
|
export { Popover } from './components/Popover';
|
|
107
104
|
export { Spotlight, SpotlightProvider, useSpotlightStore, spotlight, createSpotlightStore, useSpotlightStoreInstance, useDirectSpotlightState, directSpotlight, onSpotlightRequested } from './components/Spotlight';
|
|
108
105
|
export { FloatingActions } from './components/FloatingActions';
|
|
109
|
-
export { Can, CanWithConditions, Cannot, PermissionGate, withCan, withCannot } from './components/Can';
|
|
110
|
-
export { PermissionProvider, usePermissions, useAbility } from './components/Can';
|
|
111
|
-
export { AbilityCore, PermissionBuilder, RoleBuilder, PermissionPatterns, permissions, defineAbility, defineRoleAbility } from './components/Can';
|
|
112
106
|
export { Icon } from './components';
|
|
113
107
|
export { IconButton } from './components/IconButton';
|
|
114
108
|
export { Image } from './components/Image';
|
|
115
109
|
export { BrandIcon } from './components/BrandIcon';
|
|
116
110
|
export { Carousel } from './components/Carousel';
|
|
117
111
|
export { Gallery } from './components/Gallery';
|
|
118
|
-
export { Lottie } from './components/Lottie';
|
|
119
112
|
export { Video } from './components/Video';
|
|
120
113
|
export { Waveform } from './components/Waveform';
|
|
121
114
|
export { Collapse } from './components/Collapse';
|
|
@@ -178,7 +171,6 @@ export type { TimePickerInputProps } from './components/TimePickerInput';
|
|
|
178
171
|
export type { PhoneInputProps } from './components/PhoneInput';
|
|
179
172
|
export type { ColorPickerProps } from './components/ColorPicker';
|
|
180
173
|
export type { EmojiPickerProps } from './components/EmojiPicker';
|
|
181
|
-
export type { RichTextEditorProps, RichTextEditorContent, RichTextEditorFormat, RichTextEditorSelection } from './components/RichTextEditor';
|
|
182
174
|
export type { RatingProps } from './components/Rating';
|
|
183
175
|
export type { FormProps } from './components/Form';
|
|
184
176
|
export type { BreadcrumbsProps } from './components/Breadcrumbs';
|
|
@@ -206,18 +198,15 @@ export type { RingProps, RingColorStop, RingRenderContext } from './components/R
|
|
|
206
198
|
export type { ToastProps } from './components/Toast';
|
|
207
199
|
export type { DialogProps, DialogConfig, UseSimpleDialogOptions } from './components/Dialog';
|
|
208
200
|
export type { TooltipProps } from './components/Tooltip';
|
|
209
|
-
export type { HoverCardProps } from './components/HoverCard';
|
|
210
201
|
export type { ContextMenuProps } from './components/ContextMenu';
|
|
211
202
|
export type { PopoverProps, PopoverTargetProps, PopoverDropdownProps } from './components/Popover';
|
|
212
203
|
export type { SpotlightProps } from './components/Spotlight';
|
|
213
|
-
export type { Action, Subject, Field, Conditions, PermissionRule, PermissionCheck, Ability, CanProps, CanWithConditionsProps, CannotProps, PermissionGateProps, PermissionContextValue, PermissionProviderProps, UsePermissionsOptions } from './components/Can';
|
|
214
204
|
export type { BrandIconProps, BrandName } from './components/BrandIcon';
|
|
215
205
|
export type { CollapseProps } from './components/Collapse';
|
|
216
206
|
export type { IconButtonProps } from './components/IconButton';
|
|
217
207
|
export type { CarouselProps } from './components/Carousel';
|
|
218
208
|
export type { GalleryProps, GalleryItem } from './components/Gallery';
|
|
219
209
|
export type { ImageProps } from './components/Image';
|
|
220
|
-
export type { LottieProps } from './components/Lottie';
|
|
221
210
|
export type { WaveformProps } from './components/Waveform';
|
|
222
211
|
export type { DividerProps } from './components/Divider';
|
|
223
212
|
export type { SpaceProps } from './components/Space';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platform-blocks/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "A React Native UI library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/cjs/index.js",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"test:ci": "jest --ci --coverage --maxWorkers=2",
|
|
36
36
|
"test:update": "jest --updateSnapshot",
|
|
37
37
|
"test:component": "jest",
|
|
38
|
-
"lint": "eslint src
|
|
39
|
-
"lint:fix": "eslint src --
|
|
40
|
-
"lint:check": "eslint src --
|
|
41
|
-
"format": "eslint src --
|
|
38
|
+
"lint": "eslint src",
|
|
39
|
+
"lint:fix": "eslint src --fix",
|
|
40
|
+
"lint:check": "eslint src --max-warnings 0",
|
|
41
|
+
"format": "eslint src --fix && echo 'Code formatted successfully!'",
|
|
42
42
|
"precommit": "npm run lint:check && npm run test"
|
|
43
43
|
},
|
|
44
44
|
"keywords": [
|
|
@@ -59,88 +59,98 @@
|
|
|
59
59
|
},
|
|
60
60
|
"homepage": "https://github.com/joshstovall/platform-blocks#readme",
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@babel/core": "^7.
|
|
63
|
-
"@babel/preset-env": "^7.
|
|
64
|
-
"@babel/preset-flow": "^7.27.
|
|
65
|
-
"@babel/preset-react": "^7.
|
|
66
|
-
"@babel/preset-typescript": "^7.
|
|
67
|
-
"@
|
|
68
|
-
"@react-native/babel-preset": "^0.81.4",
|
|
62
|
+
"@babel/core": "^7.28.0",
|
|
63
|
+
"@babel/preset-env": "^7.28.0",
|
|
64
|
+
"@babel/preset-flow": "^7.27.0",
|
|
65
|
+
"@babel/preset-react": "^7.28.0",
|
|
66
|
+
"@babel/preset-typescript": "^7.28.0",
|
|
67
|
+
"@react-native/babel-preset": "^0.83.0",
|
|
69
68
|
"@react-native-masked-view/masked-view": "^0.3.2",
|
|
70
|
-
"@rollup/plugin-commonjs": "^
|
|
69
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
71
70
|
"@rollup/plugin-json": "^6.1.0",
|
|
72
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
73
|
-
"@rollup/plugin-typescript": "^12.
|
|
74
|
-
"@shopify/flash-list": "^2.
|
|
75
|
-
"@testing-library/
|
|
76
|
-
"@
|
|
77
|
-
"@types/
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"eslint": "^
|
|
83
|
-
"eslint-plugin-
|
|
84
|
-
"eslint-plugin-
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"eslint-plugin-unused-imports": "^3.0.0",
|
|
88
|
-
"expo-audio": "^1.0.13",
|
|
89
|
-
"expo-document-picker": "~14.0.7",
|
|
71
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
72
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
73
|
+
"@shopify/flash-list": "^2.2.0",
|
|
74
|
+
"@testing-library/react-native": "^13.3.0",
|
|
75
|
+
"@types/jest": "^30.0.0",
|
|
76
|
+
"@types/react": "^19.2.0",
|
|
77
|
+
"babel-jest": "^30.2.0",
|
|
78
|
+
"eslint": "^9.0.0",
|
|
79
|
+
"eslint-plugin-import": "^2.32.0",
|
|
80
|
+
"eslint-plugin-react": "^7.37.0",
|
|
81
|
+
"eslint-plugin-react-hooks": "^7.0.0",
|
|
82
|
+
"eslint-plugin-react-native": "^5.0.0",
|
|
83
|
+
"eslint-plugin-unused-imports": "^4.3.0",
|
|
84
|
+
"expo-audio": "^1.1.0",
|
|
85
|
+
"expo-document-picker": "^14.0.0",
|
|
90
86
|
"expo-haptics": "^15.0.0",
|
|
91
|
-
"expo-linear-gradient": "^
|
|
92
|
-
"expo-status-bar": "^
|
|
93
|
-
"jest": "^
|
|
94
|
-
"jest-environment-node": "^
|
|
95
|
-
"jest-expo": "^54.0.
|
|
96
|
-
"
|
|
97
|
-
"react": "
|
|
98
|
-
"react-native": "
|
|
99
|
-
"react-native-reanimated": "
|
|
100
|
-
"react-native-
|
|
101
|
-
"react-native-
|
|
102
|
-
"react-native-
|
|
87
|
+
"expo-linear-gradient": "^15.0.0",
|
|
88
|
+
"expo-status-bar": "^3.0.0",
|
|
89
|
+
"jest": "^30.2.0",
|
|
90
|
+
"jest-environment-node": "^30.2.0",
|
|
91
|
+
"jest-expo": "^54.0.0",
|
|
92
|
+
"react": "19.2.0",
|
|
93
|
+
"react-native": "0.83.1",
|
|
94
|
+
"react-native-reanimated": "~4.2.1",
|
|
95
|
+
"react-native-reanimated-carousel": "^4.0.0",
|
|
96
|
+
"react-native-safe-area-context": "^5.6.0",
|
|
97
|
+
"react-native-svg": "15.15.1",
|
|
98
|
+
"react-native-worklets": "0.7.2",
|
|
103
99
|
"react-syntax-highlighter": "^16.1.0",
|
|
104
|
-
"react-test-renderer": "19.
|
|
105
|
-
"rollup": "^4.
|
|
106
|
-
"rollup-plugin-dts": "^6.
|
|
100
|
+
"react-test-renderer": "19.2.0",
|
|
101
|
+
"rollup": "^4.57.0",
|
|
102
|
+
"rollup-plugin-dts": "^6.3.0",
|
|
107
103
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
108
|
-
"typescript": "
|
|
109
|
-
"typescript-eslint": "^8.
|
|
104
|
+
"typescript": "^5.9.0",
|
|
105
|
+
"typescript-eslint": "^8.54.0"
|
|
110
106
|
},
|
|
111
107
|
"peerDependencies": {
|
|
112
|
-
"@react-native-masked-view/masked-view": ">=0.
|
|
108
|
+
"@react-native-masked-view/masked-view": ">=0.3.0",
|
|
113
109
|
"@shopify/flash-list": ">=1.6.0",
|
|
114
|
-
"expo-document-picker": ">=13.0.0",
|
|
115
|
-
"expo-linear-gradient": ">=12.0.0",
|
|
116
110
|
"expo-audio": ">=1.0.0",
|
|
111
|
+
"expo-document-picker": ">=13.0.0",
|
|
117
112
|
"expo-haptics": ">=14.0.0",
|
|
113
|
+
"expo-linear-gradient": ">=12.0.0",
|
|
118
114
|
"expo-status-bar": ">=1.12.0",
|
|
119
|
-
"react": ">=18.0.0
|
|
115
|
+
"react": ">=18.0.0",
|
|
120
116
|
"react-native": ">=0.73.0",
|
|
121
117
|
"react-native-reanimated": ">=3.4.0",
|
|
122
118
|
"react-native-reanimated-carousel": ">=3.4.0",
|
|
123
119
|
"react-native-safe-area-context": ">=4.5.0",
|
|
124
120
|
"react-native-svg": ">=13.0.0",
|
|
121
|
+
"react-native-worklets": ">=0.5.0",
|
|
125
122
|
"react-syntax-highlighter": ">=15.0.0"
|
|
126
123
|
},
|
|
127
124
|
"peerDependenciesMeta": {
|
|
125
|
+
"@react-native-masked-view/masked-view": {
|
|
126
|
+
"optional": true
|
|
127
|
+
},
|
|
128
|
+
"@shopify/flash-list": {
|
|
129
|
+
"optional": true
|
|
130
|
+
},
|
|
128
131
|
"expo-audio": {
|
|
129
132
|
"optional": true
|
|
130
133
|
},
|
|
134
|
+
"expo-document-picker": {
|
|
135
|
+
"optional": true
|
|
136
|
+
},
|
|
131
137
|
"expo-haptics": {
|
|
132
138
|
"optional": true
|
|
133
139
|
},
|
|
140
|
+
"expo-linear-gradient": {
|
|
141
|
+
"optional": true
|
|
142
|
+
},
|
|
134
143
|
"expo-status-bar": {
|
|
135
144
|
"optional": true
|
|
136
145
|
},
|
|
146
|
+
"react-native-reanimated-carousel": {
|
|
147
|
+
"optional": true
|
|
148
|
+
},
|
|
149
|
+
"react-native-worklets": {
|
|
150
|
+
"optional": true
|
|
151
|
+
},
|
|
137
152
|
"react-syntax-highlighter": {
|
|
138
153
|
"optional": true
|
|
139
154
|
}
|
|
140
|
-
},
|
|
141
|
-
"optionalDependencies": {
|
|
142
|
-
"lottie-react": "^2.4.1",
|
|
143
|
-
"@lottiefiles/dotlottie-react": "^0.13.5",
|
|
144
|
-
"lottie-react-native": "^7.3.4"
|
|
145
155
|
}
|
|
146
156
|
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CanProps, CanWithConditionsProps, CannotProps, PermissionGateProps } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Can Component - Renders children if permission is granted
|
|
5
|
-
*/
|
|
6
|
-
export declare const Can: React.FC<CanProps>;
|
|
7
|
-
/**
|
|
8
|
-
* Can Component with conditions - For object-level permissions
|
|
9
|
-
*/
|
|
10
|
-
export declare const CanWithConditions: React.FC<CanWithConditionsProps>;
|
|
11
|
-
/**
|
|
12
|
-
* Cannot Component - Renders children if permission is NOT granted
|
|
13
|
-
*/
|
|
14
|
-
export declare const Cannot: React.FC<CannotProps>;
|
|
15
|
-
/**
|
|
16
|
-
* Permission Gate - Requires ALL permissions to pass
|
|
17
|
-
*/
|
|
18
|
-
export declare const PermissionGate: React.FC<PermissionGateProps>;
|
|
19
|
-
/**
|
|
20
|
-
* Higher-Order Component for permission checking
|
|
21
|
-
*/
|
|
22
|
-
export declare function withCan<P extends object>(action: string, subject?: any, field?: string): (Component: React.ComponentType<P>) => React.FC<P & {
|
|
23
|
-
fallback?: React.ReactNode;
|
|
24
|
-
}>;
|
|
25
|
-
/**
|
|
26
|
-
* Higher-Order Component for permission denial checking
|
|
27
|
-
*/
|
|
28
|
-
export declare function withCannot<P extends object>(action: string, subject?: any, field?: string): (Component: React.ComponentType<P>) => React.FC<P & {
|
|
29
|
-
fallback?: React.ReactNode;
|
|
30
|
-
}>;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { Action, Subject, Field, PermissionRule, PermissionCheck, Ability } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Core Ability class for managing permissions
|
|
4
|
-
*/
|
|
5
|
-
export declare class AbilityCore implements Ability {
|
|
6
|
-
private rules;
|
|
7
|
-
private cache;
|
|
8
|
-
constructor(rules?: PermissionRule[]);
|
|
9
|
-
/**
|
|
10
|
-
* Check if action is allowed on subject
|
|
11
|
-
*/
|
|
12
|
-
can(action: Action, subject: Subject, field?: Field): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Check if action is forbidden on subject
|
|
15
|
-
*/
|
|
16
|
-
cannot(action: Action, subject: Subject, field?: Field): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Get detailed permission check result
|
|
19
|
-
*/
|
|
20
|
-
check(action: Action, subject: Subject, field?: Field): PermissionCheck;
|
|
21
|
-
/**
|
|
22
|
-
* Update ability rules and clear cache
|
|
23
|
-
*/
|
|
24
|
-
update(rules: PermissionRule[]): void;
|
|
25
|
-
/**
|
|
26
|
-
* Get all current rules
|
|
27
|
-
*/
|
|
28
|
-
getRules(): PermissionRule[];
|
|
29
|
-
/**
|
|
30
|
-
* Clear all rules and cache
|
|
31
|
-
*/
|
|
32
|
-
clear(): void;
|
|
33
|
-
/**
|
|
34
|
-
* Perform the actual permission check
|
|
35
|
-
*/
|
|
36
|
-
private performCheck;
|
|
37
|
-
/**
|
|
38
|
-
* Check if a rule matches the current permission check
|
|
39
|
-
*/
|
|
40
|
-
private ruleMatches;
|
|
41
|
-
/**
|
|
42
|
-
* Check if subject matches any of the rule subjects
|
|
43
|
-
*/
|
|
44
|
-
private subjectMatches;
|
|
45
|
-
/**
|
|
46
|
-
* Check if conditions match the subject object
|
|
47
|
-
*/
|
|
48
|
-
private conditionsMatch;
|
|
49
|
-
/**
|
|
50
|
-
* Check if two values match (handles various comparison types)
|
|
51
|
-
*/
|
|
52
|
-
private valuesMatch;
|
|
53
|
-
/**
|
|
54
|
-
* Generate cache key for permission check
|
|
55
|
-
*/
|
|
56
|
-
private getCacheKey;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Create a new Ability instance
|
|
60
|
-
*/
|
|
61
|
-
export declare function createAbility(rules?: PermissionRule[]): Ability;
|
|
62
|
-
/**
|
|
63
|
-
* Helper to create permission rules
|
|
64
|
-
*/
|
|
65
|
-
export declare const definePermissions: (rules: PermissionRule[]) => PermissionRule[];
|
|
66
|
-
/**
|
|
67
|
-
* Common permission actions
|
|
68
|
-
*/
|
|
69
|
-
export declare const Actions: {
|
|
70
|
-
readonly CREATE: "create";
|
|
71
|
-
readonly READ: "read";
|
|
72
|
-
readonly UPDATE: "update";
|
|
73
|
-
readonly DELETE: "delete";
|
|
74
|
-
readonly MANAGE: "manage";
|
|
75
|
-
readonly VIEW: "view";
|
|
76
|
-
readonly EDIT: "edit";
|
|
77
|
-
readonly PUBLISH: "publish";
|
|
78
|
-
readonly ARCHIVE: "archive";
|
|
79
|
-
readonly APPROVE: "approve";
|
|
80
|
-
readonly REJECT: "reject";
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Helper to create subject types
|
|
84
|
-
*/
|
|
85
|
-
export declare const subject: (type: string, data?: object) => object;
|
|
86
|
-
/**
|
|
87
|
-
* Check if subject is of specific type
|
|
88
|
-
*/
|
|
89
|
-
export declare const subjectType: (subject: any) => string;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { AbilityCore } from './ability';
|
|
2
|
-
import { PermissionRule } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Fluent API for building permissions
|
|
5
|
-
*/
|
|
6
|
-
export declare class PermissionBuilder {
|
|
7
|
-
private rules;
|
|
8
|
-
/**
|
|
9
|
-
* Grant permission
|
|
10
|
-
*/
|
|
11
|
-
allow(action: string, subject?: any, field?: string): this;
|
|
12
|
-
/**
|
|
13
|
-
* Deny permission
|
|
14
|
-
*/
|
|
15
|
-
forbid(action: string, subject?: any, field?: string): this;
|
|
16
|
-
/**
|
|
17
|
-
* Conditional permission
|
|
18
|
-
*/
|
|
19
|
-
allowIf(action: string, subject?: any, conditions?: Record<string, any>, field?: string): this;
|
|
20
|
-
/**
|
|
21
|
-
* Conditional denial
|
|
22
|
-
*/
|
|
23
|
-
forbidIf(action: string, subject?: any, conditions?: Record<string, any>, field?: string): this;
|
|
24
|
-
/**
|
|
25
|
-
* Grant all actions on a subject
|
|
26
|
-
*/
|
|
27
|
-
manage(subject: any): this;
|
|
28
|
-
/**
|
|
29
|
-
* Forbid all actions on a subject
|
|
30
|
-
*/
|
|
31
|
-
forbidAll(subject: any): this;
|
|
32
|
-
/**
|
|
33
|
-
* Role-based permissions
|
|
34
|
-
*/
|
|
35
|
-
role(roleName: string, callback: (role: RoleBuilder) => void): this;
|
|
36
|
-
/**
|
|
37
|
-
* Build the ability with all rules
|
|
38
|
-
*/
|
|
39
|
-
build(): AbilityCore;
|
|
40
|
-
/**
|
|
41
|
-
* Get all rules
|
|
42
|
-
*/
|
|
43
|
-
getRules(): PermissionRule[];
|
|
44
|
-
/**
|
|
45
|
-
* Clear all rules
|
|
46
|
-
*/
|
|
47
|
-
clear(): this;
|
|
48
|
-
/**
|
|
49
|
-
* Merge rules from another builder
|
|
50
|
-
*/
|
|
51
|
-
merge(other: PermissionBuilder): this;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Role-specific permission builder
|
|
55
|
-
*/
|
|
56
|
-
export declare class RoleBuilder {
|
|
57
|
-
private roleName;
|
|
58
|
-
private rules;
|
|
59
|
-
constructor(roleName: string);
|
|
60
|
-
/**
|
|
61
|
-
* Grant permission for this role
|
|
62
|
-
*/
|
|
63
|
-
can(action: string, subject?: any, field?: string): this;
|
|
64
|
-
/**
|
|
65
|
-
* Deny permission for this role
|
|
66
|
-
*/
|
|
67
|
-
cannot(action: string, subject?: any, field?: string): this;
|
|
68
|
-
/**
|
|
69
|
-
* Manage all actions on subject for this role
|
|
70
|
-
*/
|
|
71
|
-
manage(subject: any): this;
|
|
72
|
-
/**
|
|
73
|
-
* Get all rules for this role
|
|
74
|
-
*/
|
|
75
|
-
getRules(): PermissionRule[];
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Common permission patterns
|
|
79
|
-
*/
|
|
80
|
-
export declare class PermissionPatterns {
|
|
81
|
-
/**
|
|
82
|
-
* Admin permissions - can do everything
|
|
83
|
-
*/
|
|
84
|
-
static admin(): PermissionBuilder;
|
|
85
|
-
/**
|
|
86
|
-
* User permissions - basic CRUD on own resources
|
|
87
|
-
*/
|
|
88
|
-
static user(userId: string): PermissionBuilder;
|
|
89
|
-
/**
|
|
90
|
-
* Guest permissions - read-only public content
|
|
91
|
-
*/
|
|
92
|
-
static guest(): PermissionBuilder;
|
|
93
|
-
/**
|
|
94
|
-
* Moderator permissions - manage content but not users
|
|
95
|
-
*/
|
|
96
|
-
static moderator(): PermissionBuilder;
|
|
97
|
-
/**
|
|
98
|
-
* Owner permissions - full control over owned resources
|
|
99
|
-
*/
|
|
100
|
-
static owner(ownerId: string): PermissionBuilder;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Helper function to create a new permission builder
|
|
104
|
-
*/
|
|
105
|
-
export declare function permissions(): PermissionBuilder;
|
|
106
|
-
/**
|
|
107
|
-
* Helper function to create ability from rules array
|
|
108
|
-
*/
|
|
109
|
-
export declare function defineAbility(callback: (builder: PermissionBuilder) => void): AbilityCore;
|
|
110
|
-
/**
|
|
111
|
-
* Helper function to create common role-based abilities
|
|
112
|
-
*/
|
|
113
|
-
export declare function defineRoleAbility(role: string, callback: (role: RoleBuilder) => void): AbilityCore;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PermissionProviderProps, PermissionContextValue } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Permission Provider Component
|
|
5
|
-
*/
|
|
6
|
-
export declare const PermissionProvider: React.FC<PermissionProviderProps>;
|
|
7
|
-
/**
|
|
8
|
-
* Hook to access permission context
|
|
9
|
-
*/
|
|
10
|
-
export declare const usePermissions: (options?: {
|
|
11
|
-
required?: boolean;
|
|
12
|
-
debug?: boolean;
|
|
13
|
-
}) => PermissionContextValue;
|
|
14
|
-
/**
|
|
15
|
-
* Hook to check a specific permission
|
|
16
|
-
*/
|
|
17
|
-
export declare const useCan: (action: string, subject: any, field?: string) => boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Hook to check if permission is denied
|
|
20
|
-
*/
|
|
21
|
-
export declare const useCannot: (action: string, subject: any, field?: string) => boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Hook to get the current ability instance
|
|
24
|
-
*/
|
|
25
|
-
export declare const useAbility: () => import("./types").Ability;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { Can, CanWithConditions, Cannot, PermissionGate, withCan, withCannot } from './Can';
|
|
2
|
-
export { PermissionProvider, usePermissions, useAbility } from './context';
|
|
3
|
-
export { AbilityCore } from './ability';
|
|
4
|
-
export { PermissionBuilder, RoleBuilder, PermissionPatterns, permissions, defineAbility, defineRoleAbility } from './builder';
|
|
5
|
-
export type { Action, Subject, Field, Conditions, PermissionRule, PermissionCheck, Ability, CanProps, CanWithConditionsProps, CannotProps, PermissionGateProps, PermissionContextValue, PermissionProviderProps, UsePermissionsOptions } from './types';
|
|
6
|
-
export { AbilityCore as PermissionAbility } from './ability';
|