@vritti/quantum-ui 0.2.5 → 0.2.7

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.
Files changed (71) hide show
  1. package/dist/Button2.js +2 -1
  2. package/dist/Button2.js.map +1 -1
  3. package/dist/Checkbox.js +3 -5
  4. package/dist/Checkbox.js.map +1 -1
  5. package/dist/DatePicker.js +416 -139
  6. package/dist/DatePicker.js.map +1 -1
  7. package/dist/Form.js.map +1 -1
  8. package/dist/Label.js +1 -1
  9. package/dist/Label.js.map +1 -1
  10. package/dist/OTPField.js +1 -1
  11. package/dist/OTPField.js.map +1 -1
  12. package/dist/PasswordField.js +3 -16
  13. package/dist/PasswordField.js.map +1 -1
  14. package/dist/PhoneField.js +23 -7
  15. package/dist/PhoneField.js.map +1 -1
  16. package/dist/Sonner.js +1249 -0
  17. package/dist/Sonner.js.map +1 -0
  18. package/dist/Spinner.js +1 -12
  19. package/dist/Spinner.js.map +1 -1
  20. package/dist/ThemeToggle.js +2 -2
  21. package/dist/ThemeToggle.js.map +1 -1
  22. package/dist/assets/quantum-ui.css +41 -10
  23. package/dist/axios.js +186 -59
  24. package/dist/axios.js.map +1 -1
  25. package/dist/circle-check-big.js +18 -0
  26. package/dist/circle-check-big.js.map +1 -0
  27. package/dist/components/Progress.js +61 -2
  28. package/dist/components/Progress.js.map +1 -1
  29. package/dist/components/Sonner.js +3 -0
  30. package/dist/components/Sonner.js.map +1 -0
  31. package/dist/createLucideIcon.js +4 -4
  32. package/dist/createLucideIcon.js.map +1 -1
  33. package/dist/field.js +2 -36
  34. package/dist/field.js.map +1 -1
  35. package/dist/index.js +2 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/index2.js +130 -54
  38. package/dist/index2.js.map +1 -1
  39. package/dist/index3.js +1 -103
  40. package/dist/index3.js.map +1 -1
  41. package/dist/index4.js +36 -35
  42. package/dist/index4.js.map +1 -1
  43. package/dist/index5.js +303 -3
  44. package/dist/index5.js.map +1 -1
  45. package/dist/lib/components/Sonner/Sonner.d.ts +5 -0
  46. package/dist/lib/components/Sonner/Sonner.d.ts.map +1 -0
  47. package/dist/lib/components/Sonner/index.d.ts +4 -0
  48. package/dist/lib/components/Sonner/index.d.ts.map +1 -0
  49. package/dist/lib/components/Sonner/toast.d.ts +29 -0
  50. package/dist/lib/components/Sonner/toast.d.ts.map +1 -0
  51. package/dist/lib/components/index.d.ts +1 -0
  52. package/dist/lib/components/index.d.ts.map +1 -1
  53. package/dist/lib/utils/axios.d.ts +5 -0
  54. package/dist/lib/utils/axios.d.ts.map +1 -1
  55. package/dist/loader-circle.js +15 -0
  56. package/dist/loader-circle.js.map +1 -0
  57. package/dist/shadcn/index.d.ts +1 -0
  58. package/dist/shadcn/index.d.ts.map +1 -1
  59. package/dist/shadcn/shadcnSonner/index.d.ts +2 -0
  60. package/dist/shadcn/shadcnSonner/index.d.ts.map +1 -0
  61. package/dist/shadcn/shadcnSonner/sonner.d.ts +4 -0
  62. package/dist/shadcn/shadcnSonner/sonner.d.ts.map +1 -0
  63. package/dist/toast.js +72 -0
  64. package/dist/toast.js.map +1 -0
  65. package/dist/utils/axios.js +1 -0
  66. package/dist/utils/axios.js.map +1 -1
  67. package/dist/utils.js +229 -150
  68. package/dist/utils.js.map +1 -1
  69. package/package.json +38 -32
  70. package/dist/index6.js +0 -246
  71. package/dist/index6.js.map +0 -1
