@motor-hero/ui-kit 0.37.0 → 0.37.2
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/hooks/use-company-subdomain.d.ts +18 -1
- package/dist/hooks/use-company-subdomain.d.ts.map +1 -1
- package/dist/index.cjs +14 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/form-field.tsx +1 -1
- package/src/hooks/use-company-subdomain.ts +34 -5
package/dist/index.js
CHANGED
|
@@ -1490,7 +1490,7 @@ function FormField({ label, htmlFor, error, required, children, className }) {
|
|
|
1490
1490
|
"label",
|
|
1491
1491
|
{
|
|
1492
1492
|
htmlFor,
|
|
1493
|
-
className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
1493
|
+
className: "block text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
1494
1494
|
children: [
|
|
1495
1495
|
label,
|
|
1496
1496
|
required && /* @__PURE__ */ jsx16("span", { className: "ml-1 text-destructive", children: "*" })
|
|
@@ -2350,11 +2350,16 @@ function Toaster(props) {
|
|
|
2350
2350
|
|
|
2351
2351
|
// src/hooks/use-company-subdomain.ts
|
|
2352
2352
|
import { useState as useState12 } from "react";
|
|
2353
|
-
|
|
2353
|
+
var ALWAYS_RESERVED = ["www", "localhost"];
|
|
2354
|
+
function getSubdomain(hostname, reservedSubdomains = []) {
|
|
2354
2355
|
const labels = hostname.split(".");
|
|
2355
2356
|
if (labels.length < 2) return void 0;
|
|
2356
2357
|
const first = labels[0];
|
|
2357
|
-
if (!first
|
|
2358
|
+
if (!first) return void 0;
|
|
2359
|
+
const reserved = [...ALWAYS_RESERVED, ...reservedSubdomains].map(
|
|
2360
|
+
(label) => label.toLowerCase()
|
|
2361
|
+
);
|
|
2362
|
+
if (reserved.includes(first.toLowerCase())) return void 0;
|
|
2358
2363
|
return first;
|
|
2359
2364
|
}
|
|
2360
2365
|
function resolveOverride(storageKey) {
|
|
@@ -2372,14 +2377,18 @@ function resolveOverride(storageKey) {
|
|
|
2372
2377
|
return window.localStorage.getItem(storageKey) ?? void 0;
|
|
2373
2378
|
}
|
|
2374
2379
|
function useCompanySubdomain(opts = {}) {
|
|
2375
|
-
const {
|
|
2380
|
+
const {
|
|
2381
|
+
enableOverride = false,
|
|
2382
|
+
overrideStorageKey = "company-subdomain",
|
|
2383
|
+
reservedSubdomains = []
|
|
2384
|
+
} = opts;
|
|
2376
2385
|
const [subdomain] = useState12(() => {
|
|
2377
2386
|
if (enableOverride) {
|
|
2378
2387
|
const override = resolveOverride(overrideStorageKey);
|
|
2379
2388
|
if (override) return override;
|
|
2380
2389
|
}
|
|
2381
2390
|
if (typeof window === "undefined") return void 0;
|
|
2382
|
-
return getSubdomain(window.location.hostname);
|
|
2391
|
+
return getSubdomain(window.location.hostname, reservedSubdomains);
|
|
2383
2392
|
});
|
|
2384
2393
|
return { subdomain };
|
|
2385
2394
|
}
|