smartsell-ui-kit 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +118 -0
- package/dist/index.cjs +695 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +141 -0
- package/dist/index.d.ts +141 -0
- package/dist/index.js +662 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SmartSell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# smartsell-ui-kit
|
|
2
|
+
|
|
3
|
+
`smartsell-ui-kit` is the public UI primitives package for SmartSell Sales custom modules.
|
|
4
|
+
|
|
5
|
+
It is designed for tenant developers who should not need to know how the core app is implemented.
|
|
6
|
+
The package stays on the public contract surface:
|
|
7
|
+
|
|
8
|
+
- theme-aware components powered by `smartsell-sales-sdk`
|
|
9
|
+
- inline-style primitives that do not depend on private app CSS files
|
|
10
|
+
- a composable modal helper with predictable slot ids for `header`, `body`, and `footer`
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install react smartsell-sales-sdk smartsell-ui-kit
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Basic button and card
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { Button, Card } from 'smartsell-ui-kit';
|
|
22
|
+
import type { ModulePageProps } from 'smartsell-sales-sdk';
|
|
23
|
+
|
|
24
|
+
export default function ExamplePage({ sdk }: ModulePageProps) {
|
|
25
|
+
return (
|
|
26
|
+
<Card sdk={sdk} title="Example" eyebrow="UI kit">
|
|
27
|
+
<Button sdk={sdk} onClick={() => sdk.navigation.goBack()}>
|
|
28
|
+
Go back
|
|
29
|
+
</Button>
|
|
30
|
+
</Card>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Composable modal pattern
|
|
36
|
+
|
|
37
|
+
Use `ComposableModal` when you want the page to keep modal state while tenants customize visual sections independently.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { ComposableModal, createModalSlotIds } from 'smartsell-ui-kit';
|
|
41
|
+
|
|
42
|
+
const slotIds = createModalSlotIds('order-review');
|
|
43
|
+
|
|
44
|
+
<ComposableModal
|
|
45
|
+
sdk={sdk}
|
|
46
|
+
isOpen={isOpen}
|
|
47
|
+
onClose={() => setIsOpen(false)}
|
|
48
|
+
onConfirm={submitOrder}
|
|
49
|
+
title="Order review"
|
|
50
|
+
description="Validate the order before sending it."
|
|
51
|
+
slotBaseId="order-review"
|
|
52
|
+
payload={{ orderNumber: 'SO-1001', total: 421.9 }}
|
|
53
|
+
>
|
|
54
|
+
<div>Default modal body</div>
|
|
55
|
+
</ComposableModal>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Slot ids generated by `createModalSlotIds('order-review')`:
|
|
59
|
+
|
|
60
|
+
- `order-review:modal-header`
|
|
61
|
+
- `order-review:modal-body`
|
|
62
|
+
- `order-review:modal-footer`
|
|
63
|
+
|
|
64
|
+
Tenant extension example:
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import {
|
|
68
|
+
defineExtensionManifest,
|
|
69
|
+
type ExtensionManifest,
|
|
70
|
+
type SlotComponentProps,
|
|
71
|
+
} from 'smartsell-sales-sdk';
|
|
72
|
+
import {
|
|
73
|
+
Button,
|
|
74
|
+
type ModalSlotContext,
|
|
75
|
+
createModalSlotIds,
|
|
76
|
+
} from 'smartsell-ui-kit';
|
|
77
|
+
|
|
78
|
+
type OrderPayload = {
|
|
79
|
+
orderNumber: string;
|
|
80
|
+
total: number;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
function CustomFooter({ sdk, context }: SlotComponentProps<ModalSlotContext<OrderPayload>>) {
|
|
84
|
+
return (
|
|
85
|
+
<Button sdk={sdk} onClick={() => context?.confirm?.()}>
|
|
86
|
+
Send order {context?.payload?.orderNumber}
|
|
87
|
+
</Button>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const slots = createModalSlotIds('order-review');
|
|
92
|
+
|
|
93
|
+
const manifest: ExtensionManifest = defineExtensionManifest({
|
|
94
|
+
slots: {
|
|
95
|
+
[slots.footer]: {
|
|
96
|
+
action: 'replace',
|
|
97
|
+
component: CustomFooter,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export default manifest;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Why this modal pattern exists
|
|
106
|
+
|
|
107
|
+
- The page owns state, data loading, and permissions.
|
|
108
|
+
- The tenant customizes `header`, `body`, and `footer` through stable slot ids.
|
|
109
|
+
- Slot overrides receive an explicit `context` object instead of relying on private core imports.
|
|
110
|
+
- The same pattern works for many modals without creating a new module type.
|
|
111
|
+
|
|
112
|
+
## Publish
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npm run typecheck
|
|
116
|
+
npm run build
|
|
117
|
+
npm publish
|
|
118
|
+
```
|