@cryptlex/web-components 5.3.0 → 5.5.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/dist/components/{ui/alert.d.ts → alert.d.ts} +3 -3
- package/dist/components/alert.js +2 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/{ui/avatar.d.ts → avatar.d.ts} +0 -1
- package/dist/components/avatar.js +2 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/{ui/badge.d.ts → badge.d.ts} +0 -1
- package/dist/components/badge.js +2 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/{ui/breadcrumbs.d.ts → breadcrumbs.d.ts} +1 -1
- package/dist/components/breadcrumbs.js +2 -0
- package/dist/components/breadcrumbs.js.map +1 -0
- package/dist/components/{ui/button.d.ts → button.d.ts} +5 -5
- package/dist/components/button.js +2 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/{ui/calendar.d.ts → calendar.d.ts} +2 -3
- package/dist/components/calendar.js +2 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.js +2 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/{inputs/checkbox.d.ts → checkbox.d.ts} +3 -3
- package/dist/components/checkbox.js +2 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/{data-table/table-commons.d.ts → data-table-commons.d.ts} +8 -8
- package/dist/components/data-table-commons.js +2 -0
- package/dist/components/data-table-commons.js.map +1 -0
- package/dist/components/{data-table/data-table-filter.d.ts → data-table-filter.d.ts} +3 -3
- package/dist/components/data-table-filter.js +2 -0
- package/dist/components/data-table-filter.js.map +1 -0
- package/dist/components/{data-table/data-table.d.ts → data-table.d.ts} +24 -25
- package/dist/components/data-table.js +2 -0
- package/dist/components/data-table.js.map +1 -0
- package/dist/components/{inputs/date-picker.d.ts → date-picker.d.ts} +3 -3
- package/dist/components/date-picker.js +2 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/{inputs/datefield.d.ts → datefield.d.ts} +3 -3
- package/dist/components/datefield.js +2 -0
- package/dist/components/datefield.js.map +1 -0
- package/dist/components/{ui/dialog.d.ts → dialog.d.ts} +3 -4
- package/dist/components/dialog.js +2 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/{ui/disclosure.d.ts → disclosure.d.ts} +3 -7
- package/dist/components/disclosure.js +2 -0
- package/dist/components/disclosure.js.map +1 -0
- package/dist/components/{inputs/field.d.ts → field.d.ts} +5 -6
- package/dist/components/field.js +2 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/id-search.js +2 -0
- package/dist/components/id-search.js.map +1 -0
- package/dist/components/{inputs/input-otp.d.ts → input-otp.d.ts} +1 -2
- package/dist/components/input-otp.js +2 -0
- package/dist/components/input-otp.js.map +1 -0
- package/dist/components/key-value-card.js +2 -0
- package/dist/components/key-value-card.js.map +1 -0
- package/dist/components/{ui/list-box.d.ts → list-box.d.ts} +1 -1
- package/dist/components/list-box.js +2 -0
- package/dist/components/list-box.js.map +1 -0
- package/dist/components/loader.js +2 -0
- package/dist/components/loader.js.map +1 -0
- package/dist/components/{ui/menu.d.ts → menu.d.ts} +5 -6
- package/dist/components/menu.js +2 -0
- package/dist/components/menu.js.map +1 -0
- package/dist/components/{inputs/multi-select.d.ts → multi-select.d.ts} +3 -4
- package/dist/components/multi-select.js +2 -0
- package/dist/components/multi-select.js.map +1 -0
- package/dist/components/{inputs/numberfield.d.ts → numberfield.d.ts} +2 -3
- package/dist/components/numberfield.js +2 -0
- package/dist/components/numberfield.js.map +1 -0
- package/dist/components/{ui/popover.d.ts → popover.d.ts} +1 -1
- package/dist/components/popover.js +2 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/{inputs/searchfield.d.ts → searchfield.d.ts} +2 -2
- package/dist/components/searchfield.js +2 -0
- package/dist/components/searchfield.js.map +1 -0
- package/dist/components/select-options.js +2 -0
- package/dist/components/select-options.js.map +1 -0
- package/dist/components/{inputs/select.d.ts → select.d.ts} +5 -5
- package/dist/components/select.js +2 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/{ui/sidebar.d.ts → sidebar.d.ts} +4 -5
- package/dist/components/sidebar.js +2 -0
- package/dist/components/sidebar.js.map +1 -0
- package/dist/components/skeleton.js +2 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/{ui/sonner.d.ts → sonner.d.ts} +1 -1
- package/dist/components/sonner.js +2 -0
- package/dist/components/sonner.js.map +1 -0
- package/dist/components/table-of-contents.d.ts +9 -0
- package/dist/components/table-of-contents.js +2 -0
- package/dist/components/table-of-contents.js.map +1 -0
- package/dist/components/{ui/table.d.ts → table.d.ts} +0 -1
- package/dist/components/table.js +2 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/{ui/tabs.d.ts → tabs.d.ts} +1 -1
- package/dist/components/tabs.js +2 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/{inputs/textfield.d.ts → textfield.d.ts} +2 -2
- package/dist/components/textfield.js +2 -0
- package/dist/components/textfield.js.map +1 -0
- package/dist/components/{ui/timeline.d.ts → timeline.d.ts} +3 -3
- package/dist/components/timeline.js +2 -0
- package/dist/components/timeline.js.map +1 -0
- package/dist/components/{ui/tooltip.d.ts → tooltip.d.ts} +1 -1
- package/dist/components/tooltip.js +2 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/utils/form-context.d.ts +1 -1
- package/dist/utils/form-context.js +2 -5
- package/dist/utils/form-context.js.map +1 -0
- package/dist/utils/form-hook.d.ts +9 -11
- package/dist/utils/form-hook.js +2 -30
- package/dist/utils/form-hook.js.map +1 -0
- package/dist/utils/primitives.d.ts +16 -2
- package/dist/utils/primitives.js +2 -39
- package/dist/utils/primitives.js.map +1 -0
- package/dist/utils/resource-names.d.ts +1 -13
- package/dist/utils/resource-names.js +2 -212
- package/dist/utils/resource-names.js.map +1 -0
- package/dist/utils/use-mobile.js +2 -15
- package/dist/utils/use-mobile.js.map +1 -0
- package/lib/utilities.css +2 -2
- package/package.json +13 -12
- package/dist/components/data-table/data-table-filter.js +0 -112
- package/dist/components/data-table/data-table.js +0 -265
- package/dist/components/data-table/table-commons.js +0 -137
- package/dist/components/inputs/checkbox.js +0 -25
- package/dist/components/inputs/date-picker.js +0 -22
- package/dist/components/inputs/datefield.js +0 -25
- package/dist/components/inputs/field.js +0 -48
- package/dist/components/inputs/id-search.js +0 -40
- package/dist/components/inputs/input-otp.js +0 -19
- package/dist/components/inputs/multi-select.js +0 -18
- package/dist/components/inputs/numberfield.js +0 -25
- package/dist/components/inputs/searchfield.js +0 -24
- package/dist/components/inputs/select-options.js +0 -286
- package/dist/components/inputs/select.js +0 -34
- package/dist/components/inputs/textfield.js +0 -28
- package/dist/components/key-value-card/key-value-card.js +0 -40
- package/dist/components/ui/alert.js +0 -18
- package/dist/components/ui/avatar.js +0 -5
- package/dist/components/ui/badge.js +0 -5
- package/dist/components/ui/breadcrumbs.js +0 -28
- package/dist/components/ui/button.js +0 -34
- package/dist/components/ui/calendar.js +0 -63
- package/dist/components/ui/card.js +0 -20
- package/dist/components/ui/dialog.js +0 -42
- package/dist/components/ui/disclosure.js +0 -20
- package/dist/components/ui/list-box.js +0 -24
- package/dist/components/ui/loader.js +0 -6
- package/dist/components/ui/menu.js +0 -38
- package/dist/components/ui/popover.js +0 -14
- package/dist/components/ui/sidebar.js +0 -177
- package/dist/components/ui/skeleton.js +0 -5
- package/dist/components/ui/sonner.js +0 -14
- package/dist/components/ui/table.js +0 -26
- package/dist/components/ui/tabs.js +0 -25
- package/dist/components/ui/timeline.js +0 -31
- package/dist/components/ui/tooltip.js +0 -12
- /package/dist/components/{ui/card.d.ts → card.d.ts} +0 -0
- /package/dist/components/{inputs/id-search.d.ts → id-search.d.ts} +0 -0
- /package/dist/components/{key-value-card/key-value-card.d.ts → key-value-card.d.ts} +0 -0
- /package/dist/components/{ui/loader.d.ts → loader.d.ts} +0 -0
- /package/dist/components/{inputs/select-options.d.ts → select-options.d.ts} +0 -0
- /package/dist/components/{ui/skeleton.d.ts → skeleton.d.ts} +0 -0
|
@@ -1,212 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param input camelCase
|
|
6
|
-
* @returns title case for the camelCase string
|
|
7
|
-
*/
|
|
8
|
-
export function convertToTitleCase(input) {
|
|
9
|
-
return input
|
|
10
|
-
.replace(/([A-Z])/g, " $1") // Insert space before capital letters
|
|
11
|
-
.trim() // Remove any leading/trailing spaces
|
|
12
|
-
.split(" ") // Split into words
|
|
13
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) // Capitalize each word
|
|
14
|
-
.join(" "); // Join back into a single string
|
|
15
|
-
}
|
|
16
|
-
export function pluralizeTimes(resourceName, count) {
|
|
17
|
-
if (count > 1) {
|
|
18
|
-
if (/y$/.test(resourceName)) {
|
|
19
|
-
if (resourceName === "Day")
|
|
20
|
-
return "Days";
|
|
21
|
-
return resourceName.replace(/y$/, "ies");
|
|
22
|
-
}
|
|
23
|
-
return resourceName.concat("s");
|
|
24
|
-
}
|
|
25
|
-
return resourceName;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Converts a string from 'camelCase' to 'Title Case'
|
|
29
|
-
* @param input String to convert to `Title Case`
|
|
30
|
-
*/
|
|
31
|
-
export function convertCamelCaseToTitleCase(input) {
|
|
32
|
-
if (input) {
|
|
33
|
-
const spacedString = input.replace(/([A-Z])/g, " $1");
|
|
34
|
-
return spacedString
|
|
35
|
-
.charAt(0)
|
|
36
|
-
.toUpperCase()
|
|
37
|
-
.concat(spacedString.slice(1))
|
|
38
|
-
.replace(/\.[a-z]/, (substr) => {
|
|
39
|
-
return substr.replace(".", " ").toUpperCase();
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return input;
|
|
43
|
-
}
|
|
44
|
-
// Display names specific to customer and reseller portal
|
|
45
|
-
const OTHER_PORTALS_DISPLAY_NAME = {
|
|
46
|
-
"product.displayName": "Product",
|
|
47
|
-
};
|
|
48
|
-
/** Resource Name should ALWAYS be in singular form */
|
|
49
|
-
export const RESOURCE_NAMES = [
|
|
50
|
-
"access-token",
|
|
51
|
-
"account",
|
|
52
|
-
"activation",
|
|
53
|
-
"activation-log",
|
|
54
|
-
"admin-role",
|
|
55
|
-
"audit-log",
|
|
56
|
-
"automated-email",
|
|
57
|
-
"automated-email-event-log",
|
|
58
|
-
"card",
|
|
59
|
-
"feature-flag",
|
|
60
|
-
"invoice",
|
|
61
|
-
"license",
|
|
62
|
-
"license-template",
|
|
63
|
-
"maintenance-policy",
|
|
64
|
-
"organization",
|
|
65
|
-
"plan",
|
|
66
|
-
"product",
|
|
67
|
-
"product-version",
|
|
68
|
-
"profile",
|
|
69
|
-
"release",
|
|
70
|
-
"release-channel",
|
|
71
|
-
"release-file",
|
|
72
|
-
"release-platform",
|
|
73
|
-
"report",
|
|
74
|
-
"role",
|
|
75
|
-
"role-claim",
|
|
76
|
-
"saml-configuration",
|
|
77
|
-
"segment",
|
|
78
|
-
"sending-domain",
|
|
79
|
-
"setting",
|
|
80
|
-
"tag",
|
|
81
|
-
"team-member",
|
|
82
|
-
"trial",
|
|
83
|
-
"trial-policy",
|
|
84
|
-
"user",
|
|
85
|
-
"user-group",
|
|
86
|
-
"webhook",
|
|
87
|
-
"webhook-event-log",
|
|
88
|
-
"webhook-trigger",
|
|
89
|
-
"reseller",
|
|
90
|
-
"oidc-configuration",
|
|
91
|
-
"organization-claim",
|
|
92
|
-
"reseller-claim",
|
|
93
|
-
];
|
|
94
|
-
export const RESOURCE_DEFINITIONS = {
|
|
95
|
-
account: "Your organization account.",
|
|
96
|
-
product: "Products are the software products you want to license",
|
|
97
|
-
license: "Licenses represent a purchase of your software. These can be linked to customers, and the license key is required to use the product.",
|
|
98
|
-
"access-token": "Access Tokens are used to authenticate your API requests.",
|
|
99
|
-
activation: "Activations, also known as devices/machines/seats are the devices consuming licenses.",
|
|
100
|
-
"activation-log": "Activation Log is a log entry of activation/deactivation of a particular license.",
|
|
101
|
-
trial: "Trial/Trial Activation is a device that has activated a trial of your product.",
|
|
102
|
-
"audit-log": "Audit logs contain all the changes made to your account.",
|
|
103
|
-
"automated-email": "Automated Email allow you to send marketing emails based on events on the linked product.",
|
|
104
|
-
"automated-email-event-log": "Automated email event log is the log of all the automated email events for your product.",
|
|
105
|
-
card: "The payment card for your account.",
|
|
106
|
-
"feature-flag": "Feature flags define features that make up tiers for your products.",
|
|
107
|
-
invoice: "",
|
|
108
|
-
"license-template": "License templates are a blueprint for the licenses you create for your customers and prevent repetition when creating licenses.",
|
|
109
|
-
"maintenance-policy": "Maintenance policies represent support contracts and can be linked to licenses.",
|
|
110
|
-
plan: "",
|
|
111
|
-
"product-version": "Product Versions are sets of Feature Flags that define the tiers of your products.",
|
|
112
|
-
"release-channel": "Release channel is the release channel for your product.",
|
|
113
|
-
"release-file": "Release files are files within your created releases.",
|
|
114
|
-
"release-platform": 'Release Platforms differentiate the target platform for your release. Common platforms include "Windows", "macOS", and "Linux".',
|
|
115
|
-
release: "Releases help you to manage different versions of your app, and secure distribute it to licensed users.",
|
|
116
|
-
report: "Analytics data for your account",
|
|
117
|
-
"role-claim": "",
|
|
118
|
-
role: "Roles define permissions for your team.",
|
|
119
|
-
"saml-configuration": "",
|
|
120
|
-
segment: "Sets of filters that can be saved to filter resources.",
|
|
121
|
-
"trial-policy": "Trial policies are templates for creating trials for your products.",
|
|
122
|
-
"webhook-event-log": "Webhook Event Logs are logs of events that have occured on webhooks.",
|
|
123
|
-
"webhook-trigger": "",
|
|
124
|
-
webhook: "Webhooks are HTTP callbacks which are triggered by specific events.",
|
|
125
|
-
organization: "",
|
|
126
|
-
profile: "",
|
|
127
|
-
setting: "",
|
|
128
|
-
tag: "Tags allow you to manage your licenses and customers on the dashboard.",
|
|
129
|
-
"team-member": "Team members can access the account based on their roles.",
|
|
130
|
-
user: "A user refers to your customer whom you want to license your product.",
|
|
131
|
-
"sending-domain": "Allows Cryptlex to send emails on your behalf using your From Email address",
|
|
132
|
-
"admin-role": "Roles that have type admin",
|
|
133
|
-
"user-group": "Groups of users that you can assign licenses to.",
|
|
134
|
-
reseller: "Resellers allow you to delegate user management to third parties or partners",
|
|
135
|
-
"oidc-configuration": "",
|
|
136
|
-
"organization-claim": "",
|
|
137
|
-
"reseller-claim": "",
|
|
138
|
-
};
|
|
139
|
-
const RESOURCE_DISPLAY_NAMES = {
|
|
140
|
-
id: "ID",
|
|
141
|
-
createdAt: "Creation Date",
|
|
142
|
-
scopes: "Permissions",
|
|
143
|
-
updatedAt: "Last Updated",
|
|
144
|
-
expiresAt: "Expiration Date",
|
|
145
|
-
lastSeenAt: "Last Seen",
|
|
146
|
-
os: "OS",
|
|
147
|
-
osVersion: "OS Version",
|
|
148
|
-
key: "License Key",
|
|
149
|
-
vmName: "VM Name",
|
|
150
|
-
container: "Container",
|
|
151
|
-
allowedIpRange: "Allowed IP Range",
|
|
152
|
-
allowedIpRanges: "Allowed IP Ranges",
|
|
153
|
-
allowedIpAddresses: "Allowed IP Addresses",
|
|
154
|
-
disallowedIpAddresses: "Disallowed IP Addresses",
|
|
155
|
-
allowVmActivation: "Allow VM Activation",
|
|
156
|
-
disableGeoLocation: "Disable Geolocation",
|
|
157
|
-
"user.id": "User ID",
|
|
158
|
-
userId: "User",
|
|
159
|
-
productId: "Product",
|
|
160
|
-
downloads: "Total Downloads",
|
|
161
|
-
claims: "Permissions",
|
|
162
|
-
googleSsoEnabled: "Google Login Enabled",
|
|
163
|
-
lastAttemptedAt: "Last Attempt Date",
|
|
164
|
-
url: "URL",
|
|
165
|
-
"trialPolicy.name": "Trial Policy Name",
|
|
166
|
-
"licensePolicy.name": "License Template Name",
|
|
167
|
-
licensePolicy: "License Template",
|
|
168
|
-
eventLog: "Audit Log",
|
|
169
|
-
cc: "CC Recepients",
|
|
170
|
-
bcc: "BCC Recepients",
|
|
171
|
-
ipAddress: "IP Address",
|
|
172
|
-
resellerId: "Reseller",
|
|
173
|
-
productVersionId: "Product Version",
|
|
174
|
-
releaseId: "Release",
|
|
175
|
-
maintenancePolicyId: "Maintenance Policy",
|
|
176
|
-
webhookId: "Webhook",
|
|
177
|
-
automatedEmailId: "Automated Email",
|
|
178
|
-
"location.countryName": "Country",
|
|
179
|
-
"location.ipAddress": "IP Address",
|
|
180
|
-
"location.countryCode": "Country",
|
|
181
|
-
organizationId: "Organization",
|
|
182
|
-
"address.country": "Country",
|
|
183
|
-
"address.addressLine1": "Address Line 1",
|
|
184
|
-
"address.addressLine2": "Address Line 2",
|
|
185
|
-
responseStatusCode: "HTTP Status Code",
|
|
186
|
-
resourceId: "Resource ID",
|
|
187
|
-
Sso: "SAML SSO 2.0",
|
|
188
|
-
"reseller.name": "Reseller",
|
|
189
|
-
sendingDomain: "Email Sending Domain",
|
|
190
|
-
};
|
|
191
|
-
function getResourceDisplayName(resourceName, portal) {
|
|
192
|
-
if (portal !== "admin-portal" && resourceName in OTHER_PORTALS_DISPLAY_NAME) {
|
|
193
|
-
return OTHER_PORTALS_DISPLAY_NAME[resourceName];
|
|
194
|
-
}
|
|
195
|
-
else if (resourceName in RESOURCE_DISPLAY_NAMES) {
|
|
196
|
-
return RESOURCE_DISPLAY_NAMES[resourceName];
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
return convertCamelCaseToTitleCase(resourceName);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
const ProjectContext = createContext('admin-portal');
|
|
203
|
-
export function ProjectProvider({ projectName, children }) {
|
|
204
|
-
return (_jsx(ProjectContext.Provider, { value: projectName, children: children }));
|
|
205
|
-
}
|
|
206
|
-
export function useProjectName() {
|
|
207
|
-
return use(ProjectContext);
|
|
208
|
-
}
|
|
209
|
-
export function useResourceFormatter() {
|
|
210
|
-
const portal = useProjectName();
|
|
211
|
-
return (resourceName) => getResourceDisplayName(resourceName, portal);
|
|
212
|
-
}
|
|
1
|
+
import{jsx as s}from"react/jsx-runtime";import{convertCamelCaseToTitleCase as n}from"./primitives.js";import{createContext as i,use as l}from"react";import"clsx";const t={"product.displayName":"Product"},f=["access-token","account","activation","activation-log","admin-role","audit-log","automated-email","automated-email-event-log","card","feature-flag","invoice","license","license-template","maintenance-policy","organization","plan","product","product-version","profile","release","release-channel","release-file","release-platform","report","role","role-claim","saml-configuration","segment","sending-domain","setting","tag","team-member","trial","trial-policy","user","user-group","webhook","webhook-event-log","webhook-trigger","reseller","oidc-configuration","organization-claim","reseller-claim"],y={account:"Your organization account.",product:"Products are the software products you want to license",license:"Licenses represent a purchase of your software. These can be linked to customers, and the license key is required to use the product.","access-token":"Access Tokens are used to authenticate your API requests.",activation:"Activations, also known as devices/machines/seats are the devices consuming licenses.","activation-log":"Activation Log is a log entry of activation/deactivation of a particular license.",trial:"Trial/Trial Activation is a device that has activated a trial of your product.","audit-log":"Audit logs contain all the changes made to your account.","automated-email":"Automated Email allow you to send marketing emails based on events on the linked product.","automated-email-event-log":"Automated email event log is the log of all the automated email events for your product.",card:"The payment card for your account.","feature-flag":"Feature flags define features that make up tiers for your products.",invoice:"","license-template":"License templates are a blueprint for the licenses you create for your customers and prevent repetition when creating licenses.","maintenance-policy":"Maintenance policies represent support contracts and can be linked to licenses.",plan:"","product-version":"Product Versions are sets of Feature Flags that define the tiers of your products.","release-channel":"Release channel is the release channel for your product.","release-file":"Release files are files within your created releases.","release-platform":'Release Platforms differentiate the target platform for your release. Common platforms include "Windows", "macOS", and "Linux".',release:"Releases help you to manage different versions of your app, and secure distribute it to licensed users.",report:"Analytics data for your account","role-claim":"",role:"Roles define permissions for your team.","saml-configuration":"",segment:"Sets of filters that can be saved to filter resources.","trial-policy":"Trial policies are templates for creating trials for your products.","webhook-event-log":"Webhook Event Logs are logs of events that have occured on webhooks.","webhook-trigger":"",webhook:"Webhooks are HTTP callbacks which are triggered by specific events.",organization:"",profile:"",setting:"",tag:"Tags allow you to manage your licenses and customers on the dashboard.","team-member":"Team members can access the account based on their roles.",user:"A user refers to your customer whom you want to license your product.","sending-domain":"Allows Cryptlex to send emails on your behalf using your From Email address","admin-role":"Roles that have type admin","user-group":"Groups of users that you can assign licenses to.",reseller:"Resellers allow you to delegate user management to third parties or partners","oidc-configuration":"","organization-claim":"","reseller-claim":""},a={id:"ID",createdAt:"Creation Date",scopes:"Permissions",updatedAt:"Last Updated",expiresAt:"Expiration Date",lastSeenAt:"Last Seen",os:"OS",osVersion:"OS Version",key:"License Key",vmName:"VM Name",container:"Container",allowedIpRange:"Allowed IP Range",allowedIpRanges:"Allowed IP Ranges",allowedIpAddresses:"Allowed IP Addresses",disallowedIpAddresses:"Disallowed IP Addresses",allowVmActivation:"Allow VM Activation",disableGeoLocation:"Disable Geolocation","user.id":"User ID",userId:"User",productId:"Product",downloads:"Total Downloads",claims:"Permissions",googleSsoEnabled:"Google Login Enabled",lastAttemptedAt:"Last Attempt Date",url:"URL","trialPolicy.name":"Trial Policy Name","licensePolicy.name":"License Template Name",licensePolicy:"License Template",eventLog:"Audit Log",cc:"CC Recepients",bcc:"BCC Recepients",ipAddress:"IP Address",resellerId:"Reseller",productVersionId:"Product Version",releaseId:"Release",maintenancePolicyId:"Maintenance Policy",webhookId:"Webhook",automatedEmailId:"Automated Email","location.countryName":"Country","location.ipAddress":"IP Address","location.countryCode":"Country",organizationId:"Organization","address.country":"Country","address.addressLine1":"Address Line 1","address.addressLine2":"Address Line 2",responseStatusCode:"HTTP Status Code",resourceId:"Resource ID",Sso:"SAML SSO 2.0","reseller.name":"Reseller",sendingDomain:"Email Sending Domain"};function c(e,o){return o!=="admin-portal"&&e in t?t[e]:e in a?a[e]:n(e)}const r=i("admin-portal");function h({projectName:e,children:o}){return s(r.Provider,{value:e,children:o})}function d(){return l(r)}function A(){const e=d();return o=>c(o,e)}export{h as ProjectProvider,y as RESOURCE_DEFINITIONS,f as RESOURCE_NAMES,d as useProjectName,A as useResourceFormatter};
|
|
2
|
+
//# sourceMappingURL=resource-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-names.js","sources":["../../lib/utils/resource-names.tsx"],"sourcesContent":["import { convertCamelCaseToTitleCase, type CtxPortals } from \"lib/utils/primitives\";\nimport { createContext, use } from \"react\";\n\n// Display names specific to customer and reseller portal\nconst OTHER_PORTALS_DISPLAY_NAME: Record<string, string> = {\n \"product.displayName\": \"Product\",\n};\n\n/** Resource Name should ALWAYS be in singular form */\nexport const RESOURCE_NAMES = [\n \"access-token\",\n \"account\",\n \"activation\",\n \"activation-log\",\n \"admin-role\",\n \"audit-log\",\n \"automated-email\",\n \"automated-email-event-log\",\n \"card\",\n \"feature-flag\",\n \"invoice\",\n \"license\",\n \"license-template\",\n \"maintenance-policy\",\n \"organization\",\n \"plan\",\n \"product\",\n \"product-version\",\n \"profile\",\n \"release\",\n \"release-channel\",\n \"release-file\",\n \"release-platform\",\n \"report\",\n \"role\",\n \"role-claim\",\n \"saml-configuration\",\n \"segment\",\n \"sending-domain\",\n \"setting\",\n \"tag\",\n \"team-member\",\n \"trial\",\n \"trial-policy\",\n \"user\",\n \"user-group\",\n \"webhook\",\n \"webhook-event-log\",\n \"webhook-trigger\",\n \"reseller\",\n \"oidc-configuration\",\n \"organization-claim\",\n \"reseller-claim\",\n] as const;\nexport type ResourceName = (typeof RESOURCE_NAMES)[number];\nexport const RESOURCE_DEFINITIONS: Record<ResourceName, string> = {\n account: \"Your organization account.\",\n product: \"Products are the software products you want to license\",\n license:\n \"Licenses represent a purchase of your software. These can be linked to customers, and the license key is required to use the product.\",\n \"access-token\": \"Access Tokens are used to authenticate your API requests.\",\n activation:\n \"Activations, also known as devices/machines/seats are the devices consuming licenses.\",\n \"activation-log\":\n \"Activation Log is a log entry of activation/deactivation of a particular license.\",\n trial:\n \"Trial/Trial Activation is a device that has activated a trial of your product.\",\n \"audit-log\": \"Audit logs contain all the changes made to your account.\",\n \"automated-email\":\n \"Automated Email allow you to send marketing emails based on events on the linked product.\",\n \"automated-email-event-log\":\n \"Automated email event log is the log of all the automated email events for your product.\",\n card: \"The payment card for your account.\",\n \"feature-flag\":\n \"Feature flags define features that make up tiers for your products.\",\n invoice: \"\",\n \"license-template\":\n \"License templates are a blueprint for the licenses you create for your customers and prevent repetition when creating licenses.\",\n \"maintenance-policy\":\n \"Maintenance policies represent support contracts and can be linked to licenses.\",\n plan: \"\",\n \"product-version\":\n \"Product Versions are sets of Feature Flags that define the tiers of your products.\",\n \"release-channel\": \"Release channel is the release channel for your product.\",\n \"release-file\": \"Release files are files within your created releases.\",\n \"release-platform\":\n 'Release Platforms differentiate the target platform for your release. Common platforms include \"Windows\", \"macOS\", and \"Linux\".',\n release:\n \"Releases help you to manage different versions of your app, and secure distribute it to licensed users.\",\n report: \"Analytics data for your account\",\n \"role-claim\": \"\",\n role: \"Roles define permissions for your team.\",\n \"saml-configuration\": \"\",\n segment: \"Sets of filters that can be saved to filter resources.\",\n \"trial-policy\":\n \"Trial policies are templates for creating trials for your products.\",\n \"webhook-event-log\":\n \"Webhook Event Logs are logs of events that have occured on webhooks.\",\n \"webhook-trigger\": \"\",\n webhook:\n \"Webhooks are HTTP callbacks which are triggered by specific events.\",\n organization: \"\",\n profile: \"\",\n setting: \"\",\n tag: \"Tags allow you to manage your licenses and customers on the dashboard.\",\n \"team-member\": \"Team members can access the account based on their roles.\",\n user: \"A user refers to your customer whom you want to license your product.\",\n \"sending-domain\":\n \"Allows Cryptlex to send emails on your behalf using your From Email address\",\n \"admin-role\": \"Roles that have type admin\",\n \"user-group\": \"Groups of users that you can assign licenses to.\",\n reseller:\n \"Resellers allow you to delegate user management to third parties or partners\",\n \"oidc-configuration\": \"\",\n \"organization-claim\": \"\",\n \"reseller-claim\": \"\",\n};\n\nconst RESOURCE_DISPLAY_NAMES: Record<string, string> = {\n id: \"ID\",\n createdAt: \"Creation Date\",\n scopes: \"Permissions\",\n updatedAt: \"Last Updated\",\n expiresAt: \"Expiration Date\",\n lastSeenAt: \"Last Seen\",\n os: \"OS\",\n osVersion: \"OS Version\",\n key: \"License Key\",\n vmName: \"VM Name\",\n container: \"Container\",\n allowedIpRange: \"Allowed IP Range\",\n allowedIpRanges: \"Allowed IP Ranges\",\n allowedIpAddresses: \"Allowed IP Addresses\",\n disallowedIpAddresses: \"Disallowed IP Addresses\",\n allowVmActivation: \"Allow VM Activation\",\n disableGeoLocation: \"Disable Geolocation\",\n \"user.id\": \"User ID\",\n userId: \"User\",\n productId: \"Product\",\n downloads: \"Total Downloads\",\n claims: \"Permissions\",\n googleSsoEnabled: \"Google Login Enabled\",\n lastAttemptedAt: \"Last Attempt Date\",\n url: \"URL\",\n \"trialPolicy.name\": \"Trial Policy Name\",\n \"licensePolicy.name\": \"License Template Name\",\n licensePolicy: \"License Template\",\n eventLog: \"Audit Log\",\n cc: \"CC Recepients\",\n bcc: \"BCC Recepients\",\n ipAddress: \"IP Address\",\n resellerId: \"Reseller\",\n productVersionId: \"Product Version\",\n releaseId: \"Release\",\n maintenancePolicyId: \"Maintenance Policy\",\n webhookId: \"Webhook\",\n automatedEmailId: \"Automated Email\",\n \"location.countryName\": \"Country\",\n \"location.ipAddress\": \"IP Address\",\n \"location.countryCode\": \"Country\",\n organizationId: \"Organization\",\n \"address.country\": \"Country\",\n \"address.addressLine1\": \"Address Line 1\",\n \"address.addressLine2\": \"Address Line 2\",\n responseStatusCode: \"HTTP Status Code\",\n resourceId: \"Resource ID\",\n Sso: \"SAML SSO 2.0\",\n \"reseller.name\": \"Reseller\",\n sendingDomain: \"Email Sending Domain\",\n};\n\nfunction getResourceDisplayName(\n resourceName: string,\n portal: CtxPortals,\n) {\n if (portal !== \"admin-portal\" && resourceName in OTHER_PORTALS_DISPLAY_NAME) {\n return OTHER_PORTALS_DISPLAY_NAME[resourceName];\n } else if (resourceName in RESOURCE_DISPLAY_NAMES) {\n return RESOURCE_DISPLAY_NAMES[resourceName];\n } else {\n return convertCamelCaseToTitleCase(resourceName);\n }\n}\n\nconst ProjectContext = createContext<CtxPortals>('admin-portal');\n\nexport function ProjectProvider({ projectName, children }: { projectName: CtxPortals; children: React.ReactNode; }) {\n return (\n <ProjectContext.Provider value={projectName}>\n {children}\n </ProjectContext.Provider>\n );\n}\n\nexport function useProjectName(): CtxPortals {\n return use(ProjectContext);\n}\n\nexport function useResourceFormatter(): (resourceName: string) => string {\n const portal = useProjectName();\n return (resourceName: string) => getResourceDisplayName(resourceName, portal);\n}"],"names":["OTHER_PORTALS_DISPLAY_NAME","RESOURCE_NAMES","RESOURCE_DEFINITIONS","RESOURCE_DISPLAY_NAMES","getResourceDisplayName","resourceName","portal","convertCamelCaseToTitleCase","ProjectContext","createContext","ProjectProvider","projectName","children","useProjectName","use","useResourceFormatter"],"mappings":"kKAIA,MAAMA,EAAqD,CACvD,sBAAuB,SAC3B,EAGaC,EAAiB,CAC1B,eACA,UACA,aACA,iBACA,aACA,YACA,kBACA,4BACA,OACA,eACA,UACA,UACA,mBACA,qBACA,eACA,OACA,UACA,kBACA,UACA,UACA,kBACA,eACA,mBACA,SACA,OACA,aACA,qBACA,UACA,iBACA,UACA,MACA,cACA,QACA,eACA,OACA,aACA,UACA,oBACA,kBACA,WACA,qBACA,qBACA,gBACJ,EAEaC,EAAqD,CAC9D,QAAS,6BACT,QAAS,yDACT,QACI,wIACJ,eAAgB,4DAChB,WACI,wFACJ,iBACI,oFACJ,MACI,iFACJ,YAAa,2DACb,kBACI,4FACJ,4BACI,2FACJ,KAAM,qCACN,eACI,sEACJ,QAAS,GACT,mBACI,kIACJ,qBACI,kFACJ,KAAM,GACN,kBACI,qFACJ,kBAAmB,2DACnB,eAAgB,wDAChB,mBACI,kIACJ,QACI,0GACJ,OAAQ,kCACR,aAAc,GACd,KAAM,0CACN,qBAAsB,GACtB,QAAS,yDACT,eACI,sEACJ,oBACI,uEACJ,kBAAmB,GACnB,QACI,sEACJ,aAAc,GACd,QAAS,GACT,QAAS,GACT,IAAK,yEACL,cAAe,4DACf,KAAM,wEACN,iBACI,8EACJ,aAAc,6BACd,aAAc,mDACd,SACI,+EACJ,qBAAsB,GACtB,qBAAsB,GACtB,iBAAkB,EACtB,EAEMC,EAAiD,CACnD,GAAI,KACJ,UAAW,gBACX,OAAQ,cACR,UAAW,eACX,UAAW,kBACX,WAAY,YACZ,GAAI,KACJ,UAAW,aACX,IAAK,cACL,OAAQ,UACR,UAAW,YACX,eAAgB,mBAChB,gBAAiB,oBACjB,mBAAoB,uBACpB,sBAAuB,0BACvB,kBAAmB,sBACnB,mBAAoB,sBACpB,UAAW,UACX,OAAQ,OACR,UAAW,UACX,UAAW,kBACX,OAAQ,cACR,iBAAkB,uBAClB,gBAAiB,oBACjB,IAAK,MACL,mBAAoB,oBACpB,qBAAsB,wBACtB,cAAe,mBACf,SAAU,YACV,GAAI,gBACJ,IAAK,iBACL,UAAW,aACX,WAAY,WACZ,iBAAkB,kBAClB,UAAW,UACX,oBAAqB,qBACrB,UAAW,UACX,iBAAkB,kBAClB,uBAAwB,UACxB,qBAAsB,aACtB,uBAAwB,UACxB,eAAgB,eAChB,kBAAmB,UACnB,uBAAwB,iBACxB,uBAAwB,iBACxB,mBAAoB,mBACpB,WAAY,cACZ,IAAK,eACL,gBAAiB,WACjB,cAAe,sBACnB,EAEA,SAASC,EACLC,EACAC,EACF,CACE,OAAIA,IAAW,gBAAkBD,KAAgBL,EACtCA,EAA2BK,CAAY,EACvCA,KAAgBF,EAChBA,EAAuBE,CAAY,EAEnCE,EAA4BF,CAAY,CAEvD,CAEA,MAAMG,EAAiBC,EAA0B,cAAc,EAExD,SAASC,EAAgB,CAAE,YAAAC,EAAa,SAAAC,GAAqE,CAChH,SACKJ,EAAe,SAAf,CAAwB,MAAOG,EAC3B,SAAAC,EACL,CAER,CAEO,SAASC,GAA6B,CACzC,OAAOC,EAAIN,CAAc,CAC7B,CAEO,SAASO,GAAyD,CACrE,MAAMT,EAASO,EAAA,EACf,OAAQR,GAAyBD,EAAuBC,EAAcC,CAAM,CAChF"}
|
package/dist/utils/use-mobile.js
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export function useIsMobile() {
|
|
4
|
-
const [isMobile, setIsMobile] = useState(undefined);
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
7
|
-
const onChange = () => {
|
|
8
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
9
|
-
};
|
|
10
|
-
mql.addEventListener("change", onChange);
|
|
11
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
12
|
-
return () => mql.removeEventListener("change", onChange);
|
|
13
|
-
}, []);
|
|
14
|
-
return !!isMobile;
|
|
15
|
-
}
|
|
1
|
+
import{useState as s,useEffect as r}from"react";const e=768;function c(){const[o,n]=s(void 0);return r(()=>{const t=window.matchMedia(`(max-width: ${e-1}px)`),i=()=>{n(window.innerWidth<e)};return t.addEventListener("change",i),n(window.innerWidth<e),()=>t.removeEventListener("change",i)},[]),!!o}export{c as useIsMobile};
|
|
2
|
+
//# sourceMappingURL=use-mobile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-mobile.js","sources":["../../lib/utils/use-mobile.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nconst MOBILE_BREAKPOINT = 768;\n\nexport function useIsMobile() {\n\tconst [isMobile, setIsMobile] = useState<boolean | undefined>(\n\t\tundefined,\n\t);\n\n\tuseEffect(() => {\n\t\tconst mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);\n\t\tconst onChange = () => {\n\t\t\tsetIsMobile(window.innerWidth < MOBILE_BREAKPOINT);\n\t\t};\n\t\tmql.addEventListener(\"change\", onChange);\n\t\tsetIsMobile(window.innerWidth < MOBILE_BREAKPOINT);\n\t\treturn () => mql.removeEventListener(\"change\", onChange);\n\t}, []);\n\n\treturn !!isMobile;\n}\n"],"names":["MOBILE_BREAKPOINT","useIsMobile","isMobile","setIsMobile","useState","useEffect","mql","onChange"],"mappings":"gDAEA,MAAMA,EAAoB,IAEnB,SAASC,GAAc,CAC7B,KAAM,CAACC,EAAUC,CAAW,EAAIC,EAC/B,MAAA,EAGD,OAAAC,EAAU,IAAM,CACf,MAAMC,EAAM,OAAO,WAAW,eAAeN,EAAoB,CAAC,KAAK,EACjEO,EAAW,IAAM,CACtBJ,EAAY,OAAO,WAAaH,CAAiB,CAClD,EACA,OAAAM,EAAI,iBAAiB,SAAUC,CAAQ,EACvCJ,EAAY,OAAO,WAAaH,CAAiB,EAC1C,IAAMM,EAAI,oBAAoB,SAAUC,CAAQ,CACxD,EAAG,CAAA,CAAE,EAEE,CAAC,CAACL,CACV"}
|
package/lib/utilities.css
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
|
|
49
49
|
/* A base set of classes for elements that can be clicked */
|
|
50
50
|
@utility btn {
|
|
51
|
-
@apply cursor-pointer ring-offset-background [&_svg:not([class*='size-'])]:size-icon shrink-0 [&_svg]:shrink-0 leading-none outline-none no-underline whitespace-nowrap select-none disabled-muted focus-ring;
|
|
51
|
+
@apply inline-flex gap-1 text-ellipsis overflow-hidden items-center justify-center font-medium transition-colors cursor-pointer ring-offset-background [&_svg:not([class*='size-'])]:size-icon shrink-0 [&_svg]:shrink-0 leading-none outline-none no-underline whitespace-nowrap select-none disabled-muted focus-ring;
|
|
52
52
|
}
|
|
53
53
|
@utility btn-primary {
|
|
54
54
|
@apply border border-primary text-primary bg-card hover:bg-primary/10 data-[hovered]:bg-primary/10 focus:bg-primary/10 data-[focused]:bg-primary/10;
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
@utility prose {
|
|
92
|
-
/* TODO, starting points are not correct */
|
|
92
|
+
/* TODO, starting points are not correct, use tw-type */
|
|
93
93
|
li {
|
|
94
94
|
@apply list-inside;
|
|
95
95
|
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptlex/web-components",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "React component library for Cryptlex web applications",
|
|
5
5
|
"author": "Cryptlex",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
8
8
|
"exports": {
|
|
9
9
|
"./components/*": {
|
|
10
|
-
"import": "./dist/components
|
|
10
|
+
"import": "./dist/components/*.js",
|
|
11
|
+
"types": "./dist/components/*.d.ts"
|
|
11
12
|
},
|
|
12
13
|
"./utils/*": {
|
|
13
|
-
"import": "./dist/utils
|
|
14
|
+
"import": "./dist/utils/*.js",
|
|
15
|
+
"types": "./dist/utils/*.d.ts"
|
|
14
16
|
},
|
|
15
|
-
"
|
|
16
|
-
"./tokens.css": "./lib/tokens.css",
|
|
17
|
-
"./theme.css": "./lib/theme.css",
|
|
18
|
-
"./base.css": "./lib/base.css",
|
|
19
|
-
"./utilities.css": "./lib/utilities.css"
|
|
17
|
+
"./*.css": "./lib/*.css"
|
|
20
18
|
},
|
|
21
19
|
"files": [
|
|
22
20
|
"dist",
|
|
@@ -46,7 +44,7 @@
|
|
|
46
44
|
"@dnd-kit/core": "6.3.1",
|
|
47
45
|
"@dnd-kit/sortable": "10.0.0",
|
|
48
46
|
"@dnd-kit/utilities": "3.2.2",
|
|
49
|
-
"@internationalized/date": "
|
|
47
|
+
"@internationalized/date": "3.8.2",
|
|
50
48
|
"@tanstack/react-form": "1.6.3",
|
|
51
49
|
"@tanstack/react-query": "5.62.3",
|
|
52
50
|
"@tanstack/react-table": "8.20.5",
|
|
@@ -66,6 +64,7 @@
|
|
|
66
64
|
"tw-animate-css": "1.3.0"
|
|
67
65
|
},
|
|
68
66
|
"devDependencies": {
|
|
67
|
+
"@rollup/plugin-node-resolve": "16.0.1",
|
|
69
68
|
"@storybook/addon-docs": "9.0.18",
|
|
70
69
|
"@storybook/addon-links": "9.0.18",
|
|
71
70
|
"@storybook/addon-onboarding": "9.0.18",
|
|
@@ -75,17 +74,19 @@
|
|
|
75
74
|
"@types/node": "^22.7.8",
|
|
76
75
|
"@types/react": "^19.1.0",
|
|
77
76
|
"@types/react-dom": "^19.1.0",
|
|
78
|
-
"@vitejs/plugin-react": "
|
|
77
|
+
"@vitejs/plugin-react": "4.7.0",
|
|
78
|
+
"rollup-preserve-directives": "1.1.3",
|
|
79
79
|
"sass": "1.80.6",
|
|
80
80
|
"storybook": "9.0.18",
|
|
81
81
|
"typescript": "5.8.3",
|
|
82
82
|
"typescript-eslint": "8.38.0",
|
|
83
83
|
"vite": "7.0.6",
|
|
84
|
-
"vite-
|
|
84
|
+
"vite-plugin-dts": "4.5.4",
|
|
85
|
+
"vite-tsconfig-paths": "5.1.4",
|
|
85
86
|
"zod": "3.25.20"
|
|
86
87
|
},
|
|
87
88
|
"scripts": {
|
|
88
|
-
"build": "tsc
|
|
89
|
+
"build": "tsc && vite build",
|
|
89
90
|
"lint": "eslint .",
|
|
90
91
|
"storybook": "storybook dev -p 6006 --no-open",
|
|
91
92
|
"build:storybook": "storybook build",
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useDataTable } from "lib/components/data-table/data-table";
|
|
3
|
-
import { TfDatePicker } from "lib/components/inputs/date-picker";
|
|
4
|
-
import { TfIdSearchInput } from "lib/components/inputs/id-search";
|
|
5
|
-
import { Button } from "lib/components/ui/button";
|
|
6
|
-
import { EasyMenu, MenuItem } from "lib/components/ui/menu";
|
|
7
|
-
import { Popover, PopoverTrigger } from "lib/components/ui/popover";
|
|
8
|
-
import { useAppForm } from "lib/utils/form-hook";
|
|
9
|
-
import { cn } from "lib/utils/primitives";
|
|
10
|
-
import { useResourceFormatter } from "lib/utils/resource-names";
|
|
11
|
-
import { Filter, Trash } from "lucide-react";
|
|
12
|
-
import { useRef } from "react";
|
|
13
|
-
export const FILTER_COMPARISON_OPERATORS = [
|
|
14
|
-
'eq',
|
|
15
|
-
'ne',
|
|
16
|
-
'cn',
|
|
17
|
-
'nc',
|
|
18
|
-
'sw',
|
|
19
|
-
'ew',
|
|
20
|
-
'in',
|
|
21
|
-
'nin',
|
|
22
|
-
'gt',
|
|
23
|
-
'gte',
|
|
24
|
-
'lt',
|
|
25
|
-
'lte',
|
|
26
|
-
];
|
|
27
|
-
export const COMPARISON_OPERATOR_LABELS = {
|
|
28
|
-
eq: 'equal to',
|
|
29
|
-
ne: 'not equal to',
|
|
30
|
-
cn: 'contains',
|
|
31
|
-
nc: 'does not contain',
|
|
32
|
-
sw: 'starts with',
|
|
33
|
-
ew: 'ends with',
|
|
34
|
-
in: 'includes',
|
|
35
|
-
nin: 'does not include',
|
|
36
|
-
gt: 'greater than',
|
|
37
|
-
gte: 'greater than or equal to',
|
|
38
|
-
lt: 'less than',
|
|
39
|
-
lte: 'less than or equal to',
|
|
40
|
-
};
|
|
41
|
-
const FilterOperations = {
|
|
42
|
-
'bool': ['eq'],
|
|
43
|
-
'enum': ['in', 'nin'],
|
|
44
|
-
'id': ['in', 'nin'],
|
|
45
|
-
'id-search': ['in', 'nin'],
|
|
46
|
-
'string': ['eq', 'ne', 'cn', 'nc', 'sw', 'ew', 'in', 'nin'],
|
|
47
|
-
'date': ['lt', 'gt'],
|
|
48
|
-
};
|
|
49
|
-
export function DataTableFilter({ className, ...props }) {
|
|
50
|
-
const { filters, query, setFilters, filterConfig } = useDataTable();
|
|
51
|
-
// TODO focus
|
|
52
|
-
// const localFilterRefs = useRef([]);
|
|
53
|
-
const addFilterButtonRef = useRef(null);
|
|
54
|
-
const resourceFormatter = useResourceFormatter();
|
|
55
|
-
const DEFAULT_VALUES = {
|
|
56
|
-
// TODO, initialize with filters from tableState
|
|
57
|
-
filters: []
|
|
58
|
-
};
|
|
59
|
-
const form = useAppForm({
|
|
60
|
-
defaultValues: DEFAULT_VALUES,
|
|
61
|
-
onSubmit: ({ value }) => {
|
|
62
|
-
// TODO, instead of generic transformation, use type based tranform()
|
|
63
|
-
setFilters(value.filters.map(lf => { return { [lf.property]: { [lf.operator]: [lf.value] } }; }));
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
// More reason to hate TS https://github.com/Microsoft/TypeScript/issues/12870
|
|
67
|
-
const filterKeys = Object.keys(filterConfig).sort();
|
|
68
|
-
return (_jsx("section", { ...props, className: cn("flex gap-icon items-center", className), children: _jsxs(PopoverTrigger, { onOpenChange: (o) => {
|
|
69
|
-
// Set filters when the popover closes
|
|
70
|
-
if (!o) {
|
|
71
|
-
form.handleSubmit();
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
addFilterButtonRef.current?.focus();
|
|
75
|
-
}
|
|
76
|
-
}, children: [_jsx(Button, { active: filters.length > 0, isDisabled: query.isPending || filterKeys.length === 0, type: "button", size: 'icon', variant: 'neutral', children: _jsx(Filter, {}) }), _jsx(Popover, { className: "w-full p-icon", children: _jsx("form", { onSubmit: (e) => { e.preventDefault(); }, className: "flex flex-col gap-icon max-h-table overflow-auto ", children: _jsx(form.Field, { mode: "array", name: "filters", children: (field) => {
|
|
77
|
-
return _jsxs(_Fragment, { children: [field.state.value.map((lf, i) => {
|
|
78
|
-
return (_jsxs("div", { className: "flex gap-icon items-center justify-normal", children: [_jsx("span", { className: "text-sm", children: resourceFormatter(lf.property) }), _jsx(form.AppField, { name: `filters[${i}].operator`, children: (sf) => (_jsx(sf.TfSingleSelect, { items: FilterOperations[lf.type].map(op => ({ id: op, label: _jsx(_Fragment, { children: COMPARISON_OPERATOR_LABELS[op] }) })) })) }, lf.id), lf.type === 'bool' && _jsx(form.AppField, { name: `filters[${i}].value`, children: (sf) => (_jsx(sf.TfCheckbox, {})) }), lf.type === 'date' && _jsx(form.AppField, { name: `filters[${i}].value`, children: (_) => (_jsx(TfDatePicker, {})) }), lf.type === 'id' && _jsx(form.AppField, { name: `filters[${i}].value`, children: (sf) => (_jsx(sf.TfTextField, {})) }), lf.type === 'string' && _jsx(form.AppField, { name: `filters[${i}].value`, children: (sf) => (_jsx(sf.TfTextField, {})) }), lf.type === 'enum' && _jsx(form.AppField, { name: `filters[${i}].value`, children: (sf) => (_jsx(sf.TfMultiSelect, { items: filterConfig[lf.property].options })) }), lf.type === 'id-search' && _jsx(form.AppField, { name: `filters[${i}].value`, children: (_) => (_jsx(TfIdSearchInput, { multiple: true, accessor: "id", searchFn: filterConfig[lf.property].search })) }), _jsx(Button, { type: "button", variant: "destructive", size: "icon", onPress: () => field.removeValue(i), children: _jsx(Trash, {}) })] }, lf.id));
|
|
79
|
-
}), _jsxs("div", { className: "flex w-full items-center justify-end gap-2 not-first:mt-icon", children: [_jsx(EasyMenu, { label: "Add Filter", children: filterKeys.map(k => _jsx(MenuItem, { onAction: () => {
|
|
80
|
-
//@ts-ignore
|
|
81
|
-
const type = filterConfig[k].type;
|
|
82
|
-
const defaultValue = (t) => {
|
|
83
|
-
// TODO, ensure exhaustive???
|
|
84
|
-
switch (t) {
|
|
85
|
-
case 'bool':
|
|
86
|
-
return true;
|
|
87
|
-
case 'string':
|
|
88
|
-
return '';
|
|
89
|
-
case 'date':
|
|
90
|
-
return new Date().toISOString();
|
|
91
|
-
case 'id':
|
|
92
|
-
return '';
|
|
93
|
-
case 'id-search':
|
|
94
|
-
return [];
|
|
95
|
-
case 'enum':
|
|
96
|
-
return [];
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const newFilter = {
|
|
100
|
-
id: `${k}-${Date.now()}`,
|
|
101
|
-
operator: FilterOperations[type][0],
|
|
102
|
-
//@ts-ignore
|
|
103
|
-
value: defaultValue(type),
|
|
104
|
-
type: type,
|
|
105
|
-
property: k,
|
|
106
|
-
};
|
|
107
|
-
field.pushValue(newFilter);
|
|
108
|
-
// TODO Focus to ref
|
|
109
|
-
}, className: "dropdown-item", children: resourceFormatter(k) }, k)) }), field.state.value.length > 0 ? (_jsx(Button, { type: "button", variant: "neutral", onPress: () => { field.setValue([]); }, children: "Reset filters" })) : null] })] });
|
|
110
|
-
} }) }) })] }) }));
|
|
111
|
-
}
|
|
112
|
-
;
|