@usebridge/sdk-react 0.5.1 → 0.6.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/index.cjs CHANGED
@@ -164,6 +164,287 @@ var require_lodash = __commonJS({
164
164
  }
165
165
  });
166
166
 
167
+ // ../../node_modules/dayjs/dayjs.min.js
168
+ var require_dayjs_min = __commonJS({
169
+ "../../node_modules/dayjs/dayjs.min.js"(exports2, module2) {
170
+ "use strict";
171
+ !(function(t, e) {
172
+ "object" == typeof exports2 && "undefined" != typeof module2 ? module2.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e();
173
+ })(exports2, (function() {
174
+ "use strict";
175
+ var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
176
+ var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
177
+ return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
178
+ } }, m = function(t2, e2, n2) {
179
+ var r2 = String(t2);
180
+ return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
181
+ }, v = { s: m, z: function(t2) {
182
+ var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
183
+ return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
184
+ }, m: function t2(e2, n2) {
185
+ if (e2.date() < n2.date()) return -t2(n2, e2);
186
+ var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
187
+ return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
188
+ }, a: function(t2) {
189
+ return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
190
+ }, p: function(t2) {
191
+ return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
192
+ }, u: function(t2) {
193
+ return void 0 === t2;
194
+ } }, g = "en", D = {};
195
+ D[g] = M;
196
+ var p = "$isDayjsObject", S = function(t2) {
197
+ return t2 instanceof _ || !(!t2 || !t2[p]);
198
+ }, w = function t2(e2, n2, r2) {
199
+ var i2;
200
+ if (!e2) return g;
201
+ if ("string" == typeof e2) {
202
+ var s2 = e2.toLowerCase();
203
+ D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
204
+ var u2 = e2.split("-");
205
+ if (!i2 && u2.length > 1) return t2(u2[0]);
206
+ } else {
207
+ var a2 = e2.name;
208
+ D[a2] = e2, i2 = a2;
209
+ }
210
+ return !r2 && i2 && (g = i2), i2 || !r2 && g;
211
+ }, O = function(t2, e2) {
212
+ if (S(t2)) return t2.clone();
213
+ var n2 = "object" == typeof e2 ? e2 : {};
214
+ return n2.date = t2, n2.args = arguments, new _(n2);
215
+ }, b = v;
216
+ b.l = w, b.i = S, b.w = function(t2, e2) {
217
+ return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
218
+ };
219
+ var _ = (function() {
220
+ function M2(t2) {
221
+ this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
222
+ }
223
+ var m2 = M2.prototype;
224
+ return m2.parse = function(t2) {
225
+ this.$d = (function(t3) {
226
+ var e2 = t3.date, n2 = t3.utc;
227
+ if (null === e2) return /* @__PURE__ */ new Date(NaN);
228
+ if (b.u(e2)) return /* @__PURE__ */ new Date();
229
+ if (e2 instanceof Date) return new Date(e2);
230
+ if ("string" == typeof e2 && !/Z$/i.test(e2)) {
231
+ var r2 = e2.match($);
232
+ if (r2) {
233
+ var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
234
+ return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
235
+ }
236
+ }
237
+ return new Date(e2);
238
+ })(t2), this.init();
239
+ }, m2.init = function() {
240
+ var t2 = this.$d;
241
+ this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
242
+ }, m2.$utils = function() {
243
+ return b;
244
+ }, m2.isValid = function() {
245
+ return !(this.$d.toString() === l);
246
+ }, m2.isSame = function(t2, e2) {
247
+ var n2 = O(t2);
248
+ return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
249
+ }, m2.isAfter = function(t2, e2) {
250
+ return O(t2) < this.startOf(e2);
251
+ }, m2.isBefore = function(t2, e2) {
252
+ return this.endOf(e2) < O(t2);
253
+ }, m2.$g = function(t2, e2, n2) {
254
+ return b.u(t2) ? this[e2] : this.set(n2, t2);
255
+ }, m2.unix = function() {
256
+ return Math.floor(this.valueOf() / 1e3);
257
+ }, m2.valueOf = function() {
258
+ return this.$d.getTime();
259
+ }, m2.startOf = function(t2, e2) {
260
+ var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
261
+ var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
262
+ return r2 ? i2 : i2.endOf(a);
263
+ }, $2 = function(t3, e3) {
264
+ return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
265
+ }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
266
+ switch (f2) {
267
+ case h:
268
+ return r2 ? l2(1, 0) : l2(31, 11);
269
+ case c:
270
+ return r2 ? l2(1, M3) : l2(0, M3 + 1);
271
+ case o:
272
+ var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
273
+ return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
274
+ case a:
275
+ case d:
276
+ return $2(v2 + "Hours", 0);
277
+ case u:
278
+ return $2(v2 + "Minutes", 1);
279
+ case s:
280
+ return $2(v2 + "Seconds", 2);
281
+ case i:
282
+ return $2(v2 + "Milliseconds", 3);
283
+ default:
284
+ return this.clone();
285
+ }
286
+ }, m2.endOf = function(t2) {
287
+ return this.startOf(t2, false);
288
+ }, m2.$set = function(t2, e2) {
289
+ var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
290
+ if (o2 === c || o2 === h) {
291
+ var y2 = this.clone().set(d, 1);
292
+ y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
293
+ } else l2 && this.$d[l2]($2);
294
+ return this.init(), this;
295
+ }, m2.set = function(t2, e2) {
296
+ return this.clone().$set(t2, e2);
297
+ }, m2.get = function(t2) {
298
+ return this[b.p(t2)]();
299
+ }, m2.add = function(r2, f2) {
300
+ var d2, l2 = this;
301
+ r2 = Number(r2);
302
+ var $2 = b.p(f2), y2 = function(t2) {
303
+ var e2 = O(l2);
304
+ return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
305
+ };
306
+ if ($2 === c) return this.set(c, this.$M + r2);
307
+ if ($2 === h) return this.set(h, this.$y + r2);
308
+ if ($2 === a) return y2(1);
309
+ if ($2 === o) return y2(7);
310
+ var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
311
+ return b.w(m3, this);
312
+ }, m2.subtract = function(t2, e2) {
313
+ return this.add(-1 * t2, e2);
314
+ }, m2.format = function(t2) {
315
+ var e2 = this, n2 = this.$locale();
316
+ if (!this.isValid()) return n2.invalidDate || l;
317
+ var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
318
+ return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
319
+ }, d2 = function(t3) {
320
+ return b.s(s2 % 12 || 12, t3, "0");
321
+ }, $2 = f2 || function(t3, e3, n3) {
322
+ var r3 = t3 < 12 ? "AM" : "PM";
323
+ return n3 ? r3.toLowerCase() : r3;
324
+ };
325
+ return r2.replace(y, (function(t3, r3) {
326
+ return r3 || (function(t4) {
327
+ switch (t4) {
328
+ case "YY":
329
+ return String(e2.$y).slice(-2);
330
+ case "YYYY":
331
+ return b.s(e2.$y, 4, "0");
332
+ case "M":
333
+ return a2 + 1;
334
+ case "MM":
335
+ return b.s(a2 + 1, 2, "0");
336
+ case "MMM":
337
+ return h2(n2.monthsShort, a2, c2, 3);
338
+ case "MMMM":
339
+ return h2(c2, a2);
340
+ case "D":
341
+ return e2.$D;
342
+ case "DD":
343
+ return b.s(e2.$D, 2, "0");
344
+ case "d":
345
+ return String(e2.$W);
346
+ case "dd":
347
+ return h2(n2.weekdaysMin, e2.$W, o2, 2);
348
+ case "ddd":
349
+ return h2(n2.weekdaysShort, e2.$W, o2, 3);
350
+ case "dddd":
351
+ return o2[e2.$W];
352
+ case "H":
353
+ return String(s2);
354
+ case "HH":
355
+ return b.s(s2, 2, "0");
356
+ case "h":
357
+ return d2(1);
358
+ case "hh":
359
+ return d2(2);
360
+ case "a":
361
+ return $2(s2, u2, true);
362
+ case "A":
363
+ return $2(s2, u2, false);
364
+ case "m":
365
+ return String(u2);
366
+ case "mm":
367
+ return b.s(u2, 2, "0");
368
+ case "s":
369
+ return String(e2.$s);
370
+ case "ss":
371
+ return b.s(e2.$s, 2, "0");
372
+ case "SSS":
373
+ return b.s(e2.$ms, 3, "0");
374
+ case "Z":
375
+ return i2;
376
+ }
377
+ return null;
378
+ })(t3) || i2.replace(":", "");
379
+ }));
380
+ }, m2.utcOffset = function() {
381
+ return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
382
+ }, m2.diff = function(r2, d2, l2) {
383
+ var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
384
+ return b.m(y2, m3);
385
+ };
386
+ switch (M3) {
387
+ case h:
388
+ $2 = D2() / 12;
389
+ break;
390
+ case c:
391
+ $2 = D2();
392
+ break;
393
+ case f:
394
+ $2 = D2() / 3;
395
+ break;
396
+ case o:
397
+ $2 = (g2 - v2) / 6048e5;
398
+ break;
399
+ case a:
400
+ $2 = (g2 - v2) / 864e5;
401
+ break;
402
+ case u:
403
+ $2 = g2 / n;
404
+ break;
405
+ case s:
406
+ $2 = g2 / e;
407
+ break;
408
+ case i:
409
+ $2 = g2 / t;
410
+ break;
411
+ default:
412
+ $2 = g2;
413
+ }
414
+ return l2 ? $2 : b.a($2);
415
+ }, m2.daysInMonth = function() {
416
+ return this.endOf(c).$D;
417
+ }, m2.$locale = function() {
418
+ return D[this.$L];
419
+ }, m2.locale = function(t2, e2) {
420
+ if (!t2) return this.$L;
421
+ var n2 = this.clone(), r2 = w(t2, e2, true);
422
+ return r2 && (n2.$L = r2), n2;
423
+ }, m2.clone = function() {
424
+ return b.w(this.$d, this);
425
+ }, m2.toDate = function() {
426
+ return new Date(this.valueOf());
427
+ }, m2.toJSON = function() {
428
+ return this.isValid() ? this.toISOString() : null;
429
+ }, m2.toISOString = function() {
430
+ return this.$d.toISOString();
431
+ }, m2.toString = function() {
432
+ return this.$d.toUTCString();
433
+ }, M2;
434
+ })(), k = _.prototype;
435
+ return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach((function(t2) {
436
+ k[t2[1]] = function(e2) {
437
+ return this.$g(e2, t2[0], t2[1]);
438
+ };
439
+ })), O.extend = function(t2, e2) {
440
+ return t2.$i || (t2(e2, _, O), t2.$i = true), O;
441
+ }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
442
+ return O(1e3 * t2);
443
+ }, O.en = D[g], O.Ls = D, O.p = {}, O;
444
+ }));
445
+ }
446
+ });
447
+
167
448
  // src/index.ts
