@getmicdrop/svelte-components 5.3.13 → 5.3.14

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.
@@ -1,21 +1,26 @@
1
1
  /**
2
- * Form options for dropdowns used across the performers portal.
2
+ * Form options for dropdowns used across all Micdrop applications.
3
3
  * Use these with Select and MultiSelect components instead of
4
4
  * creating wrapper components like GenderInput or EthnicityDropdown.
5
5
  *
6
6
  * Example:
7
- * import { GENDER_OPTIONS } from './formOptions';
7
+ * import { GENDER_OPTIONS } from '@getmicdrop/svelte-components/constants/formOptions';
8
8
  * <Select items={GENDER_OPTIONS} label="Gender" />
9
9
  */
10
10
  export const GENDER_OPTIONS: ({
11
11
  name: string;
12
- value: number;
12
+ value: null;
13
13
  } | {
14
14
  name: string;
15
- value: null;
15
+ value: number;
16
16
  })[];
17
+ export const GENDER_OPTIONS_VALUE_LABEL: {
18
+ value: number;
19
+ label: string;
20
+ }[];
17
21
  export const ETHNICITY_OPTIONS: {
18
22
  name: string;
19
23
  value: number;
20
24
  }[];
25
+ export const ETHNICITY_NAMES: string[];
21
26
  //# sourceMappingURL=formOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formOptions.d.ts","sourceRoot":"","sources":["../../src/lib/constants/formOptions.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;KAKE;AAEF;;;IAQE"}