package/dist/axios.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { g as generateToastId, t as toast } from './toast.js';
2
+
1
3
  const defaultConfig = {
2
4
  csrf: {
3
5
  endpoint: "/csrf/token",
@@ -68,6 +70,13 @@ function resetConfig() {
68
70
  setGlobalConfig({ ...defaultConfig });
69
71
  }
70
72
 
73
+ /**
74
+ * Create a bound version of a function with a specified `this` context
75
+ *
76
+ * @param {Function} fn - The function to bind
77
+ * @param {*} thisArg - The value to be passed as the `this` parameter
78
+ * @returns {Function} A new function that will call the original function with the specified `this` context
79
+ */
71
80
  function bind(fn, thisArg) {
72
81
  return function wrap() {
73
82
  return fn.apply(thisArg, arguments);
@@ -1320,7 +1329,7 @@ class InterceptorManager {
1320
1329
  *
1321
1330
  * @param {Number} id The ID that was returned by `use`
1322
1331
  *
1323
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1332
+ * @returns {void}
1324
1333
  */
1325
1334
  eject(id) {
1326
1335
  if (this.handlers[id]) {
@@ -2280,27 +2289,38 @@ const cookies = platform.hasStandardBrowserEnv ?
2280
2289
 
2281
2290
  // Standard browser envs support document.cookie
2282
2291
  {
2283
- write(name, value, expires, path, domain, secure) {
2284
- const cookie = [name + '=' + encodeURIComponent(value)];
2285
-
2286
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2292
+ write(name, value, expires, path, domain, secure, sameSite) {
2293
+ if (typeof document === 'undefined') return;
2287
2294
 
2288
- utils$1.isString(path) && cookie.push('path=' + path);
2295
+ const cookie = [`${name}=${encodeURIComponent(value)}`];
2289
2296
 
2290
- utils$1.isString(domain) && cookie.push('domain=' + domain);
2291
-
2292
- secure === true && cookie.push('secure');
2297
+ if (utils$1.isNumber(expires)) {
2298
+ cookie.push(`expires=${new Date(expires).toUTCString()}`);
2299
+ }
2300
+ if (utils$1.isString(path)) {
2301
+ cookie.push(`path=${path}`);
2302
+ }
2303
+ if (utils$1.isString(domain)) {
2304
+ cookie.push(`domain=${domain}`);
2305
+ }
2306
+ if (secure === true) {
2307
+ cookie.push('secure');
2308
+ }
2309
+ if (utils$1.isString(sameSite)) {
2310
+ cookie.push(`SameSite=${sameSite}`);
2311
+ }
2293
2312
 
2294
2313
  document.cookie = cookie.join('; ');
2295
2314
  },
2296
2315
 
2297
2316
  read(name) {
2298
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2299
- return (match ? decodeURIComponent(match[3]) : null);
2317
+ if (typeof document === 'undefined') return null;
2318
+ const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
2319
+ return match ? decodeURIComponent(match[1]) : null;
2300
2320
  },
2301
2321
 
2302
2322
  remove(name) {
2303
- this.write(name, '', Date.now() - 86400000);
2323
+ this.write(name, '', Date.now() - 86400000, '/');
2304
2324
  }
2305
2325
  }
2306
2326
 
@@ -2389,11 +2409,11 @@ function mergeConfig$1(config1, config2) {
2389
2409
  }
2390
2410
 
2391
2411
  // eslint-disable-next-line consistent-return
2392
- function mergeDeepProperties(a, b, prop , caseless) {
2412
+ function mergeDeepProperties(a, b, prop, caseless) {
2393
2413
  if (!utils$1.isUndefined(b)) {
2394
- return getMergedValue(a, b, prop , caseless);
2414
+ return getMergedValue(a, b, prop, caseless);
2395
2415
  } else if (!utils$1.isUndefined(a)) {
2396
- return getMergedValue(undefined, a, prop , caseless);
2416
+ return getMergedValue(undefined, a, prop, caseless);
2397
2417
  }
2398
2418
  }
2399
2419
 
@@ -2451,7 +2471,7 @@ function mergeConfig$1(config1, config2) {
2451
2471
  socketPath: defaultToConfig2,
2452
2472
  responseEncoding: defaultToConfig2,
2453
2473
  validateStatus: mergeDirectKeys,
2454
- headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
2474
+ headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
2455
2475
  };
2456
2476
 
2457
2477
  utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
@@ -3089,7 +3109,7 @@ const factory = (env) => {
3089
3109
  const seedCache = new Map();
3090
3110
 
3091
3111
  const getFetch = (config) => {
3092
- let env = config ? config.env : {};
3112
+ let env = (config && config.env) || {};
3093
3113
  const {fetch, Request, Response} = env;
3094
3114
  const seeds = [
3095
3115
  Request, Response, fetch
@@ -3112,6 +3132,15 @@ const getFetch = (config) => {
3112
3132
 
3113
3133
  getFetch();
3114
3134
 
3135
+ /**
3136
+ * Known adapters mapping.
3137
+ * Provides environment-specific adapters for Axios:
3138
+ * - `http` for Node.js
3139
+ * - `xhr` for browsers
3140
+ * - `fetch` for fetch API-based requests
3141
+ *
3142
+ * @type {Object<string, Function|Object>}
3143
+ */
3115
3144
  const knownAdapters = {
3116
3145
  http: httpAdapter,
3117
3146
  xhr: xhrAdapter,
@@ -3120,71 +3149,107 @@ const knownAdapters = {
3120
3149
  }
3121
3150
  };
3122
3151
 
3152
+ // Assign adapter names for easier debugging and identification
3123
3153
  utils$1.forEach(knownAdapters, (fn, value) => {
3124
3154
  if (fn) {
3125
3155
  try {
3126
- Object.defineProperty(fn, 'name', {value});
3156
+ Object.defineProperty(fn, 'name', { value });
3127
3157
  } catch (e) {
3128
3158
  // eslint-disable-next-line no-empty
3129
3159
  }
3130
- Object.defineProperty(fn, 'adapterName', {value});
3160
+ Object.defineProperty(fn, 'adapterName', { value });
3131
3161
  }
3132
3162
  });
3133
3163
 
3164
+ /**
3165
+ * Render a rejection reason string for unknown or unsupported adapters
3166
+ *
3167
+ * @param {string} reason
3168
+ * @returns {string}
3169
+ */
3134
3170
  const renderReason = (reason) => `- ${reason}`;
3135
3171
 
3172
+ /**
3173
+ * Check if the adapter is resolved (function, null, or false)
3174
+ *
3175
+ * @param {Function|null|false} adapter
3176
+ * @returns {boolean}
3177
+ */
3136
3178
  const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3137
3179
 
3138
- const adapters = {
3139
- getAdapter: (adapters, config) => {
3140
- adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3141
-
3142
- const {length} = adapters;
3143
- let nameOrAdapter;
3144
- let adapter;
3180
+ /**
3181
+ * Get the first suitable adapter from the provided list.
3182
+ * Tries each adapter in order until a supported one is found.
3183
+ * Throws an AxiosError if no adapter is suitable.
3184
+ *
3185
+ * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
3186
+ * @param {Object} config - Axios request configuration
3187
+ * @throws {AxiosError} If no suitable adapter is available
3188
+ * @returns {Function} The resolved adapter function
3189
+ */
3190
+ function getAdapter$1(adapters, config) {
3191
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3145
3192
 
3146
- const rejectedReasons = {};
3193
+ const { length } = adapters;
3194
+ let nameOrAdapter;
3195
+ let adapter;
3147
3196
 
3148
- for (let i = 0; i < length; i++) {
3149
- nameOrAdapter = adapters[i];
3150
- let id;
3197
+ const rejectedReasons = {};
3151
3198
 
3152
- adapter = nameOrAdapter;
3199
+ for (let i = 0; i < length; i++) {
3200
+ nameOrAdapter = adapters[i];
3201
+ let id;
3153
3202
 
3154
- if (!isResolvedHandle(nameOrAdapter)) {
3155
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3203
+ adapter = nameOrAdapter;
3156
3204
 
3157
- if (adapter === undefined) {
3158
- throw new AxiosError$1(`Unknown adapter '${id}'`);
3159
- }
3160
- }
3205
+ if (!isResolvedHandle(nameOrAdapter)) {
3206
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3161
3207
 
3162
- if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
3163
- break;
3208
+ if (adapter === undefined) {
3209
+ throw new AxiosError$1(`Unknown adapter '${id}'`);
3164
3210
  }
3211
+ }
3165
3212
 
3166
- rejectedReasons[id || '#' + i] = adapter;
3213
+ if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
3214
+ break;
3167
3215
  }
3168
3216
 
3169
- if (!adapter) {
3217
+ rejectedReasons[id || '#' + i] = adapter;
3218
+ }
3170
3219
 
3171
- const reasons = Object.entries(rejectedReasons)
3172
- .map(([id, state]) => `adapter ${id} ` +
3173
- (state === false ? 'is not supported by the environment' : 'is not available in the build')
3174
- );
3220
+ if (!adapter) {
3221
+ const reasons = Object.entries(rejectedReasons)
3222
+ .map(([id, state]) => `adapter ${id} ` +
3223
+ (state === false ? 'is not supported by the environment' : 'is not available in the build')
3224
+ );
3175
3225
 
3176
- let s = length ?
3177
- (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3178
- 'as no adapter specified';
3226
+ let s = length ?
3227
+ (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3228
+ 'as no adapter specified';
3179
3229
 
3180
- throw new AxiosError$1(
3181
- `There is no suitable adapter to dispatch the request ` + s,
3182
- 'ERR_NOT_SUPPORT'
3183
- );
3184
- }
3230
+ throw new AxiosError$1(
3231
+ `There is no suitable adapter to dispatch the request ` + s,
3232
+ 'ERR_NOT_SUPPORT'
3233
+ );
3234
+ }
3185
3235
 
3186
- return adapter;
3187
- },
3236
+ return adapter;
3237
+ }
3238
+
3239
+ /**
3240
+ * Exports Axios adapters and utility to resolve an adapter
3241
+ */
3242
+ const adapters = {
3243
+ /**
3244
+ * Resolve an adapter from a list of adapter names or functions.
3245
+ * @type {Function}
3246
+ */
3247
+ getAdapter: getAdapter$1,
3248
+
3249
+ /**
3250
+ * Exposes all known adapters
3251
+ * @type {Object<string, Function|Object>}
3252
+ */
3188
3253
  adapters: knownAdapters
3189
3254
  };
3190
3255
 
@@ -3261,7 +3326,7 @@ function dispatchRequest(config) {
3261
3326
  });
3262
3327
  }
3263
3328
 
3264
- const VERSION$1 = "1.12.2";
3329
+ const VERSION$1 = "1.13.2";
3265
3330
 
3266
3331
  const validators$1 = {};
3267
3332
 
@@ -3816,6 +3881,12 @@ const HttpStatusCode$1 = {
3816
3881
  LoopDetected: 508,
3817
3882
  NotExtended: 510,
3818
3883
  NetworkAuthenticationRequired: 511,
3884
+ WebServerIsDown: 521,
3885
+ ConnectionTimedOut: 522,
3886
+ OriginIsUnreachable: 523,
3887
+ TimeoutOccurred: 524,
3888
+ SslHandshakeFailed: 525,
3889
+ InvalidSslCertificate: 526,
3819
3890
  };
3820
3891
 
3821
3892
  Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
@@ -4082,16 +4153,72 @@ axios.interceptors.request.use(async (config) => {
4082
4153
  if (!csrf) csrf = await fetchCsrfToken();
4083
4154
  if (csrf) config.headers[quantumConfig.csrf.headerName] = csrf;
4084
4155
  }
4156
+ const loadingMessage = config.loadingMessage;
4157
+ if (loadingMessage) {
4158
+ const toastId = generateToastId();
4159
+ config._toastId = toastId;
4160
+ toast.loading(loadingMessage, { id: toastId });
4161
+ }
4085
4162
  return config;
4086
4163
  });
4087
4164
  axios.interceptors.response.use(
4088
- (response) => response,
4165
+ (response) => {
4166
+ const config = response.config;
4167
+ const method = config.method?.toUpperCase();
4168
+ const isMutation = ["POST", "PUT", "PATCH", "DELETE"].includes(method || "");
4169
+ const toastId = config._toastId;
4170
+ if (toastId) {
4171
+ const message = config.successMessage || response.data?.message;
4172
+ if (message) {
4173
+ toast.success(message, { id: toastId });
4174
+ } else {
4175
+ toast.success("Done", { id: toastId, duration: 1e3 });
4176
+ }
4177
+ } else {
4178
+ const showSuccess = config.showSuccessToast ?? isMutation;
4179
+ if (showSuccess) {
4180
+ const message = config.successMessage || response.data?.message;
4181
+ if (message) {
4182
+ toast.success(message);
4183
+ }
4184
+ }
4185
+ }
4186
+ return response;
4187
+ },
4089
4188
  (error) => {
4090
- const isPublicRequest = error.config?.public === true;
4091
- if (error.response?.status === 401 && !isPublicRequest) {
4189
+ const config = error.config;
4190
+ const showError = config?.showErrorToast ?? true;
4191
+ const status = error.response?.status;
4192
+ const errorData = error.response?.data;
4193
+ const isPublicRequest = config?.public === true;
4194
+ const toastId = config?._toastId;
4195
+ if (status === 401 && !isPublicRequest) {
4196
+ if (toastId) {
4197
+ toast.error("Session expired", { id: toastId });
4198
+ }
4092
4199
  clearToken();
4093
4200
  cancelTokenRefresh();
4094
4201
  redirectToLogin();
4202
+ return Promise.reject(error);
4203
+ }
4204
+ if (showError && status && status >= 500) {
4205
+ const errorMessage = errorData?.message || errorData?.detail || "Something went wrong. Please try again.";
4206
+ if (toastId) {
4207
+ toast.error("Server Error", { id: toastId, description: errorMessage });
4208
+ } else {
4209
+ toast.error("Server Error", { description: errorMessage });
4210
+ }
4211
+ }
4212
+ if (showError && !error.response) {
4213
+ if (toastId) {
4214
+ toast.error("Network Error", { id: toastId, description: "Please check your internet connection." });
4215
+ } else {
4216
+ toast.error("Network Error", { description: "Please check your internet connection." });
4217
+ }
4218
+ }
4219
+ if (toastId && status && status >= 400 && status < 500 && status !== 401) {
4220
+ const errorMessage = errorData?.message || errorData?.detail || "Request failed";
4221
+ toast.error(errorMessage, { id: toastId });
4095
4222
  }
4096
4223
  return Promise.reject(error);
4097
4224
  }