168
449
  var index_exports = {};
169
450
  __export(index_exports, {
@@ -172,6 +453,7 @@ __export(index_exports, {
172
453
  HardEligibilityContext: () => HardEligibilityContext,
173
454
  HardEligibilityProvider: () => HardEligibilityProvider,
174
455
  SoftEligibilityProvider: () => SoftEligibilityProvider,
456
+ isValidDatestamp: () => isValidDatestamp,
175
457
  useBridgeSdk: () => useBridgeSdk,
176
458
  useCreateHardEligibilitySession: () => useCreateHardEligibilitySession,
177
459
  useCreateSoftEligibilitySession: () => useCreateSoftEligibilitySession,
@@ -1888,6 +2170,18 @@ var import_zustand4 = require("zustand");
1888
2170
 
1889
2171
  // src/eligibility-input/eligibility-input-store.ts
1890
2172
  var import_zustand = require("zustand");
2173
+
2174
+ // src/lib/is-valid-datestamp.ts
2175
+ var import_dayjs = __toESM(require_dayjs_min(), 1);
2176
+ function isValidDatestamp(value) {
2177
+ if (!value) return false;
2178
+ if (typeof value !== "string") return false;
2179
+ const isValidFormat = /^\d{4}-\d{2}-\d{2}$/.test(value);
2180
+ if (!isValidFormat) return false;
2181
+ return (0, import_dayjs.default)(value).isValid();
2182
+ }
2183
+
2184
+ // src/eligibility-input/eligibility-input-store.ts
1891
2185
  function createEligibilityInputStore(requirePatient) {
1892
2186
  return (0, import_zustand.createStore)()((set) => ({
1893
2187
  requirePatient,
@@ -1909,7 +2203,12 @@ function createEligibilityInputStore(requirePatient) {
1909
2203
  },
1910
2204
  dateOfBirth: {
1911
2205
  value: null,
1912
- set: (dateOfBirth) => set((s) => ({ ...s, dateOfBirth: { ...s.dateOfBirth, value: dateOfBirth } }))
2206
+ set: (dateOfBirth) => {
2207
+ if (dateOfBirth && !isValidDatestamp(dateOfBirth)) {
2208
+ throw new Error('dateOfBirth must be a valid date, string value of "YYYY-MM-DD"');
2209
+ }
2210
+ set((s) => ({ ...s, dateOfBirth: { ...s.dateOfBirth, value: dateOfBirth } }));
2211
+ }
1913
2212
  },
1914
2213
  memberId: {
1915
2214
  value: "",
@@ -2036,7 +2335,7 @@ function useEligibilityInputField(field, defaultValue) {
2036
2335
  case "dateOfBirth":
2037
2336
  isVisible = requirePatient;
2038
2337
  isRequired = requirePatient;
2039
- isValid = Boolean(input.dateOfBirth.value);
2338
+ isValid = isValidDatestamp(input.dateOfBirth.value);
2040
2339
  break;
2041
2340
  case "memberId": {
2042
2341
  const memberIdIsRequired = Boolean(
@@ -2087,6 +2386,7 @@ function useEligibilityInputIsValid() {
2087
2386
  }
2088
2387
 
2089
2388
  // src/hard-eligibility/use-hard-eligibility-submit.ts
2389
+ var import_dayjs2 = __toESM(require_dayjs_min(), 1);
2090
2390
  function useHardEligibilitySubmit() {
2091
2391
  const session = useHardEligibilitySession();
2092
2392
  const { state, payer, firstName, lastName, dateOfBirth, memberId } = useEligibilityInput();
@@ -2109,7 +2409,7 @@ function useHardEligibilitySubmit() {
2109
2409
  payerId: payer.value.id,
2110
2410
  firstName: firstName.value.trim(),
2111
2411
  lastName: lastName.value.trim(),
2112
- dateOfBirth: (0, import_sdk_core9.dateToDateObject)(dateOfBirth.value),
2412
+ dateOfBirth: (0, import_sdk_core9.dateToDateObject)((0, import_dayjs2.default)(dateOfBirth.value).toDate()),
2113
2413
  memberId: memberId.value?.trim() || void 0
2114
2414
  };
2115
2415
  }
@@ -2245,6 +2545,7 @@ function useSoftEligibilitySubmit() {
2245
2545
  HardEligibilityContext,
2246
2546
  HardEligibilityProvider,
2247
2547
  SoftEligibilityProvider,
2548
+ isValidDatestamp,
2248
2549
  useBridgeSdk,
2249
2550
  useCreateHardEligibilitySession,
2250
2551
  useCreateSoftEligibilitySession,