1
+ {"version":3,"file":"formOptions.d.ts","sourceRoot":"","sources":["../../src/lib/constants/formOptions.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH;;;;;;KAME;AAGF;;;IAKE;AAGF;;;IAQE;AAGF,uCAQE"}
@@ -1,26 +1,48 @@
1
- /**
2
- * Form options for dropdowns used across the performers portal.
3
- * Use these with Select and MultiSelect components instead of
4
- * creating wrapper components like GenderInput or EthnicityDropdown.
5
- *
6
- * Example:
7
- * import { GENDER_OPTIONS } from './formOptions';
8
- * <Select items={GENDER_OPTIONS} label="Gender" />
9
- */
10
-
11
- export const GENDER_OPTIONS = [
12
- { name: "Male", value: 1 },
13
- { name: "Female", value: 2 },
14
- { name: "Non-binary", value: 3 },
15
- { name: "Rather not say", value: null },
16
- ];
17
-
18
- export const ETHNICITY_OPTIONS = [
19
- { name: "American Indian or Alaska Native", value: 0 },
20
- { name: "Asian", value: 1 },
21
- { name: "Black or African American", value: 2 },
22
- { name: "Hispanic or Latino", value: 3 },
23
- { name: "Middle Eastern or North African", value: 4 },
24
- { name: "Native Hawaiian or Pacific Islander", value: 5 },
25
- { name: "White", value: 6 },
26
- ];
1
+ /**
2
+ * Form options for dropdowns used across all Micdrop applications.
3
+ * Use these with Select and MultiSelect components instead of
4
+ * creating wrapper components like GenderInput or EthnicityDropdown.
5
+ *
6
+ * Example:
7
+ * import { GENDER_OPTIONS } from '@getmicdrop/svelte-components/constants/formOptions';
8
+ * <Select items={GENDER_OPTIONS} label="Gender" />
9
+ */
10
+
11
+ // Primary format: { name, value } for Select/MultiSelect components
12
+ export const GENDER_OPTIONS = [
13
+ { name: "", value: null },
14
+ { name: "Male", value: 1 },
15
+ { name: "Female", value: 2 },
16
+ { name: "Non-binary", value: 3 },
17
+ { name: "Rather not say", value: 4 },
18
+ ];
19
+
20
+ // Alternative format: { value, label } for components using that convention
21
+ export const GENDER_OPTIONS_VALUE_LABEL = [
22
+ { value: 0, label: 'Male' },
23
+ { value: 1, label: 'Female' },
24
+ { value: 2, label: 'Non-binary' },
25
+ { value: 3, label: 'Rather not say' },
26
+ ];
27
+
28
+ // Primary format: { name, value } for Select/MultiSelect components
29
+ export const ETHNICITY_OPTIONS = [
30
+ { name: "American Indian or Alaska Native", value: 0 },
31
+ { name: "Asian", value: 1 },
32
+ { name: "Black or African American", value: 2 },
33
+ { name: "Hispanic or Latino", value: 3 },
34
+ { name: "Middle Eastern or North African", value: 4 },
35
+ { name: "Native Hawaiian or Pacific Islander", value: 5 },
36
+ { name: "White", value: 6 },
37
+ ];
38
+
39
+ // Simple string array of ethnicity names (for backward compatibility)
40
+ export const ETHNICITY_NAMES = [
41
+ "American Indian or Alaska Native",
42
+ "Asian",
43
+ "Black or African American",
44
+ "Hispanic or Latino",
45
+ "Middle Eastern or North African",
46
+ "Native Hawaiian or Pacific Islander",
47
+ "White",
48
+ ];
package/dist/index.d.ts CHANGED
@@ -112,16 +112,6 @@ export { default as ShowTimeCard } from "./calendar/ShowTimeCard/ShowTimeCard.sv
112
112
  export * from "./constants/formOptions.js";
113
113
  export * from "./constants/validation.js";
114
114
  export * from "./presets/index.js";
115
- export * from "./utils/utils.js";
116
- export * from "./utils/utils/utils.js";
117
- export * from "./utils/greetings.js";
118
- export * from "./utils/imageValidation.js";
119
- export * from "./utils/apiConfig.js";
120
- export * from "./stores/toaster.js";
121
- export * from "./stores/navigation.js";
122
- export * from "./stores/auth.js";
123
- export * from "./config.js";
124
- export * from "./telemetry.js";
125
115
  export { portal } from "./utils/portal.js";
126
116
  export { typography } from "./tokens/typography.js";
127
117
  export { default as MiniMonthCalendar, default as Calendar } from "./calendar/Calendar/MiniMonthCalendar.svelte";
package/dist/index.js CHANGED
@@ -216,22 +216,8 @@ export * from './constants/validation.js';
216
216
  // Presets - Domain-to-color mappings for migration
217
217
  export * from './presets/index.js';
218
218
 
219
- // Utils / Actions
220
- export { portal } from './utils/portal.js';
221
- export * from './utils/utils.js';
222
- export * from './utils/utils/utils.js';
223
- export * from './utils/greetings.js';
224
- export * from './utils/imageValidation.js';
225
- export * from './utils/apiConfig.js';
226
-
227
- // Stores
228
- export * from './stores/toaster.js';
229
- export * from './stores/navigation.js';
230
- export * from './stores/auth.js';
231
-
232
- // Config & Telemetry
233
- export * from './config.js';
234
- export * from './telemetry.js';
235
-
236
- // Design Tokens
237
- export { typography } from './tokens/typography.js';
219
+ // Utils / Actions
220
+ export { portal } from './utils/portal.js';
221
+
222
+ // Design Tokens
223
+ export { typography } from './tokens/typography.js';
@@ -1,123 +1,36 @@
1
- import { writable, get, derived } from "svelte/store";
2
- import { jwtDecode } from "jwt-decode";
3
-
4
- // Store to manage authentication state
5
- export const auth = writable({
6
- isAuthenticated: false,
7
- token: null,
8
- refreshToken: null,
9
- userDetails: null, // To store email and first name
10
- tokenExpiry: null, // Token expiration timestamp
11
- permissions: null, // RBAC permissions
12
- context: null, // User context (performer)
13
- });
14
-
15
- // Derived store for checking if user has performer permissions
16
- export const isPerformer = derived(auth, ($auth) =>
17
- $auth.context?.contextType === 'performer' || $auth.isAuthenticated
18
- );
19
-
20
- // Function to set authentication state
21
- export const setAuthState = (state) => {
22
- auth.set(state);
23
- };
24
-
25
- // Function to clear the authentication state
26
- export const clearAuthState = () => {
27
- auth.set({
28
- isAuthenticated: false,
29
- token: null,
30
- refreshToken: null,
31
- userDetails: null,
32
- tokenExpiry: null,
33
- permissions: null,
34
- context: null,
35
- });
36
- };
37
-
38
- // Parse cookies helper
39
- const parseCookies = () => {
40
- if (typeof document === "undefined") return {};
41
- return Object.fromEntries(
42
- document.cookie
43
- .split("; ")
44
- .filter(c => c)
45
- .map((c) => c.split("="))
46
- .map(([k, v]) => [k, decodeURIComponent(v || "")])
47
- );
48
- };
49
-
50
- // Get token expiry from JWT
51
- const getTokenExpiry = (token) => {
52
- if (!token) return null;
53
- try {
54
- const decoded = jwtDecode(token);
55
- return decoded.exp ? decoded.exp * 1000 : null; // Convert to milliseconds
56
- } catch {
57
- return null;
58
- }
59
- };
60
-
61
- // Check if token is expired or about to expire (within 5 minutes)
62
- export const isTokenExpiringSoon = (bufferMs = 5 * 60 * 1000) => {
63
- const state = get(auth);
64
- if (!state.tokenExpiry) return true;
65
- return Date.now() >= (state.tokenExpiry - bufferMs);
66
- };
67
-
68
- // Initialize the store from cookies
69
- export const initializeAuthState = () => {
70
- const cookies = parseCookies();
71
-
72
- if (cookies.performer_token) {
73
- const tokenExpiry = getTokenExpiry(cookies.performer_token);
74
-
75
- setAuthState({
76
- isAuthenticated: true,
77
- token: cookies.performer_token,
78
- refreshToken: cookies.performer_refresh_token || null,
79
- userDetails: cookies.userDetails ? JSON.parse(cookies.userDetails) : null,
80
- tokenExpiry,
81
- });
82
- }
83
- };
84
-
85
- // Update tokens after a refresh
86
- export const updateTokens = (accessToken, refreshToken) => {
87
- auth.update(state => ({
88
- ...state,
89
- token: accessToken,
90
- refreshToken: refreshToken || state.refreshToken,
91
- tokenExpiry: getTokenExpiry(accessToken),
92
- }));
93
- };
94
-
95
- // Update permissions
96
- export const setPermissions = (permissions) => {
97
- auth.update(state => ({
98
- ...state,
99
- permissions,
100
- }));
101
- };
102
-
103
- // Set user context
104
- export const setContext = (context) => {
105
- auth.update(state => ({
106
- ...state,
107
- context,
108
- }));
109
- };
110
-
111
- // Check if user has a specific permission
112
- export const hasPermission = (category, permission) => {
113
- const state = get(auth);
114
- if (!state.permissions) return false;
115
-
116
- // Performers have limited permissions by design
117
- return state.permissions[category]?.[permission] ?? false;
118
- };
119
-
120
- // Get current permissions
121
- export const getPermissions = () => {
122
- return get(auth).permissions;
123
- };
1
+ import { writable } from "svelte/store";
2
+
3
+ // Store to manage authentication state
4
+ export const auth = writable({
5
+ isAuthenticated: false,
6
+ token: null,
7
+ userDetails: null, // To store email and first name
8
+ });
9
+
10
+ // Function to set authentication state
11
+ export const setAuthState = (state) => {
12
+ auth.set(state);
13
+ };
14
+
15
+ // Function to clear the authentication state
16
+ export const clearAuthState = () => {
17
+ auth.set({ isAuthenticated: false, token: null, userDetails: null });
18
+ };
19
+
20
+ // Initialize the store from cookies
21
+ export const initializeAuthState = () => {
22
+ const cookies = Object.fromEntries(
23
+ document.cookie
24
+ .split("; ")
25
+ .map((c) => c.split("="))
26
+ .map(([k, v]) => [k, decodeURIComponent(v)])
27
+ );
28
+
29
+ if (cookies.performer_token) {
30
+ setAuthState({
31
+ isAuthenticated: true,
32
+ token: cookies.performer_token,
33
+ userDetails: cookies.userDetails ? JSON.parse(cookies.userDetails) : null,
34
+ });
35
+ }
36
+ };