@stoplight/elements-core 7.6.4 → 7.6.5

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.
@@ -0,0 +1,6 @@
1
+ declare type ChosenServerUrl = {
2
+ leading: string;
3
+ trailing: string | null;
4
+ };
5
+ export declare function useChosenServerUrl(chosenServerUrl: string): ChosenServerUrl;
6
+ export {};
package/index.esm.js CHANGED
@@ -410,6 +410,21 @@ function createNamedContext(name, defaultValue) {
410
410
  return context;
411
411
  }
412
412
 
413
+ const ALPHANUMERIC = /[^A-Za-z0-9]+$/;
414
+ function useChosenServerUrl(chosenServerUrl) {
415
+ const match = ALPHANUMERIC.exec(chosenServerUrl);
416
+ if (match === null) {
417
+ return {
418
+ leading: chosenServerUrl,
419
+ trailing: null,
420
+ };
421
+ }
422
+ return {
423
+ leading: chosenServerUrl.substring(0, match.index),
424
+ trailing: chosenServerUrl.substring(match.index),
425
+ };
426
+ }
427
+
413
428
  const chosenServerAtom = atom(undefined);
414
429
 
415
430
  function isValidServer(server) {
@@ -2217,9 +2232,12 @@ function MethodPath({ method, path }) {
2217
2232
  function MethodPathInner({ method, path, chosenServerUrl }) {
2218
2233
  const isDark = useThemeIsDark();
2219
2234
  const fullUrl = `${chosenServerUrl}${path}`;
2220
- const pathElem = (React.createElement(Flex, { overflowX: "hidden" },
2221
- chosenServerUrl ? (React.createElement(Box, { dir: "rtl", color: "muted", fontSize: "lg", textOverflow: "truncate", overflowX: "hidden" }, chosenServerUrl)) : null,
2222
- React.createElement(Box, { fontSize: "lg", fontWeight: "semibold", flex: 1 }, path)));
2235
+ const { leading, trailing } = useChosenServerUrl(chosenServerUrl);
2236
+ const pathElem = (React.createElement(Flex, { overflowX: "hidden", fontSize: "lg", userSelect: "all" },
2237
+ React.createElement(Box, { dir: "rtl", color: "muted", textOverflow: "truncate", overflowX: "hidden" },
2238
+ leading,
2239
+ trailing !== null && (React.createElement(Box, { as: "span", dir: "ltr", style: { unicodeBidi: 'bidi-override' } }, trailing))),
2240
+ React.createElement(Box, { fontWeight: "semibold", flex: 1 }, path)));
2223
2241
  return (React.createElement(HStack, { spacing: 3, pl: 2.5, pr: 4, py: 2, bg: "canvas-50", rounded: "lg", fontFamily: "mono", display: "inline-flex", maxW: "full", title: fullUrl },
2224
2242
  React.createElement(Box, { py: 1, px: 2.5, rounded: "lg", bg: !isDark ? HttpMethodColors[method] : 'canvas-100', color: !isDark ? 'on-primary' : 'body', fontSize: "lg", fontWeight: "semibold", textTransform: "uppercase" }, method),
2225
2243
  pathElem));
package/index.js CHANGED
@@ -464,6 +464,21 @@ function createNamedContext(name, defaultValue) {
464
464
  return context;
465
465
  }
466
466
 
467
+ const ALPHANUMERIC = /[^A-Za-z0-9]+$/;
468
+ function useChosenServerUrl(chosenServerUrl) {
469
+ const match = ALPHANUMERIC.exec(chosenServerUrl);
470
+ if (match === null) {
471
+ return {
472
+ leading: chosenServerUrl,
473
+ trailing: null,
474
+ };
475
+ }
476
+ return {
477
+ leading: chosenServerUrl.substring(0, match.index),
478
+ trailing: chosenServerUrl.substring(match.index),
479
+ };
480
+ }
481
+
467
482
  const chosenServerAtom = jotai.atom(undefined);
468
483
 
469
484
  function isValidServer(server) {
@@ -2271,9 +2286,12 @@ function MethodPath({ method, path }) {
2271
2286
  function MethodPathInner({ method, path, chosenServerUrl }) {
2272
2287
  const isDark = mosaic.useThemeIsDark();
2273
2288
  const fullUrl = `${chosenServerUrl}${path}`;
2274
- const pathElem = (React__namespace.createElement(mosaic.Flex, { overflowX: "hidden" },
2275
- chosenServerUrl ? (React__namespace.createElement(mosaic.Box, { dir: "rtl", color: "muted", fontSize: "lg", textOverflow: "truncate", overflowX: "hidden" }, chosenServerUrl)) : null,
2276
- React__namespace.createElement(mosaic.Box, { fontSize: "lg", fontWeight: "semibold", flex: 1 }, path)));
2289
+ const { leading, trailing } = useChosenServerUrl(chosenServerUrl);
2290
+ const pathElem = (React__namespace.createElement(mosaic.Flex, { overflowX: "hidden", fontSize: "lg", userSelect: "all" },
2291
+ React__namespace.createElement(mosaic.Box, { dir: "rtl", color: "muted", textOverflow: "truncate", overflowX: "hidden" },
2292
+ leading,
2293
+ trailing !== null && (React__namespace.createElement(mosaic.Box, { as: "span", dir: "ltr", style: { unicodeBidi: 'bidi-override' } }, trailing))),
2294
+ React__namespace.createElement(mosaic.Box, { fontWeight: "semibold", flex: 1 }, path)));
2277
2295
  return (React__namespace.createElement(mosaic.HStack, { spacing: 3, pl: 2.5, pr: 4, py: 2, bg: "canvas-50", rounded: "lg", fontFamily: "mono", display: "inline-flex", maxW: "full", title: fullUrl },
2278
2296
  React__namespace.createElement(mosaic.Box, { py: 1, px: 2.5, rounded: "lg", bg: !isDark ? HttpMethodColors[method] : 'canvas-100', color: !isDark ? 'on-primary' : 'body', fontSize: "lg", fontWeight: "semibold", textTransform: "uppercase" }, method),
2279
2297
  pathElem));
package/index.mjs CHANGED
@@ -410,6 +410,21 @@ function createNamedContext(name, defaultValue) {
410
410
  return context;
411
411
  }
412
412
 
413
+ const ALPHANUMERIC = /[^A-Za-z0-9]+$/;
414
+ function useChosenServerUrl(chosenServerUrl) {
415
+ const match = ALPHANUMERIC.exec(chosenServerUrl);
416
+ if (match === null) {
417
+ return {
418
+ leading: chosenServerUrl,
419
+ trailing: null,
420
+ };
421
+ }
422
+ return {
423
+ leading: chosenServerUrl.substring(0, match.index),
424
+ trailing: chosenServerUrl.substring(match.index),
425
+ };
426
+ }
427
+
413
428
  const chosenServerAtom = atom(undefined);
414
429
 
415
430
  function isValidServer(server) {
@@ -2217,9 +2232,12 @@ function MethodPath({ method, path }) {
2217
2232
  function MethodPathInner({ method, path, chosenServerUrl }) {
2218
2233
  const isDark = useThemeIsDark();
2219
2234
  const fullUrl = `${chosenServerUrl}${path}`;
2220
- const pathElem = (React.createElement(Flex, { overflowX: "hidden" },
2221
- chosenServerUrl ? (React.createElement(Box, { dir: "rtl", color: "muted", fontSize: "lg", textOverflow: "truncate", overflowX: "hidden" }, chosenServerUrl)) : null,
2222
- React.createElement(Box, { fontSize: "lg", fontWeight: "semibold", flex: 1 }, path)));
2235
+ const { leading, trailing } = useChosenServerUrl(chosenServerUrl);
2236
+ const pathElem = (React.createElement(Flex, { overflowX: "hidden", fontSize: "lg", userSelect: "all" },
2237
+ React.createElement(Box, { dir: "rtl", color: "muted", textOverflow: "truncate", overflowX: "hidden" },
2238
+ leading,
2239
+ trailing !== null && (React.createElement(Box, { as: "span", dir: "ltr", style: { unicodeBidi: 'bidi-override' } }, trailing))),
2240
+ React.createElement(Box, { fontWeight: "semibold", flex: 1 }, path)));
2223
2241
  return (React.createElement(HStack, { spacing: 3, pl: 2.5, pr: 4, py: 2, bg: "canvas-50", rounded: "lg", fontFamily: "mono", display: "inline-flex", maxW: "full", title: fullUrl },
2224
2242
  React.createElement(Box, { py: 1, px: 2.5, rounded: "lg", bg: !isDark ? HttpMethodColors[method] : 'canvas-100', color: !isDark ? 'on-primary' : 'body', fontSize: "lg", fontWeight: "semibold", textTransform: "uppercase" }, method),
2225
2243
  pathElem));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "7.6.4",
3
+ "version": "7.6.5",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",
@@ -37,7 +37,7 @@
37
37
  "@stoplight/types": "^13.0.0",
38
38
  "@stoplight/yaml": "^4.2.3",
39
39
  "classnames": "^2.2.6",
40
- "httpsnippet": "^1.24.0",
40
+ "httpsnippet": "^2.0.0",
41
41
  "jotai": "1.3.9",
42
42
  "json-schema": "^0.4.0",
43
43
  "lodash": "^4.17.19",