@nswds/app 1.22.0 → 1.23.1
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 +57 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.js +57 -15
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -2446,6 +2446,7 @@ function SegmentedControlTrigger({
|
|
|
2446
2446
|
}
|
|
2447
2447
|
);
|
|
2448
2448
|
}
|
|
2449
|
+
var findGreyKey = (themes) => Object.keys(themes).find((k) => k.toLowerCase().includes("grey")) ?? "";
|
|
2449
2450
|
function ThemeSelector({
|
|
2450
2451
|
themeCategory,
|
|
2451
2452
|
setThemeCategory,
|
|
@@ -2453,12 +2454,18 @@ function ThemeSelector({
|
|
|
2453
2454
|
setPrimaryColor,
|
|
2454
2455
|
accentColor,
|
|
2455
2456
|
setAccentColor,
|
|
2457
|
+
greyColor,
|
|
2458
|
+
setGreyColor,
|
|
2456
2459
|
availableAccentColors,
|
|
2457
2460
|
colorThemes: colorThemes2
|
|
2458
2461
|
}) {
|
|
2459
2462
|
const handleCategoryChange = (newCategory) => {
|
|
2460
2463
|
setThemeCategory(newCategory);
|
|
2461
2464
|
const availableColors = Object.keys(colorThemes2[newCategory]);
|
|
2465
|
+
const neutral = findGreyKey(colorThemes2[newCategory]);
|
|
2466
|
+
if (neutral && neutral !== greyColor) {
|
|
2467
|
+
setGreyColor(neutral);
|
|
2468
|
+
}
|
|
2462
2469
|
if (availableColors.length > 0) {
|
|
2463
2470
|
if (availableColors.includes(primaryColor)) {
|
|
2464
2471
|
const newAccentColor = availableColors.find((color) => color !== primaryColor);
|
|
@@ -5954,6 +5961,7 @@ function CodeDemo({ data, hide = {} }) {
|
|
|
5954
5961
|
const [themeCategory, setThemeCategory] = React6.useState("brand");
|
|
5955
5962
|
const [primaryColor, setPrimaryColor] = React6.useState("blue");
|
|
5956
5963
|
const [accentColor, setAccentColor] = React6.useState("red");
|
|
5964
|
+
const [greyColor, setGreyColor] = React6.useState("grey");
|
|
5957
5965
|
React6.useEffect(() => {
|
|
5958
5966
|
setDarkMode(resolvedTheme === "dark");
|
|
5959
5967
|
}, [resolvedTheme]);
|
|
@@ -5966,9 +5974,10 @@ function CodeDemo({ data, hide = {} }) {
|
|
|
5966
5974
|
const themeValues = React6__namespace.default.useMemo(
|
|
5967
5975
|
() => ({
|
|
5968
5976
|
...getShades("primary", primaryColor, themeCategory),
|
|
5969
|
-
...getShades("accent", accentColor, themeCategory)
|
|
5977
|
+
...getShades("accent", accentColor, themeCategory),
|
|
5978
|
+
...getShades("grey", greyColor, themeCategory)
|
|
5970
5979
|
}),
|
|
5971
|
-
[themeCategory, primaryColor, accentColor]
|
|
5980
|
+
[themeCategory, primaryColor, accentColor, greyColor]
|
|
5972
5981
|
);
|
|
5973
5982
|
React6__namespace.default.useEffect(() => {
|
|
5974
5983
|
const frame = iframeRef.current;
|
|
@@ -6024,6 +6033,14 @@ function CodeDemo({ data, hide = {} }) {
|
|
|
6024
6033
|
function countLines(value) {
|
|
6025
6034
|
return (value.match(/\n/g) || "").length + 1;
|
|
6026
6035
|
}
|
|
6036
|
+
function selectIframe(data2, currentVariant) {
|
|
6037
|
+
const { iframe } = data2;
|
|
6038
|
+
if (!iframe) return;
|
|
6039
|
+
if (typeof iframe === "number") return iframe;
|
|
6040
|
+
if ("src" in iframe) return iframe;
|
|
6041
|
+
return iframe[currentVariant];
|
|
6042
|
+
}
|
|
6043
|
+
const iframeData = selectIframe(data, variant);
|
|
6027
6044
|
const variants = getVariants(data);
|
|
6028
6045
|
const code = getCode(data, variant);
|
|
6029
6046
|
const codeItems = getCodeItems(code);
|
|
@@ -6042,7 +6059,9 @@ function CodeDemo({ data, hide = {} }) {
|
|
|
6042
6059
|
primaryColor,
|
|
6043
6060
|
setPrimaryColor,
|
|
6044
6061
|
accentColor,
|
|
6045
|
-
setAccentColor
|
|
6062
|
+
setAccentColor,
|
|
6063
|
+
greyColor,
|
|
6064
|
+
setGreyColor
|
|
6046
6065
|
}
|
|
6047
6066
|
),
|
|
6048
6067
|
!rtl && /* @__PURE__ */ jsxRuntime.jsx(ToggleRTLButton, { isRTL, onClick: () => setIsRTL((state) => !state) }),
|
|
@@ -6061,14 +6080,14 @@ function CodeDemo({ data, hide = {} }) {
|
|
|
6061
6080
|
view,
|
|
6062
6081
|
isRTL,
|
|
6063
6082
|
isDarkMode,
|
|
6064
|
-
iframe:
|
|
6083
|
+
iframe: iframeData,
|
|
6065
6084
|
themeValues,
|
|
6066
|
-
children:
|
|
6085
|
+
children: iframeData ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6067
6086
|
IFrame,
|
|
6068
6087
|
{
|
|
6069
6088
|
sandbox: "allow-scripts allow-same-origin",
|
|
6070
6089
|
ref: iframeRef,
|
|
6071
|
-
|
|
6090
|
+
iframe: iframeData,
|
|
6072
6091
|
isRTL,
|
|
6073
6092
|
isDarkMode
|
|
6074
6093
|
}
|
|
@@ -6118,7 +6137,7 @@ function CodeDemo({ data, hide = {} }) {
|
|
|
6118
6137
|
] });
|
|
6119
6138
|
}
|
|
6120
6139
|
var IFrame = React6__namespace.default.forwardRef(
|
|
6121
|
-
({
|
|
6140
|
+
({ iframe, isRTL, isDarkMode }, ref) => {
|
|
6122
6141
|
React6.useEffect(() => {
|
|
6123
6142
|
const document2 = ref?.current?.contentDocument;
|
|
6124
6143
|
const root = document2?.documentElement;
|
|
@@ -6127,11 +6146,11 @@ var IFrame = React6__namespace.default.forwardRef(
|
|
|
6127
6146
|
root.classList.toggle("dark", !!isDarkMode);
|
|
6128
6147
|
}
|
|
6129
6148
|
}, [isRTL, isDarkMode, ref]);
|
|
6130
|
-
if (typeof
|
|
6131
|
-
return /* @__PURE__ */ jsxRuntime.jsx("iframe", { ref, src: "", height:
|
|
6149
|
+
if (typeof iframe === "number") {
|
|
6150
|
+
return /* @__PURE__ */ jsxRuntime.jsx("iframe", { ref, src: "", height: iframe, width: "100%", className: "w-full" });
|
|
6132
6151
|
}
|
|
6133
|
-
if (typeof
|
|
6134
|
-
const { src, height = 0, width = 100, noPadding } =
|
|
6152
|
+
if (typeof iframe === "object" && iframe?.src) {
|
|
6153
|
+
const { src, height = 0, width = 100, noPadding } = iframe;
|
|
6135
6154
|
const finalSrc = noPadding ? `${src}?noPadding` : src;
|
|
6136
6155
|
const finalWidth = width === 100 ? "100%" : width;
|
|
6137
6156
|
return /* @__PURE__ */ jsxRuntime.jsx("iframe", { ref, src: finalSrc, height, width: finalWidth, className: "w-full" });
|
|
@@ -6236,7 +6255,9 @@ function ThemeSelectorDropDown({
|
|
|
6236
6255
|
primaryColor,
|
|
6237
6256
|
setPrimaryColor,
|
|
6238
6257
|
accentColor,
|
|
6239
|
-
setAccentColor
|
|
6258
|
+
setAccentColor,
|
|
6259
|
+
greyColor,
|
|
6260
|
+
setGreyColor
|
|
6240
6261
|
}) {
|
|
6241
6262
|
const filteredColorThemes = React6.useMemo(() => {
|
|
6242
6263
|
const filtered = {};
|
|
@@ -6254,6 +6275,10 @@ function ThemeSelectorDropDown({
|
|
|
6254
6275
|
return allColors.filter((color) => color !== primaryColor);
|
|
6255
6276
|
}, [filteredColorThemes, themeCategory, primaryColor]);
|
|
6256
6277
|
React6.useEffect(() => {
|
|
6278
|
+
const neutralKey = Object.keys(colorThemes[themeCategory]).find((k) => k.toLowerCase().includes("grey")) ?? "";
|
|
6279
|
+
if (neutralKey && neutralKey !== greyColor) {
|
|
6280
|
+
setGreyColor(neutralKey);
|
|
6281
|
+
}
|
|
6257
6282
|
const availableColors = Object.keys(colorThemes[themeCategory]);
|
|
6258
6283
|
if (!availableColors.includes(primaryColor)) {
|
|
6259
6284
|
setPrimaryColor(availableColors[0]);
|
|
@@ -6268,7 +6293,15 @@ function ThemeSelectorDropDown({
|
|
|
6268
6293
|
setAccentColor(newAccentColor);
|
|
6269
6294
|
}
|
|
6270
6295
|
}
|
|
6271
|
-
}, [
|
|
6296
|
+
}, [
|
|
6297
|
+
themeCategory,
|
|
6298
|
+
primaryColor,
|
|
6299
|
+
accentColor,
|
|
6300
|
+
greyColor,
|
|
6301
|
+
setPrimaryColor,
|
|
6302
|
+
setAccentColor,
|
|
6303
|
+
setGreyColor
|
|
6304
|
+
]);
|
|
6272
6305
|
const primaryColorSwatch = colorThemes[themeCategory][primaryColor]?.colors[3]?.hex || "#000000";
|
|
6273
6306
|
const accentColorSwatch = colorThemes[themeCategory][accentColor]?.colors[2]?.hex || "#000000";
|
|
6274
6307
|
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
|
|
@@ -6289,6 +6322,8 @@ function ThemeSelectorDropDown({
|
|
|
6289
6322
|
setPrimaryColor,
|
|
6290
6323
|
accentColor,
|
|
6291
6324
|
setAccentColor,
|
|
6325
|
+
greyColor,
|
|
6326
|
+
setGreyColor,
|
|
6292
6327
|
availableAccentColors,
|
|
6293
6328
|
colorThemes: filteredColorThemes
|
|
6294
6329
|
}
|
|
@@ -7337,7 +7372,7 @@ function Heading({
|
|
|
7337
7372
|
|
|
7338
7373
|
// package.json
|
|
7339
7374
|
var package_default = {
|
|
7340
|
-
version: "1.
|
|
7375
|
+
version: "1.22.0"};
|
|
7341
7376
|
function Logo(props) {
|
|
7342
7377
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7343
7378
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "NSW Government" }),
|
|
@@ -8807,6 +8842,7 @@ function ThemeColorPalette() {
|
|
|
8807
8842
|
const [themeCategory, setThemeCategory] = React6.useState("brand");
|
|
8808
8843
|
const [primaryColor, setPrimaryColor] = React6.useState("blue");
|
|
8809
8844
|
const [accentColor, setAccentColor] = React6.useState("red");
|
|
8845
|
+
const [greyColor, setGreyColor] = React6.useState("grey");
|
|
8810
8846
|
const [sheetOpen, setSheetOpen] = React6.useState(false);
|
|
8811
8847
|
const filteredColorThemes = React6.useMemo(() => {
|
|
8812
8848
|
const filtered = {};
|
|
@@ -8824,6 +8860,10 @@ function ThemeColorPalette() {
|
|
|
8824
8860
|
return allColors.filter((color) => color !== primaryColor);
|
|
8825
8861
|
}, [filteredColorThemes, themeCategory, primaryColor]);
|
|
8826
8862
|
React6.useEffect(() => {
|
|
8863
|
+
const neutralKey = Object.keys(colorThemes[themeCategory]).find((k) => k.toLowerCase().includes("grey")) ?? "";
|
|
8864
|
+
if (neutralKey && neutralKey !== greyColor) {
|
|
8865
|
+
setGreyColor(neutralKey);
|
|
8866
|
+
}
|
|
8827
8867
|
const availableColors = Object.keys(colorThemes[themeCategory]);
|
|
8828
8868
|
if (!availableColors.includes(primaryColor)) {
|
|
8829
8869
|
setPrimaryColor(availableColors[0]);
|
|
@@ -8838,7 +8878,7 @@ function ThemeColorPalette() {
|
|
|
8838
8878
|
setAccentColor(newAccentColor);
|
|
8839
8879
|
}
|
|
8840
8880
|
}
|
|
8841
|
-
}, [themeCategory, primaryColor, accentColor]);
|
|
8881
|
+
}, [themeCategory, primaryColor, accentColor, greyColor]);
|
|
8842
8882
|
const currentColorPalette = React6.useMemo(() => {
|
|
8843
8883
|
if (!colorThemes[themeCategory] || !colorThemes[themeCategory][primaryColor] || !colorThemes[themeCategory][accentColor]) {
|
|
8844
8884
|
return [
|
|
@@ -8911,6 +8951,8 @@ function ThemeColorPalette() {
|
|
|
8911
8951
|
setPrimaryColor,
|
|
8912
8952
|
accentColor,
|
|
8913
8953
|
setAccentColor,
|
|
8954
|
+
greyColor,
|
|
8955
|
+
setGreyColor,
|
|
8914
8956
|
availableAccentColors,
|
|
8915
8957
|
colorThemes: filteredColorThemes
|
|
8916
8958
|
}
|