@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.
- package/dist/components/form-dialog.d.ts.map +1 -1
- package/dist/hooks/use-company-subdomain.d.ts +18 -1
- package/dist/hooks/use-company-subdomain.d.ts.map +1 -1
- package/dist/index.cjs +18 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/form-dialog.tsx +9 -1
- package/src/hooks/use-company-subdomain.ts +34 -5
|
@@ -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,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D;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
|
-
|
|
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;
|
|
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
|
-
|
|
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
|
|
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 {
|
|
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
|
}
|