@motor-hero/ui-kit 0.37.1 → 0.37.3

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 +1 @@
1
- {"version":3,"file":"form-dialog.d.ts","sourceRoot":"","sources":["../../src/components/form-dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAc,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAErF,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,KAAK,IAAI,CAAA;IACtC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,WAAsB,EACtB,WAAwB,EACxB,QAAQ,EACR,YAAoB,EACpB,UAAkB,GACnB,EAAE,qBAAqB,qBAyBvB;AAED,MAAM,MAAM,cAAc,GAAG,cAAc,CAAA;AAE3C,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,eAAe,EAAE,gBAAgB,CAAC;IAC9E,yEAAyE;IACzE,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAA;CACzD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,eAAe,qBAehE"}
1
+ {"version":3,"file":"form-dialog.d.ts","sourceRoot":"","sources":["../../src/components/form-dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAc,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAErF,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,KAAK,IAAI,CAAA;IACtC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,WAAsB,EACtB,WAAwB,EACxB,QAAQ,EACR,YAAoB,EACpB,UAAkB,GACnB,EAAE,qBAAqB,qBAyBvB;AAED,MAAM,MAAM,cAAc,GAAG,cAAc,CAAA;AAE3C,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,eAAe,EAAE,gBAAgB,CAAC;IAC9E,yEAAyE;IACzE,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAA;CACzD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,eAAe,qBAuBhE"}
@@ -1,10 +1,27 @@
1
1
  export type UseCompanySubdomainOptions = {
2
2
  enableOverride?: boolean;
3
3
  overrideStorageKey?: string;
4
+ /**
5
+ * Host labels that are *not* tenants. A product whose default host carries
6
+ * a label of its own (`app.example.com`, `admin.example.com`) must list it
7
+ * here, or that label is read as a tenant slug and sent downstream as one.
8
+ *
9
+ * Added to the built-in `www`; `localhost` is always excluded structurally.
10
+ * Case-insensitive.
11
+ */
12
+ reservedSubdomains?: string[];
4
13
  };
5
14
  export type UseCompanySubdomainResult = {
6
15
  subdomain: string | undefined;
7
16
  };
8
- export declare function getSubdomain(hostname: string): string | undefined;
17
+ /**
18
+ * The tenant slug in a hostname, or `undefined` when there is none.
19
+ *
20
+ * The first label is only a tenant if it isn't reserved. Callers whose
21
+ * default host is `app.<domain>` must pass `["app"]` (plus any sibling
22
+ * surfaces like `admin`), otherwise visiting the default host yields the
23
+ * literal `"app"` as if it were a customer.
24
+ */
25
+ export declare function getSubdomain(hostname: string, reservedSubdomains?: string[]): string | undefined;
9
26
  export declare function useCompanySubdomain(opts?: UseCompanySubdomainOptions): UseCompanySubdomainResult;
10
27
  //# sourceMappingURL=use-company-subdomain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-company-subdomain.d.ts","sourceRoot":"","sources":["../../src/hooks/use-company-subdomain.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,0BAA0B,GAAG;IACvC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,CAAA;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMjE;AAiBD,wBAAgB,mBAAmB,CACjC,IAAI,GAAE,0BAA+B,GACpC,yBAAyB,CAc3B"}
1
+ {"version":3,"file":"use-company-subdomain.d.ts","sourceRoot":"","sources":["../../src/hooks/use-company-subdomain.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,0BAA0B,GAAG;IACvC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,CAAA;AAID;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,kBAAkB,GAAE,MAAM,EAAO,GAChC,MAAM,GAAG,SAAS,CAUpB;AAiBD,wBAAgB,mBAAmB,CACjC,IAAI,GAAE,0BAA+B,GACpC,yBAAyB,CAiB3B"}
package/dist/index.cjs CHANGED
@@ -1541,11 +1541,15 @@ function FormDialogLayout({
1541
1541
  ] });
1542
1542
  }
1543
1543
  function FormDialog({ onSubmit, ...rest }) {
1544
+ const handleSubmit = (e) => {
1545
+ e.stopPropagation();
1546
+ onSubmit?.(e);
1547
+ };
1544
1548
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1545
1549
  BaseDialog,
1546
1550
  {
1547
1551
  ...rest,
1548
- contentWrapper: onSubmit ? (content) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("form", { onSubmit, className: "flex min-h-0 flex-1 flex-col", children: content }) : void 0
1552
+ contentWrapper: onSubmit ? (content) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("form", { onSubmit: handleSubmit, className: "flex min-h-0 flex-1 flex-col", children: content }) : void 0
1549
1553
  }
1550
1554
  );
1551
1555
  }
@@ -2427,11 +2431,16 @@ function Toaster(props) {
2427
2431
 
2428
2432
  // src/hooks/use-company-subdomain.ts
2429
2433
  var import_react8 = require("react");
2430
- function getSubdomain(hostname) {
2434
+ var ALWAYS_RESERVED = ["www", "localhost"];
2435
+ function getSubdomain(hostname, reservedSubdomains = []) {
2431
2436
  const labels = hostname.split(".");
2432
2437
  if (labels.length < 2) return void 0;
2433
2438
  const first = labels[0];
2434
- if (!first || first === "www" || first === "localhost") return void 0;
2439
+ if (!first) return void 0;
2440
+ const reserved = [...ALWAYS_RESERVED, ...reservedSubdomains].map(
2441
+ (label) => label.toLowerCase()
2442
+ );
2443
+ if (reserved.includes(first.toLowerCase())) return void 0;
2435
2444
  return first;
2436
2445
  }
2437
2446
  function resolveOverride(storageKey) {
@@ -2449,14 +2458,18 @@ function resolveOverride(storageKey) {
2449
2458
  return window.localStorage.getItem(storageKey) ?? void 0;
2450
2459
  }
2451
2460
  function useCompanySubdomain(opts = {}) {
2452
- const { enableOverride = false, overrideStorageKey = "company-subdomain" } = opts;
2461
+ const {
2462
+ enableOverride = false,
2463
+ overrideStorageKey = "company-subdomain",
2464
+ reservedSubdomains = []
2465
+ } = opts;
2453
2466
  const [subdomain] = (0, import_react8.useState)(() => {
2454
2467
  if (enableOverride) {
2455
2468
  const override = resolveOverride(overrideStorageKey);
2456
2469
  if (override) return override;
2457
2470
  }
2458
2471
  if (typeof window === "undefined") return void 0;
2459
- return getSubdomain(window.location.hostname);
2472
+ return getSubdomain(window.location.hostname, reservedSubdomains);
2460
2473
  });
2461
2474
  return { subdomain };
2462
2475
  }