@schandlergarcia/sf-web-components 1.0.0
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/.a4drules/skills/building-data-visualization/SKILL.md +72 -0
- package/.a4drules/skills/building-data-visualization/implementation/bar-line-chart.md +316 -0
- package/.a4drules/skills/building-data-visualization/implementation/dashboard-layout.md +189 -0
- package/.a4drules/skills/building-data-visualization/implementation/donut-chart.md +181 -0
- package/.a4drules/skills/building-data-visualization/implementation/stat-card.md +150 -0
- package/.a4drules/skills/building-react-components/SKILL.md +96 -0
- package/.a4drules/skills/building-react-components/implementation/component.md +78 -0
- package/.a4drules/skills/building-react-components/implementation/header-footer.md +132 -0
- package/.a4drules/skills/building-react-components/implementation/page.md +93 -0
- package/.a4drules/skills/configuring-csp-trusted-sites/SKILL.md +90 -0
- package/.a4drules/skills/configuring-csp-trusted-sites/implementation/metadata-format.md +281 -0
- package/.a4drules/skills/configuring-webapp-metadata/SKILL.md +158 -0
- package/.a4drules/skills/creating-webapp/SKILL.md +140 -0
- package/.a4drules/skills/deploying-to-salesforce/SKILL.md +226 -0
- package/.a4drules/skills/implementing-file-upload/SKILL.md +396 -0
- package/.a4drules/skills/installing-webapp-features/SKILL.md +210 -0
- package/.a4drules/skills/managing-agentforce-conversation-client/SKILL.md +186 -0
- package/.a4drules/skills/managing-agentforce-conversation-client/references/constraints.md +134 -0
- package/.a4drules/skills/managing-agentforce-conversation-client/references/examples.md +132 -0
- package/.a4drules/skills/managing-agentforce-conversation-client/references/style-tokens.md +101 -0
- package/.a4drules/skills/managing-agentforce-conversation-client/references/troubleshooting.md +57 -0
- package/.a4drules/skills/using-salesforce-data/SKILL.md +363 -0
- package/.a4drules/skills/using-salesforce-data/graphql-search.sh +139 -0
- package/.a4drules/webapp-data.md +353 -0
- package/.a4drules/webapp-ui.md +16 -0
- package/README.md +124 -0
- package/dist/components/library/cards/ActionList.js +27 -0
- package/dist/components/library/cards/ActionList.js.map +1 -0
- package/dist/components/library/cards/ActivityCard.js +40 -0
- package/dist/components/library/cards/ActivityCard.js.map +1 -0
- package/dist/components/library/cards/BaseCard.js +89 -0
- package/dist/components/library/cards/BaseCard.js.map +1 -0
- package/dist/components/library/cards/CalloutCard.js +28 -0
- package/dist/components/library/cards/CalloutCard.js.map +1 -0
- package/dist/components/library/cards/ChartCard.js +79 -0
- package/dist/components/library/cards/ChartCard.js.map +1 -0
- package/dist/components/library/cards/FeedPanel.js +38 -0
- package/dist/components/library/cards/FeedPanel.js.map +1 -0
- package/dist/components/library/cards/ListCard.js +112 -0
- package/dist/components/library/cards/ListCard.js.map +1 -0
- package/dist/components/library/cards/MetricCard.js +86 -0
- package/dist/components/library/cards/MetricCard.js.map +1 -0
- package/dist/components/library/cards/MetricsStrip.js +60 -0
- package/dist/components/library/cards/MetricsStrip.js.map +1 -0
- package/dist/components/library/cards/SectionCard.js +59 -0
- package/dist/components/library/cards/SectionCard.js.map +1 -0
- package/dist/components/library/cards/StatusCard.js +137 -0
- package/dist/components/library/cards/StatusCard.js.map +1 -0
- package/dist/components/library/cards/TableCard.js +244 -0
- package/dist/components/library/cards/TableCard.js.map +1 -0
- package/dist/components/library/cards/WidgetCard.js +60 -0
- package/dist/components/library/cards/WidgetCard.js.map +1 -0
- package/dist/components/library/charts/D3Chart.js +74 -0
- package/dist/components/library/charts/D3Chart.js.map +1 -0
- package/dist/components/library/charts/D3ChartTemplates.js +44 -0
- package/dist/components/library/charts/D3ChartTemplates.js.map +1 -0
- package/dist/components/library/charts/GeoMap.js +229 -0
- package/dist/components/library/charts/GeoMap.js.map +1 -0
- package/dist/components/library/chat/ChatBar.js +194 -0
- package/dist/components/library/chat/ChatBar.js.map +1 -0
- package/dist/components/library/chat/ChatInput.js +67 -0
- package/dist/components/library/chat/ChatInput.js.map +1 -0
- package/dist/components/library/chat/ChatMessage.js +112 -0
- package/dist/components/library/chat/ChatMessage.js.map +1 -0
- package/dist/components/library/chat/ChatMessageList.js +50 -0
- package/dist/components/library/chat/ChatMessageList.js.map +1 -0
- package/dist/components/library/chat/ChatPanel.js +77 -0
- package/dist/components/library/chat/ChatPanel.js.map +1 -0
- package/dist/components/library/chat/ChatSuggestions.js +22 -0
- package/dist/components/library/chat/ChatSuggestions.js.map +1 -0
- package/dist/components/library/chat/ChatToolCall.js +87 -0
- package/dist/components/library/chat/ChatToolCall.js.map +1 -0
- package/dist/components/library/chat/ChatTypingIndicator.js +20 -0
- package/dist/components/library/chat/ChatTypingIndicator.js.map +1 -0
- package/dist/components/library/chat/ChatWelcome.js +24 -0
- package/dist/components/library/chat/ChatWelcome.js.map +1 -0
- package/dist/components/library/chat/useChatState.js +77 -0
- package/dist/components/library/chat/useChatState.js.map +1 -0
- package/dist/components/library/data/DataModeProvider.js +47 -0
- package/dist/components/library/data/DataModeProvider.js.map +1 -0
- package/dist/components/library/data/DataModeToggle.js +28 -0
- package/dist/components/library/data/DataModeToggle.js.map +1 -0
- package/dist/components/library/data/filterUtils.js +71 -0
- package/dist/components/library/data/filterUtils.js.map +1 -0
- package/dist/components/library/data/useDataSource.js +13 -0
- package/dist/components/library/data/useDataSource.js.map +1 -0
- package/dist/components/library/data/usePageFilters.js +46 -0
- package/dist/components/library/data/usePageFilters.js.map +1 -0
- package/dist/components/library/filters/FilterBar.js +89 -0
- package/dist/components/library/filters/FilterBar.js.map +1 -0
- package/dist/components/library/filters/SearchFilter.js +44 -0
- package/dist/components/library/filters/SearchFilter.js.map +1 -0
- package/dist/components/library/filters/SelectFilter.js +44 -0
- package/dist/components/library/filters/SelectFilter.js.map +1 -0
- package/dist/components/library/filters/ToggleFilter.js +48 -0
- package/dist/components/library/filters/ToggleFilter.js.map +1 -0
- package/dist/components/library/forms/FormField.js +256 -0
- package/dist/components/library/forms/FormField.js.map +1 -0
- package/dist/components/library/forms/FormModal.js +161 -0
- package/dist/components/library/forms/FormModal.js.map +1 -0
- package/dist/components/library/forms/FormRenderer.js +32 -0
- package/dist/components/library/forms/FormRenderer.js.map +1 -0
- package/dist/components/library/forms/FormSection.js +49 -0
- package/dist/components/library/forms/FormSection.js.map +1 -0
- package/dist/components/library/forms/useFormState.js +85 -0
- package/dist/components/library/forms/useFormState.js.map +1 -0
- package/dist/components/library/heroui/Accordion.js +12 -0
- package/dist/components/library/heroui/Accordion.js.map +1 -0
- package/dist/components/library/heroui/Alert.js +12 -0
- package/dist/components/library/heroui/Alert.js.map +1 -0
- package/dist/components/library/heroui/Badge.js +12 -0
- package/dist/components/library/heroui/Badge.js.map +1 -0
- package/dist/components/library/heroui/Breadcrumbs.js +12 -0
- package/dist/components/library/heroui/Breadcrumbs.js.map +1 -0
- package/dist/components/library/heroui/Button.js +18 -0
- package/dist/components/library/heroui/Button.js.map +1 -0
- package/dist/components/library/heroui/Card.js +12 -0
- package/dist/components/library/heroui/Card.js.map +1 -0
- package/dist/components/library/heroui/Drawer.js +12 -0
- package/dist/components/library/heroui/Drawer.js.map +1 -0
- package/dist/components/library/heroui/Dropdown.js +12 -0
- package/dist/components/library/heroui/Dropdown.js.map +1 -0
- package/dist/components/library/heroui/Input.js +10 -0
- package/dist/components/library/heroui/Input.js.map +1 -0
- package/dist/components/library/heroui/Kbd.js +12 -0
- package/dist/components/library/heroui/Kbd.js.map +1 -0
- package/dist/components/library/heroui/Meter.js +12 -0
- package/dist/components/library/heroui/Meter.js.map +1 -0
- package/dist/components/library/heroui/Modal.js +12 -0
- package/dist/components/library/heroui/Modal.js.map +1 -0
- package/dist/components/library/heroui/Pagination.js +12 -0
- package/dist/components/library/heroui/Pagination.js.map +1 -0
- package/dist/components/library/heroui/ProgressBar.js +12 -0
- package/dist/components/library/heroui/ProgressBar.js.map +1 -0
- package/dist/components/library/heroui/ProgressCircle.js +12 -0
- package/dist/components/library/heroui/ProgressCircle.js.map +1 -0
- package/dist/components/library/heroui/ScrollShadow.js +12 -0
- package/dist/components/library/heroui/ScrollShadow.js.map +1 -0
- package/dist/components/library/heroui/Select.js +12 -0
- package/dist/components/library/heroui/Select.js.map +1 -0
- package/dist/components/library/heroui/Separator.js +12 -0
- package/dist/components/library/heroui/Separator.js.map +1 -0
- package/dist/components/library/heroui/Skeleton.js +12 -0
- package/dist/components/library/heroui/Skeleton.js.map +1 -0
- package/dist/components/library/heroui/Tabs.js +12 -0
- package/dist/components/library/heroui/Tabs.js.map +1 -0
- package/dist/components/library/heroui/Toast.js +13 -0
- package/dist/components/library/heroui/Toast.js.map +1 -0
- package/dist/components/library/heroui/Toggle.js +12 -0
- package/dist/components/library/heroui/Toggle.js.map +1 -0
- package/dist/components/library/heroui/Tooltip.js +12 -0
- package/dist/components/library/heroui/Tooltip.js.map +1 -0
- package/dist/components/library/layout/PageContainer.js +9 -0
- package/dist/components/library/layout/PageContainer.js.map +1 -0
- package/dist/components/library/skeletons/CardSkeleton.js +29 -0
- package/dist/components/library/skeletons/CardSkeleton.js.map +1 -0
- package/dist/components/library/theme/AppThemeProvider.js +55 -0
- package/dist/components/library/theme/AppThemeProvider.js.map +1 -0
- package/dist/components/library/theme/tokens.js +55 -0
- package/dist/components/library/theme/tokens.js.map +1 -0
- package/dist/components/library/ui/Avatar.js +33 -0
- package/dist/components/library/ui/Avatar.js.map +1 -0
- package/dist/components/library/ui/Button.js +50 -0
- package/dist/components/library/ui/Button.js.map +1 -0
- package/dist/components/library/ui/Card.js +21 -0
- package/dist/components/library/ui/Card.js.map +1 -0
- package/dist/components/library/ui/Chip.js +31 -0
- package/dist/components/library/ui/Chip.js.map +1 -0
- package/dist/components/library/ui/Container.js +42 -0
- package/dist/components/library/ui/Container.js.map +1 -0
- package/dist/components/library/ui/EmptyState.js +27 -0
- package/dist/components/library/ui/EmptyState.js.map +1 -0
- package/dist/components/library/ui/Input.js +22 -0
- package/dist/components/library/ui/Input.js.map +1 -0
- package/dist/components/library/ui/Spinner.js +64 -0
- package/dist/components/library/ui/Spinner.js.map +1 -0
- package/dist/components/library/ui/Text.js +43 -0
- package/dist/components/library/ui/Text.js.map +1 -0
- package/dist/components/library/ui/Toggle.js +47 -0
- package/dist/components/library/ui/Toggle.js.map +1 -0
- package/dist/components/workspace/ComponentRegistry.js +231 -0
- package/dist/components/workspace/ComponentRegistry.js.map +1 -0
- package/dist/index.js +185 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/utils.js +9 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/node_modules/clsx/dist/clsx.js +17 -0
- package/dist/node_modules/clsx/dist/clsx.js.map +1 -0
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +2925 -0
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -0
- package/package.json +81 -0
- package/scripts/get-graphql-schema.mjs +68 -0
- package/scripts/reset-command-center.sh +358 -0
- package/scripts/rewrite-e2e-assets.mjs +23 -0
- package/scripts/validate-dashboard.sh +290 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
# Salesforce Data Access
|
|
2
|
+
|
|
3
|
+
- **Fetch or display Salesforce data** — Query records (Account, Contact, Opportunity, custom objects) to show in a component
|
|
4
|
+
- **Create, update, or delete records** — Perform mutations on Salesforce data
|
|
5
|
+
- **Add data fetching to a component** — Wire up a React component to Salesforce data
|
|
6
|
+
- **Call REST APIs** — Use Connect REST, Apex REST, or UI API endpoints
|
|
7
|
+
- **Explore the org schema** — Discover available objects, fields, or relationships
|
|
8
|
+
|
|
9
|
+
## Data SDK Requirement
|
|
10
|
+
|
|
11
|
+
> **All Salesforce data access MUST use the Data SDK** (`@salesforce/sdk-data`). The SDK handles authentication, CSRF, and base URL resolution. Never use `fetch()` or `axios` directly.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { createDataSDK, gql } from "@salesforce/sdk-data";
|
|
15
|
+
|
|
16
|
+
const sdk = await createDataSDK();
|
|
17
|
+
|
|
18
|
+
// GraphQL for record queries/mutations (PREFERRED)
|
|
19
|
+
const response = await sdk.graphql?.<ResponseType>(query, variables);
|
|
20
|
+
|
|
21
|
+
// REST for Connect REST, Apex REST, UI API (when GraphQL insufficient)
|
|
22
|
+
const res = await sdk.fetch?.("/services/apexrest/my-resource");
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Always use optional chaining** (`sdk.graphql?.()`, `sdk.fetch?.()`) — these methods may be undefined in some surfaces.
|
|
26
|
+
|
|
27
|
+
## Supported APIs
|
|
28
|
+
|
|
29
|
+
**Only the following APIs are permitted.** Any endpoint not listed here must not be used.
|
|
30
|
+
|
|
31
|
+
| API | Method | Endpoints / Use Case |
|
|
32
|
+
|-----|--------|----------------------|
|
|
33
|
+
| GraphQL | `sdk.graphql` | All record queries and mutations via `uiapi { }` namespace |
|
|
34
|
+
| UI API REST | `sdk.fetch` | `/services/data/v{ver}/ui-api/records/{id}` — record metadata when GraphQL is insufficient |
|
|
35
|
+
| Apex REST | `sdk.fetch` | `/services/apexrest/{resource}` — custom server-side logic, aggregates, multi-step transactions |
|
|
36
|
+
| Connect REST | `sdk.fetch` | `/services/data/v{ver}/connect/file/upload/config` — file upload config |
|
|
37
|
+
| Einstein LLM | `sdk.fetch` | `/services/data/v{ver}/einstein/llm/prompt/generations` — AI text generation |
|
|
38
|
+
|
|
39
|
+
**Not supported:**
|
|
40
|
+
|
|
41
|
+
- **Enterprise REST query endpoint** (`/services/data/v*/query` with SOQL) — blocked at the proxy level. Use GraphQL for record reads; use Apex REST if server-side SOQL aggregates are required.
|
|
42
|
+
- **Aura-enabled Apex** (`@AuraEnabled`) — an LWC/Aura pattern with no invocation path from React webapps.
|
|
43
|
+
- **Chatter API** (`/chatter/users/me`) — use `uiapi { currentUser { ... } }` in a GraphQL query instead.
|
|
44
|
+
- **Any other Salesforce REST endpoint** not listed in the supported table above.
|
|
45
|
+
|
|
46
|
+
## Decision: GraphQL vs REST
|
|
47
|
+
|
|
48
|
+
| Need | Method | Example |
|
|
49
|
+
|------|--------|---------|
|
|
50
|
+
| Query/mutate records | `sdk.graphql` | Account, Contact, custom objects |
|
|
51
|
+
| Current user info | `sdk.graphql` | `uiapi { currentUser { Id Name { value } } }` |
|
|
52
|
+
| UI API record metadata | `sdk.fetch` | `/ui-api/records/{id}` |
|
|
53
|
+
| Connect REST | `sdk.fetch` | `/connect/file/upload/config` |
|
|
54
|
+
| Apex REST | `sdk.fetch` | `/services/apexrest/auth/login` |
|
|
55
|
+
| Einstein LLM | `sdk.fetch` | `/einstein/llm/prompt/generations` |
|
|
56
|
+
|
|
57
|
+
**GraphQL is preferred** for record operations. Use REST only when GraphQL doesn't cover the use case.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## GraphQL Workflow
|
|
62
|
+
|
|
63
|
+
### Step 1: Acquire Schema
|
|
64
|
+
|
|
65
|
+
The `schema.graphql` file (265K+ lines) is the source of truth. **Never open or parse it directly.**
|
|
66
|
+
|
|
67
|
+
1. Check if `schema.graphql` exists at the SFDX project root
|
|
68
|
+
2. If missing, run from the **webapp dir**: `npm run graphql:schema`
|
|
69
|
+
3. Custom objects appear only after metadata is deployed
|
|
70
|
+
|
|
71
|
+
### Step 2: Look Up Entity Schema
|
|
72
|
+
|
|
73
|
+
Map user intent to PascalCase names ("accounts" → `Account`), then **run the search script from the project root**:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# From project root — look up all relevant schema info for one or more entities
|
|
77
|
+
bash .a4drules/skills/using-salesforce-data/graphql-search.sh Account
|
|
78
|
+
|
|
79
|
+
# Multiple entities at once
|
|
80
|
+
bash .a4drules/skills/using-salesforce-data/graphql-search.sh Account Contact Opportunity
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The script outputs five sections per entity:
|
|
84
|
+
1. **Type definition** — all queryable fields and relationships
|
|
85
|
+
2. **Filter options** — available fields for `where:` conditions
|
|
86
|
+
3. **Sort options** — available fields for `orderBy:`
|
|
87
|
+
4. **Create input** — fields accepted by create mutations
|
|
88
|
+
5. **Update input** — fields accepted by update mutations
|
|
89
|
+
|
|
90
|
+
Use this output to determine exact field names before writing any query or mutation. **Maximum 2 script runs.** If the entity still can't be found, ask the user — the object may not be deployed.
|
|
91
|
+
|
|
92
|
+
### Step 3: Generate Query
|
|
93
|
+
|
|
94
|
+
Use the templates below. Every field name **must** be verified from the script output in Step 2.
|
|
95
|
+
|
|
96
|
+
#### Read Query Template
|
|
97
|
+
|
|
98
|
+
```graphql
|
|
99
|
+
query GetAccounts {
|
|
100
|
+
uiapi {
|
|
101
|
+
query {
|
|
102
|
+
Account(where: { Industry: { eq: "Technology" } }, first: 10) {
|
|
103
|
+
edges {
|
|
104
|
+
node {
|
|
105
|
+
Id
|
|
106
|
+
Name @optional { value }
|
|
107
|
+
Industry @optional { value }
|
|
108
|
+
# Parent relationship
|
|
109
|
+
Owner @optional { Name { value } }
|
|
110
|
+
# Child relationship
|
|
111
|
+
Contacts @optional {
|
|
112
|
+
edges { node { Name @optional { value } } }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**FLS Resilience**: Apply `@optional` to all record fields. The server omits inaccessible fields instead of failing. Consuming code must use optional chaining:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
const name = node.Name?.value ?? "";
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### Mutation Template
|
|
129
|
+
|
|
130
|
+
```graphql
|
|
131
|
+
mutation CreateAccount($input: AccountCreateInput!) {
|
|
132
|
+
uiapi {
|
|
133
|
+
AccountCreate(input: $input) {
|
|
134
|
+
Record { Id Name { value } }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Mutation constraints:**
|
|
141
|
+
- Create: Include required fields, only `createable` fields, no child relationships
|
|
142
|
+
- Update: Include `Id`, only `updateable` fields
|
|
143
|
+
- Delete: Include `Id` only
|
|
144
|
+
|
|
145
|
+
#### Object Metadata & Picklist Values
|
|
146
|
+
|
|
147
|
+
Use `uiapi { objectInfos(...) }` to fetch field metadata or picklist values. Pass **either** `apiNames` or `objectInfoInputs` — never both in the same query.
|
|
148
|
+
|
|
149
|
+
**Object metadata** (field labels, data types, CRUD flags):
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
const GET_OBJECT_INFO = gql`
|
|
153
|
+
query GetObjectInfo($apiNames: [String!]!) {
|
|
154
|
+
uiapi {
|
|
155
|
+
objectInfos(apiNames: $apiNames) {
|
|
156
|
+
ApiName
|
|
157
|
+
label
|
|
158
|
+
labelPlural
|
|
159
|
+
fields {
|
|
160
|
+
ApiName
|
|
161
|
+
label
|
|
162
|
+
dataType
|
|
163
|
+
updateable
|
|
164
|
+
createable
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
`;
|
|
170
|
+
|
|
171
|
+
const sdk = await createDataSDK();
|
|
172
|
+
const response = await sdk.graphql?.(GET_OBJECT_INFO, { apiNames: ["Account"] });
|
|
173
|
+
const objectInfos = response?.data?.uiapi?.objectInfos ?? [];
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Picklist values** (use `objectInfoInputs` + `... on PicklistField` inline fragment):
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
const GET_PICKLIST_VALUES = gql`
|
|
180
|
+
query GetPicklistValues($objectInfoInputs: [ObjectInfoInput!]!) {
|
|
181
|
+
uiapi {
|
|
182
|
+
objectInfos(objectInfoInputs: $objectInfoInputs) {
|
|
183
|
+
ApiName
|
|
184
|
+
fields {
|
|
185
|
+
ApiName
|
|
186
|
+
... on PicklistField {
|
|
187
|
+
picklistValuesByRecordTypeIDs {
|
|
188
|
+
recordTypeID
|
|
189
|
+
picklistValues {
|
|
190
|
+
label
|
|
191
|
+
value
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
`;
|
|
200
|
+
|
|
201
|
+
const response = await sdk.graphql?.(GET_PICKLIST_VALUES, {
|
|
202
|
+
objectInfoInputs: [{ objectApiName: "Account" }],
|
|
203
|
+
});
|
|
204
|
+
const fields = response?.data?.uiapi?.objectInfos?.[0]?.fields ?? [];
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Step 4: Validate & Test
|
|
208
|
+
|
|
209
|
+
1. **Lint**: `npx eslint <file>` from webapp dir
|
|
210
|
+
2. **Test**: Ask user before testing. For mutations, request input values — never fabricate data.
|
|
211
|
+
|
|
212
|
+
**If ESLint reports a GraphQL error** (e.g. `Cannot query field`, `Unknown type`, `Unknown argument`), the field or type name is wrong. Re-run the schema search script to find the correct name — do not guess:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# From project root — re-check the entity that caused the error
|
|
216
|
+
bash .a4drules/skills/using-salesforce-data/graphql-search.sh <EntityName>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Then fix the query using the exact names from the script output.
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Webapp Integration (React)
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
import { createDataSDK, gql } from "@salesforce/sdk-data";
|
|
227
|
+
|
|
228
|
+
const GET_ACCOUNTS = gql`
|
|
229
|
+
query GetAccounts {
|
|
230
|
+
uiapi {
|
|
231
|
+
query {
|
|
232
|
+
Account(first: 10) {
|
|
233
|
+
edges {
|
|
234
|
+
node {
|
|
235
|
+
Id
|
|
236
|
+
Name @optional { value }
|
|
237
|
+
Industry @optional { value }
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
`;
|
|
245
|
+
|
|
246
|
+
const sdk = await createDataSDK();
|
|
247
|
+
const response = await sdk.graphql?.(GET_ACCOUNTS);
|
|
248
|
+
|
|
249
|
+
if (response?.errors?.length) {
|
|
250
|
+
throw new Error(response.errors.map(e => e.message).join("; "));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const accounts = response?.data?.uiapi?.query?.Account?.edges?.map(e => e.node) ?? [];
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## REST API Patterns
|
|
258
|
+
|
|
259
|
+
Use `sdk.fetch` when GraphQL is insufficient. See the [Supported APIs](#supported-apis) table for the full allowlist.
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
declare const __SF_API_VERSION__: string;
|
|
263
|
+
const API_VERSION = typeof __SF_API_VERSION__ !== "undefined" ? __SF_API_VERSION__ : "65.0";
|
|
264
|
+
|
|
265
|
+
// Connect — file upload config
|
|
266
|
+
const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/connect/file/upload/config`);
|
|
267
|
+
|
|
268
|
+
// Apex REST (no version in path)
|
|
269
|
+
const res = await sdk.fetch?.("/services/apexrest/auth/login", {
|
|
270
|
+
method: "POST",
|
|
271
|
+
body: JSON.stringify({ email, password }),
|
|
272
|
+
headers: { "Content-Type": "application/json" },
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
// UI API — record with metadata (prefer GraphQL for simple reads)
|
|
276
|
+
const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/ui-api/records/${recordId}`);
|
|
277
|
+
|
|
278
|
+
// Einstein LLM
|
|
279
|
+
const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/einstein/llm/prompt/generations`, {
|
|
280
|
+
method: "POST",
|
|
281
|
+
body: JSON.stringify({ promptTextorId: prompt }),
|
|
282
|
+
});
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Current user**: Do not use Chatter (`/chatter/users/me`). Use GraphQL instead:
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
const GET_CURRENT_USER = gql`
|
|
289
|
+
query CurrentUser {
|
|
290
|
+
uiapi { currentUser { Id Name { value } } }
|
|
291
|
+
}
|
|
292
|
+
`;
|
|
293
|
+
const response = await sdk.graphql?.(GET_CURRENT_USER);
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Directory Structure
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
<project-root>/ ← SFDX project root
|
|
302
|
+
├── schema.graphql ← grep target (lives here)
|
|
303
|
+
├── sfdx-project.json
|
|
304
|
+
└── force-app/main/default/webapplications/<app-name>/ ← webapp dir
|
|
305
|
+
├── package.json ← npm scripts
|
|
306
|
+
└── src/
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
| Command | Run From | Why |
|
|
310
|
+
|---------|----------|-----|
|
|
311
|
+
| `npm run graphql:schema` | webapp dir | Script in webapp's package.json |
|
|
312
|
+
| `npx eslint <file>` | webapp dir | Reads eslint.config.js |
|
|
313
|
+
| `bash .a4drules/skills/using-salesforce-data/graphql-search.sh <Entity>` | project root | Schema lookup |
|
|
314
|
+
| `sf api request rest` | project root | Needs sfdx-project.json |
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Quick Reference
|
|
319
|
+
|
|
320
|
+
### Schema Lookup (from project root)
|
|
321
|
+
|
|
322
|
+
Run the search script to get all relevant schema info in one step:
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
bash .a4drules/skills/using-salesforce-data/graphql-search.sh <EntityName>
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
| Script Output Section | Used For |
|
|
329
|
+
|-----------------------|----------|
|
|
330
|
+
| Type definition | Field names, parent/child relationships |
|
|
331
|
+
| Filter options | `where:` conditions |
|
|
332
|
+
| Sort options | `orderBy:` |
|
|
333
|
+
| CreateRepresentation | Create mutation field list |
|
|
334
|
+
| UpdateRepresentation | Update mutation field list |
|
|
335
|
+
|
|
336
|
+
### Error Categories
|
|
337
|
+
|
|
338
|
+
| Error Contains | Resolution |
|
|
339
|
+
|----------------|------------|
|
|
340
|
+
| `Cannot query field` | Field name is wrong — run `graphql-search.sh <Entity>` and use the exact name from the Type definition section |
|
|
341
|
+
| `Unknown type` | Type name is wrong — run `graphql-search.sh <Entity>` to confirm the correct PascalCase entity name |
|
|
342
|
+
| `Unknown argument` | Argument name is wrong — run `graphql-search.sh <Entity>` and check Filter or OrderBy sections |
|
|
343
|
+
| `invalid syntax` | Fix syntax per error message |
|
|
344
|
+
| `validation error` | Field name is wrong — run `graphql-search.sh <Entity>` to verify |
|
|
345
|
+
| `VariableTypeMismatch` | Correct argument type from schema |
|
|
346
|
+
| `invalid cross reference id` | Entity deleted — ask for valid Id |
|
|
347
|
+
|
|
348
|
+
### Checklist
|
|
349
|
+
|
|
350
|
+
- [ ] All field names verified via search script (Step 2)
|
|
351
|
+
- [ ] `@optional` applied to record fields (reads)
|
|
352
|
+
- [ ] Optional chaining in consuming code
|
|
353
|
+
- [ ] Lint passes: `npx eslint <file>`
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# UI Platform Rule
|
|
2
|
+
|
|
3
|
+
**All new UI must be built as a Salesforce Web Application.**
|
|
4
|
+
|
|
5
|
+
When any task involves creating a new UI, frontend, page, dashboard, form, or user-facing feature:
|
|
6
|
+
|
|
7
|
+
1. Use `sf webapp generate` to scaffold the web app inside the SFDX project — do not use `create-react-app`, standalone Vite, or any other scaffold.
|
|
8
|
+
2. The app must live under `<sfdx-source>/webapplications/<AppName>/` as a WebApplication bundle.
|
|
9
|
+
3. Do not build new UIs as LWC components, Aura components, or Visualforce pages.
|
|
10
|
+
|
|
11
|
+
Invoke the `creating-webapp` skill (`.a4drules/skills/creating-webapp/`) for the full setup workflow.
|
|
12
|
+
|
|
13
|
+
## Data Access (MUST FOLLOW)
|
|
14
|
+
|
|
15
|
+
- **Never hardcode data in the app.** All data displayed in the UI must come from live Salesforce data fetching — no static arrays, mock objects, or placeholder values in production code.
|
|
16
|
+
- **Always invoke the `using-salesforce-data` skill** (`.a4drules/skills/using-salesforce-data/`) before writing any data access code. All implementation must be derived from that skill.
|
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# @salesforce/sf-web-components
|
|
2
|
+
|
|
3
|
+
Reusable Salesforce web components library with Tailwind CSS v4 and shadcn/ui components.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @salesforce/sf-web-components
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Peer Dependencies
|
|
12
|
+
|
|
13
|
+
This package requires:
|
|
14
|
+
- React 18+ or 19+
|
|
15
|
+
- Tailwind CSS v4
|
|
16
|
+
- @tailwindcss/vite
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Import Components
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { Button, Card } from '@salesforce/sf-web-components';
|
|
24
|
+
import { cn } from '@salesforce/sf-web-components/lib';
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
return (
|
|
28
|
+
<Card className={cn('p-4')}>
|
|
29
|
+
<Button>Click me</Button>
|
|
30
|
+
</Card>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Import Styles
|
|
36
|
+
|
|
37
|
+
Add to your main CSS file:
|
|
38
|
+
|
|
39
|
+
```css
|
|
40
|
+
@import '@salesforce/sf-web-components/styles';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Tailwind Configuration
|
|
44
|
+
|
|
45
|
+
Extend your `tailwind.config.ts`:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import type { Config } from 'tailwindcss';
|
|
49
|
+
|
|
50
|
+
export default {
|
|
51
|
+
content: [
|
|
52
|
+
'./src/**/*.{js,ts,jsx,tsx}',
|
|
53
|
+
'./node_modules/@salesforce/sf-web-components/dist/**/*.{js,jsx}'
|
|
54
|
+
],
|
|
55
|
+
theme: {
|
|
56
|
+
extend: {}
|
|
57
|
+
}
|
|
58
|
+
} satisfies Config;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Components
|
|
62
|
+
|
|
63
|
+
This library includes:
|
|
64
|
+
- UI components (Button, Card, Input, etc.)
|
|
65
|
+
- Data components (Tables, Lists)
|
|
66
|
+
- Chart components (via Recharts)
|
|
67
|
+
- Form components
|
|
68
|
+
- Filter components
|
|
69
|
+
- Layout components
|
|
70
|
+
|
|
71
|
+
## Utilities
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import { cn } from '@salesforce/sf-web-components/lib';
|
|
75
|
+
|
|
76
|
+
// Merge Tailwind classes with conflict resolution
|
|
77
|
+
const className = cn('px-2 py-1', 'px-4'); // Result: 'py-1 px-4'
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Development
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Install dependencies
|
|
84
|
+
npm install
|
|
85
|
+
|
|
86
|
+
# Build the library
|
|
87
|
+
npm run build
|
|
88
|
+
|
|
89
|
+
# Build types only
|
|
90
|
+
npm run build:types
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Publishing
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npm publish
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## 🤖 AI Agent Skills
|
|
101
|
+
|
|
102
|
+
This package includes Claude Code agent skills that teach AI how to work with these components.
|
|
103
|
+
|
|
104
|
+
The `.a4drules/` directory contains:
|
|
105
|
+
- **Skills**: Step-by-step guides for building with this library
|
|
106
|
+
- **Features**: Feature-specific implementation rules
|
|
107
|
+
- **Docs**: Data access patterns and UI conventions
|
|
108
|
+
|
|
109
|
+
### Using with Claude Code
|
|
110
|
+
|
|
111
|
+
When you install this package, Claude Code automatically discovers the skills and uses them to:
|
|
112
|
+
- Build components correctly
|
|
113
|
+
- Follow your architectural patterns
|
|
114
|
+
- Use the right data access methods
|
|
115
|
+
- Apply consistent styling
|
|
116
|
+
|
|
117
|
+
### Available Skills
|
|
118
|
+
|
|
119
|
+
Check `.a4drules/skills/` for the full list of included agent skills.
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsxs as i, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import m from "../ui/Button.js";
|
|
4
|
+
function x({
|
|
5
|
+
actions: s = [],
|
|
6
|
+
title: t,
|
|
7
|
+
onAction: l,
|
|
8
|
+
className: d = ""
|
|
9
|
+
}) {
|
|
10
|
+
return /* @__PURE__ */ i("div", { className: `rounded-2xl border border-slate-200 bg-white p-4 dark:border-slate-800 dark:bg-slate-900 ${d}`, children: [
|
|
11
|
+
t && /* @__PURE__ */ r("div", { className: "mb-3 text-sm font-medium text-slate-900 dark:text-slate-50", children: t }),
|
|
12
|
+
/* @__PURE__ */ r("div", { className: "flex flex-wrap gap-2", children: s.map((e, a) => /* @__PURE__ */ r(
|
|
13
|
+
m,
|
|
14
|
+
{
|
|
15
|
+
size: "sm",
|
|
16
|
+
variant: a === 0 ? "primary" : "outline",
|
|
17
|
+
onClick: () => l?.(e),
|
|
18
|
+
children: typeof e == "string" ? e : e.label
|
|
19
|
+
},
|
|
20
|
+
a
|
|
21
|
+
)) })
|
|
22
|
+
] });
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
x as default
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=ActionList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionList.js","sources":["../../../../src/components/library/cards/ActionList.jsx"],"sourcesContent":["import React from \"react\";\nimport UIButton from \"../ui/Button\";\n\n/**\n * Row of action buttons — typically used at the bottom of a dashboard section.\n *\n * @param {{ label: string, [key]: any }[] | string[]} actions\n * @param {string} title\n * @param {Function} onAction Called with the action object/string when clicked\n */\nexport default function ActionList({\n actions = [],\n title,\n onAction,\n className = \"\",\n}) {\n return (\n <div className={`rounded-2xl border border-slate-200 bg-white p-4 dark:border-slate-800 dark:bg-slate-900 ${className}`}>\n {title && (\n <div className=\"mb-3 text-sm font-medium text-slate-900 dark:text-slate-50\">\n {title}\n </div>\n )}\n <div className=\"flex flex-wrap gap-2\">\n {actions.map((action, i) => (\n <UIButton\n key={i}\n size=\"sm\"\n variant={i === 0 ? \"primary\" : \"outline\"}\n onClick={() => onAction?.(action)}\n >\n {typeof action === \"string\" ? action : action.label}\n </UIButton>\n ))}\n </div>\n </div>\n );\n}\n"],"names":["ActionList","actions","title","onAction","className","jsxs","jsx","action","i","UIButton"],"mappings":";;;AAUA,SAAwBA,EAAW;AAAA,EACjC,SAAAC,IAAU,CAAA;AAAA,EACV,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC,IAAY;AACd,GAAG;AACD,SACE,gBAAAC,EAAC,OAAA,EAAI,WAAW,4FAA4FD,CAAS,IAClH,UAAA;AAAA,IAAAF,KACC,gBAAAI,EAAC,OAAA,EAAI,WAAU,8DACZ,UAAAJ,GACH;AAAA,IAEF,gBAAAI,EAAC,SAAI,WAAU,wBACZ,YAAQ,IAAI,CAACC,GAAQC,MACpB,gBAAAF;AAAA,MAACG;AAAA,MAAA;AAAA,QAEC,MAAK;AAAA,QACL,SAASD,MAAM,IAAI,YAAY;AAAA,QAC/B,SAAS,MAAML,IAAWI,CAAM;AAAA,QAE/B,UAAA,OAAOA,KAAW,WAAWA,IAASA,EAAO;AAAA,MAAA;AAAA,MALzCC;AAAA,IAAA,CAOR,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { AnimatePresence as n, motion as o } from "framer-motion";
|
|
4
|
+
import { ExclamationCircleIcon as c, CheckCircleIcon as d, ClockIcon as m, ArrowPathIcon as p } from "@heroicons/react/24/outline";
|
|
5
|
+
import x from "../ui/Text.js";
|
|
6
|
+
const l = {
|
|
7
|
+
working: { Icon: p, color: "text-indigo-500", spin: !0 },
|
|
8
|
+
pending: { Icon: m, color: "text-slate-400", spin: !1 },
|
|
9
|
+
complete: { Icon: d, color: "text-emerald-500", spin: !1 },
|
|
10
|
+
error: { Icon: c, color: "text-red-500", spin: !1 }
|
|
11
|
+
};
|
|
12
|
+
function u({ action: e }) {
|
|
13
|
+
const r = l[e.status] ?? l.pending;
|
|
14
|
+
return /* @__PURE__ */ t(
|
|
15
|
+
o.div,
|
|
16
|
+
{
|
|
17
|
+
initial: { y: 12, opacity: 0 },
|
|
18
|
+
animate: { y: 0, opacity: 1 },
|
|
19
|
+
exit: { y: -12, opacity: 0 },
|
|
20
|
+
className: "rounded-lg border border-slate-100 bg-slate-50 p-3 dark:border-slate-800 dark:bg-slate-950/40",
|
|
21
|
+
children: /* @__PURE__ */ i("div", { className: "flex items-start gap-2", children: [
|
|
22
|
+
/* @__PURE__ */ t(r.Icon, { className: `mt-0.5 h-4 w-4 shrink-0 ${r.color} ${r.spin ? "animate-spin" : ""}` }),
|
|
23
|
+
/* @__PURE__ */ i("div", { className: "min-w-0", children: [
|
|
24
|
+
/* @__PURE__ */ t("div", { className: "text-xs font-medium text-slate-700 dark:text-slate-200", children: e.title ?? e.action }),
|
|
25
|
+
(e.subtitle ?? e.traveler ?? e.timestamp ?? e.startedAt) && /* @__PURE__ */ t("div", { className: "mt-0.5 text-[10px] text-slate-400", children: [e.subtitle, e.traveler, e.timestamp ?? e.startedAt].filter(Boolean).join(" · ") })
|
|
26
|
+
] })
|
|
27
|
+
] })
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
function b({ title: e = "Activity", actions: r = [], className: a = "" }) {
|
|
32
|
+
return r.length === 0 ? null : /* @__PURE__ */ i("div", { className: a, children: [
|
|
33
|
+
e && /* @__PURE__ */ t(x, { as: "div", size: "xs", weight: "semibold", muted: !0, className: "mb-2 uppercase tracking-wider", children: e }),
|
|
34
|
+
/* @__PURE__ */ t("div", { className: "space-y-2", children: /* @__PURE__ */ t(n, { children: r.map((s) => /* @__PURE__ */ t(u, { action: s }, s.id)) }) })
|
|
35
|
+
] });
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
b as default
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=ActivityCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActivityCard.js","sources":["../../../../src/components/library/cards/ActivityCard.jsx"],"sourcesContent":["import React from \"react\";\nimport { motion, AnimatePresence } from \"framer-motion\";\nimport { ArrowPathIcon, CheckCircleIcon, ExclamationCircleIcon, ClockIcon } from \"@heroicons/react/24/outline\";\nimport UIText from \"../ui/Text\";\n\nconst STATUS_ICON = {\n working: { Icon: ArrowPathIcon, color: \"text-indigo-500\", spin: true },\n pending: { Icon: ClockIcon, color: \"text-slate-400\", spin: false },\n complete: { Icon: CheckCircleIcon, color: \"text-emerald-500\", spin: false },\n error: { Icon: ExclamationCircleIcon, color: \"text-red-500\", spin: false },\n};\n\nfunction ActionItem({ action }) {\n const s = STATUS_ICON[action.status] ?? STATUS_ICON.pending;\n return (\n <motion.div\n initial={{ y: 12, opacity: 0 }}\n animate={{ y: 0, opacity: 1 }}\n exit={{ y: -12, opacity: 0 }}\n className=\"rounded-lg border border-slate-100 bg-slate-50 p-3 dark:border-slate-800 dark:bg-slate-950/40\"\n >\n <div className=\"flex items-start gap-2\">\n <s.Icon className={`mt-0.5 h-4 w-4 shrink-0 ${s.color} ${s.spin ? \"animate-spin\" : \"\"}`} />\n <div className=\"min-w-0\">\n <div className=\"text-xs font-medium text-slate-700 dark:text-slate-200\">{action.title ?? action.action}</div>\n {(action.subtitle ?? action.traveler ?? action.timestamp ?? action.startedAt) && (\n <div className=\"mt-0.5 text-[10px] text-slate-400\">\n {[action.subtitle, action.traveler, action.timestamp ?? action.startedAt].filter(Boolean).join(\" · \")}\n </div>\n )}\n </div>\n </div>\n </motion.div>\n );\n}\n\nexport default function ActivityCard({ title = \"Activity\", actions = [], className = \"\" }) {\n if (actions.length === 0) return null;\n\n return (\n <div className={className}>\n {title && (\n <UIText as=\"div\" size=\"xs\" weight=\"semibold\" muted className=\"mb-2 uppercase tracking-wider\">\n {title}\n </UIText>\n )}\n <div className=\"space-y-2\">\n <AnimatePresence>\n {actions.map(a => (\n <ActionItem key={a.id} action={a} />\n ))}\n </AnimatePresence>\n </div>\n </div>\n );\n}\n"],"names":["STATUS_ICON","ArrowPathIcon","ClockIcon","CheckCircleIcon","ExclamationCircleIcon","ActionItem","action","s","jsx","motion","jsxs","ActivityCard","title","actions","className","UIText","AnimatePresence","a"],"mappings":";;;;;AAKA,MAAMA,IAAc;AAAA,EAClB,SAAU,EAAE,MAAMC,GAAsB,OAAO,mBAAoB,MAAM,GAAA;AAAA,EACzE,SAAU,EAAE,MAAMC,GAAsB,OAAO,kBAAoB,MAAM,GAAA;AAAA,EACzE,UAAU,EAAE,MAAMC,GAAsB,OAAO,oBAAoB,MAAM,GAAA;AAAA,EACzE,OAAU,EAAE,MAAMC,GAAuB,OAAO,gBAAoB,MAAM,GAAA;AAC5E;AAEA,SAASC,EAAW,EAAE,QAAAC,KAAU;AAC9B,QAAMC,IAAIP,EAAYM,EAAO,MAAM,KAAKN,EAAY;AACpD,SACE,gBAAAQ;AAAA,IAACC,EAAO;AAAA,IAAP;AAAA,MACC,SAAS,EAAE,GAAG,IAAI,SAAS,EAAA;AAAA,MAC3B,SAAS,EAAE,GAAG,GAAG,SAAS,EAAA;AAAA,MAC1B,MAAM,EAAE,GAAG,KAAK,SAAS,EAAA;AAAA,MACzB,WAAU;AAAA,MAEV,UAAA,gBAAAC,EAAC,OAAA,EAAI,WAAU,0BACb,UAAA;AAAA,QAAA,gBAAAF,EAACD,EAAE,MAAF,EAAO,WAAW,2BAA2BA,EAAE,KAAK,IAAIA,EAAE,OAAO,iBAAiB,EAAE,GAAA,CAAI;AAAA,QACzF,gBAAAG,EAAC,OAAA,EAAI,WAAU,WACb,UAAA;AAAA,UAAA,gBAAAF,EAAC,SAAI,WAAU,0DAA0D,UAAAF,EAAO,SAASA,EAAO,QAAO;AAAA,WACrGA,EAAO,YAAYA,EAAO,YAAYA,EAAO,aAAaA,EAAO,cACjE,gBAAAE,EAAC,OAAA,EAAI,WAAU,qCACZ,UAAA,CAACF,EAAO,UAAUA,EAAO,UAAUA,EAAO,aAAaA,EAAO,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,KAAK,EAAA,CACtG;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,SAAwBK,EAAa,EAAE,OAAAC,IAAQ,YAAY,SAAAC,IAAU,IAAI,WAAAC,IAAY,MAAM;AACzF,SAAID,EAAQ,WAAW,IAAU,OAG/B,gBAAAH,EAAC,SAAI,WAAAI,GACF,UAAA;AAAA,IAAAF,KACC,gBAAAJ,EAACO,GAAA,EAAO,IAAG,OAAM,MAAK,MAAK,QAAO,YAAW,OAAK,IAAC,WAAU,iCAC1D,UAAAH,GACH;AAAA,sBAED,OAAA,EAAI,WAAU,aACb,UAAA,gBAAAJ,EAACQ,KACE,UAAAH,EAAQ,IAAI,CAAAI,MACX,gBAAAT,EAACH,KAAsB,QAAQY,EAAA,GAAdA,EAAE,EAAe,CACnC,GACH,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as a, jsxs as e, Fragment as z } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
const c = {
|
|
4
|
+
default: "",
|
|
5
|
+
metric: "",
|
|
6
|
+
chart: "",
|
|
7
|
+
table: "",
|
|
8
|
+
widget: "",
|
|
9
|
+
status: ""
|
|
10
|
+
}, u = {
|
|
11
|
+
xs: "",
|
|
12
|
+
sm: "min-h-[80px]",
|
|
13
|
+
md: "min-h-[120px]",
|
|
14
|
+
lg: "min-h-[160px]",
|
|
15
|
+
xl: "min-h-[220px]",
|
|
16
|
+
full: ""
|
|
17
|
+
}, m = {
|
|
18
|
+
none: "p-0",
|
|
19
|
+
xs: "p-2",
|
|
20
|
+
sm: "p-3",
|
|
21
|
+
default: "p-4",
|
|
22
|
+
lg: "p-6",
|
|
23
|
+
xl: "p-8"
|
|
24
|
+
};
|
|
25
|
+
function M({
|
|
26
|
+
header: t,
|
|
27
|
+
body: n,
|
|
28
|
+
footer: d,
|
|
29
|
+
children: p,
|
|
30
|
+
variant: h = "default",
|
|
31
|
+
size: f = "md",
|
|
32
|
+
padding: v = "default",
|
|
33
|
+
shadow: g = !0,
|
|
34
|
+
radius: s = "2xl",
|
|
35
|
+
border: x = !0,
|
|
36
|
+
isHoverable: b = !1,
|
|
37
|
+
isPressable: l = !1,
|
|
38
|
+
isLoading: N = !1,
|
|
39
|
+
isDisabled: S = !1,
|
|
40
|
+
isSelected: C = !1,
|
|
41
|
+
className: w = "",
|
|
42
|
+
headerClassName: k = "",
|
|
43
|
+
bodyClassName: r = "",
|
|
44
|
+
footerClassName: A = "",
|
|
45
|
+
onPress: i,
|
|
46
|
+
onHover: E,
|
|
47
|
+
...j
|
|
48
|
+
}) {
|
|
49
|
+
const B = l ? "button" : "div", I = s ? `rounded-${s}` : "rounded-2xl", L = m[v] ?? m.default, _ = u[f] ?? u.md, y = c[h] ?? c.default, D = b || l, o = S || l && !i;
|
|
50
|
+
return /* @__PURE__ */ a(
|
|
51
|
+
B,
|
|
52
|
+
{
|
|
53
|
+
type: l ? "button" : void 0,
|
|
54
|
+
onClick: l ? i : void 0,
|
|
55
|
+
onMouseEnter: E,
|
|
56
|
+
disabled: l ? o : void 0,
|
|
57
|
+
className: [
|
|
58
|
+
"w-full text-left",
|
|
59
|
+
I,
|
|
60
|
+
x ? "border border-slate-200 dark:border-slate-800" : "border border-transparent",
|
|
61
|
+
"bg-white dark:bg-slate-900",
|
|
62
|
+
g ? "shadow-sm" : "",
|
|
63
|
+
_,
|
|
64
|
+
y,
|
|
65
|
+
D ? "transition hover:-translate-y-[1px] hover:shadow-md" : "",
|
|
66
|
+
C ? "ring-2 ring-brand-500" : "",
|
|
67
|
+
o ? "opacity-60" : "",
|
|
68
|
+
w
|
|
69
|
+
].filter(Boolean).join(" "),
|
|
70
|
+
...j,
|
|
71
|
+
children: /* @__PURE__ */ e("div", { className: L, children: [
|
|
72
|
+
t != null ? /* @__PURE__ */ a("div", { className: k, children: t }) : null,
|
|
73
|
+
N ? /* @__PURE__ */ e("div", { className: ["mt-3 space-y-3", r].filter(Boolean).join(" "), children: [
|
|
74
|
+
/* @__PURE__ */ a("div", { className: "h-4 w-1/3 animate-pulse rounded bg-slate-200 dark:bg-slate-800" }),
|
|
75
|
+
/* @__PURE__ */ a("div", { className: "h-4 w-2/3 animate-pulse rounded bg-slate-200 dark:bg-slate-800" }),
|
|
76
|
+
/* @__PURE__ */ a("div", { className: "h-4 w-1/2 animate-pulse rounded bg-slate-200 dark:bg-slate-800" })
|
|
77
|
+
] }) : /* @__PURE__ */ e(z, { children: [
|
|
78
|
+
n != null ? /* @__PURE__ */ a("div", { className: r, children: n }) : null,
|
|
79
|
+
p
|
|
80
|
+
] }),
|
|
81
|
+
d != null ? /* @__PURE__ */ a("div", { className: A, children: d }) : null
|
|
82
|
+
] })
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
M as default
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=BaseCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseCard.js","sources":["../../../../src/components/library/cards/BaseCard.jsx"],"sourcesContent":["import React from \"react\";\n\nconst VARIANT_CLASSES = {\n default: \"\",\n metric: \"\",\n chart: \"\",\n table: \"\",\n widget: \"\",\n status: \"\"\n};\n\nconst SIZE_CLASSES = {\n xs: \"\",\n sm: \"min-h-[80px]\",\n md: \"min-h-[120px]\",\n lg: \"min-h-[160px]\",\n xl: \"min-h-[220px]\",\n full: \"\"\n};\n\nconst PADDING_CLASSES = {\n none: \"p-0\",\n xs: \"p-2\",\n sm: \"p-3\",\n default: \"p-4\",\n lg: \"p-6\",\n xl: \"p-8\"\n};\n\nexport default function BaseCard({\n header,\n body,\n footer,\n children,\n variant = \"default\",\n size = \"md\",\n padding = \"default\",\n shadow = true,\n radius = \"2xl\",\n border = true,\n isHoverable = false,\n isPressable = false,\n isLoading = false,\n isDisabled = false,\n isSelected = false,\n className = \"\",\n headerClassName = \"\",\n bodyClassName = \"\",\n footerClassName = \"\",\n onPress,\n onHover,\n ...rest\n}) {\n const Comp = isPressable ? \"button\" : \"div\";\n\n const radiusClass = radius ? `rounded-${radius}` : \"rounded-2xl\";\n const paddingClass = PADDING_CLASSES[padding] ?? PADDING_CLASSES.default;\n const sizeClass = SIZE_CLASSES[size] ?? SIZE_CLASSES.md;\n const variantClass = VARIANT_CLASSES[variant] ?? VARIANT_CLASSES.default;\n\n const interactive = isHoverable || isPressable;\n const disabled = isDisabled || (isPressable && !onPress);\n\n return (\n <Comp\n type={isPressable ? \"button\" : undefined}\n onClick={isPressable ? onPress : undefined}\n onMouseEnter={onHover}\n disabled={isPressable ? disabled : undefined}\n className={[\n \"w-full text-left\",\n radiusClass,\n border ? \"border border-slate-200 dark:border-slate-800\" : \"border border-transparent\",\n \"bg-white dark:bg-slate-900\",\n shadow ? \"shadow-sm\" : \"\",\n sizeClass,\n variantClass,\n interactive ? \"transition hover:-translate-y-[1px] hover:shadow-md\" : \"\",\n isSelected ? \"ring-2 ring-brand-500\" : \"\",\n disabled ? \"opacity-60\" : \"\",\n className\n ]\n .filter(Boolean)\n .join(\" \")}\n {...rest}\n >\n <div className={paddingClass}>\n {header != null ? <div className={headerClassName}>{header}</div> : null}\n\n {isLoading ? (\n <div className={[\"mt-3 space-y-3\", bodyClassName].filter(Boolean).join(\" \")}>\n <div className=\"h-4 w-1/3 animate-pulse rounded bg-slate-200 dark:bg-slate-800\" />\n <div className=\"h-4 w-2/3 animate-pulse rounded bg-slate-200 dark:bg-slate-800\" />\n <div className=\"h-4 w-1/2 animate-pulse rounded bg-slate-200 dark:bg-slate-800\" />\n </div>\n ) : (\n <>\n {body != null ? <div className={bodyClassName}>{body}</div> : null}\n {children}\n </>\n )}\n\n {footer != null ? <div className={footerClassName}>{footer}</div> : null}\n </div>\n </Comp>\n );\n}\n\n\n"],"names":["VARIANT_CLASSES","SIZE_CLASSES","PADDING_CLASSES","BaseCard","header","body","footer","children","variant","size","padding","shadow","radius","border","isHoverable","isPressable","isLoading","isDisabled","isSelected","className","headerClassName","bodyClassName","footerClassName","onPress","onHover","rest","Comp","radiusClass","paddingClass","sizeClass","variantClass","interactive","disabled","jsx","jsxs","Fragment"],"mappings":"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"}
|