@indico-data/design-system 1.0.55 → 1.0.56

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,3 @@
1
+ import { ListItem } from './types';
2
+ export declare const navigationItems: ListItem[];
3
+ export declare const footerItems: ListItem[];
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { PermafrostComponent } from '@/types';
3
+ type Props = PermafrostComponent & {
4
+ questionMark?: boolean;
5
+ for?: string | null;
6
+ place?: string;
7
+ clickToShow?: boolean;
8
+ delayShow?: number;
9
+ delayHide?: number;
10
+ questionMarkClassName?: string;
11
+ children: React.ReactNode;
12
+ block?: boolean;
13
+ };
14
+ export declare const Tooltip: (props: Props) => import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Tooltip } from './Tooltip';
3
+ declare const meta: Meta<typeof Tooltip>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Tooltip>;
6
+ export declare const Single: Story;
7
+ export declare const NoQuestionMark: Story;
8
+ export declare const Bottom: Story;
9
+ export declare const Right: Story;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const StyledTooltip: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
@@ -0,0 +1 @@
1
+ export { Tooltip } from './Tooltip';
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { PermafrostComponent } from '@/types';
3
+ type Props = PermafrostComponent & {
4
+ questionMark?: boolean;
5
+ for?: string | null;
6
+ place?: string;
7
+ clickToShow?: boolean;
8
+ delayShow?: number;
9
+ delayHide?: number;
10
+ questionMarkClassName?: string;
11
+ children: React.ReactNode;
12
+ block?: boolean;
13
+ };
14
+ export declare const Tooltip: (props: Props) => import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Tooltip } from './Tooltip';
3
+ declare const meta: Meta<typeof Tooltip>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Tooltip>;
6
+ export declare const Single: Story;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const StyledTooltip: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
@@ -0,0 +1 @@
1
+ export { Tooltip } from './Tooltip';
package/lib/index.d.ts CHANGED
@@ -301,12 +301,12 @@ declare const margin: {
301
301
  declare function decimalAdjust(type: any, value: any, exp: any): any;
302
302
  declare function round10(value: any, exp: any): any;
303
303
  declare function clamp(value: any, min: any, max: any): any;
304
- declare function numberWithCommas(x: any): any;
304
+ declare function numberWithCommas$1(x: any): any;
305
305
  declare namespace MATH {
306
306
  export { decimalAdjust };
307
307
  export { round10 };
308
308
  export { clamp };
309
- export { numberWithCommas };
309
+ export { numberWithCommas$1 as numberWithCommas };
310
310
  }
311
311
 
312
312
  declare const allColors: {
@@ -1125,4 +1125,90 @@ type Props = {
1125
1125
  } & PermafrostComponent;
1126
1126
  declare const Toggle: (props: Props) => react_jsx_runtime.JSX.Element;
1127
1127
 
1128
- export { animation as ANIMATION, Radio as AbstractRadio, RadioGroup as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button, allColors as COLORS, CirclePulse, CircleSpinner, ConfirmModal, DatePicker, Drawer, EditableInput, GlobalStyles, Icon, IconButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, PercentageRing, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RandomLoadingMessage, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Shrug, SingleCombobox, StyledWizard, typography as TYPOGRAPHY, TextInput, TextTruncate, Toggle, Wizard, WizardCard, WizardSection, WizardWithSidebar, faIcons, indicons };
1128
+ declare const mix: (color_1: string, color_2: string, weight: number) => string;
1129
+ declare const shade: (color: string, percentage: number) => string;
1130
+ declare const tint: (color: string, percentage: number) => string;
1131
+ /**
1132
+ * Converts hex color values to rgb or rgba values if a opacity is supplied
1133
+ * @param hex
1134
+ * @returns {*}
1135
+ */
1136
+ declare const hexToRgb: (hex: string, opacity?: number) => string | undefined;
1137
+ /**
1138
+ * Takes a 3- or 6-character hex color value, and returns an object containing
1139
+ * its equivalent HSL values.
1140
+ *
1141
+ * @see {@link https://css-tricks.com/converting-color-spaces-in-javascript/}
1142
+ * @see {@link https://gist.github.com/mjackson/5311256}
1143
+ */
1144
+ declare function hexToHsl(hexColor: string): {
1145
+ hue: number;
1146
+ saturation: number;
1147
+ lightness: number;
1148
+ };
1149
+
1150
+ declare const color_d_hexToHsl: typeof hexToHsl;
1151
+ declare const color_d_hexToRgb: typeof hexToRgb;
1152
+ declare const color_d_mix: typeof mix;
1153
+ declare const color_d_shade: typeof shade;
1154
+ declare const color_d_tint: typeof tint;
1155
+ declare namespace color_d {
1156
+ export { color_d_hexToHsl as hexToHsl, color_d_hexToRgb as hexToRgb, color_d_mix as mix, color_d_shade as shade, color_d_tint as tint };
1157
+ }
1158
+
1159
+ declare const camelCaseToUpperUnderscore: (string: string) => string;
1160
+ declare const camelCaseToSpaceUpper: (string: string) => string;
1161
+ declare const underscoreToCapitalize: (string: string) => string;
1162
+ declare const snakeCaseToCamelCase: (string: string) => string;
1163
+ declare function capitalize(string: string): string;
1164
+ declare function capitalizeFirstOnly(string: string): string;
1165
+ /**
1166
+ * Generates a random string of English alphabet characters. Defaults to a length of 8.
1167
+ */
1168
+ declare function createRandomString(length?: number): string;
1169
+ declare const maxLengthWithEllipse: (string: string, maxLength: number) => string;
1170
+ declare const maxLengthWithMiddleEllipsis: (string: string, maxLength: number) => string;
1171
+
1172
+ declare const string_d_camelCaseToSpaceUpper: typeof camelCaseToSpaceUpper;
1173
+ declare const string_d_camelCaseToUpperUnderscore: typeof camelCaseToUpperUnderscore;
1174
+ declare const string_d_capitalize: typeof capitalize;
1175
+ declare const string_d_capitalizeFirstOnly: typeof capitalizeFirstOnly;
1176
+ declare const string_d_createRandomString: typeof createRandomString;
1177
+ declare const string_d_maxLengthWithEllipse: typeof maxLengthWithEllipse;
1178
+ declare const string_d_maxLengthWithMiddleEllipsis: typeof maxLengthWithMiddleEllipsis;
1179
+ declare const string_d_snakeCaseToCamelCase: typeof snakeCaseToCamelCase;
1180
+ declare const string_d_underscoreToCapitalize: typeof underscoreToCapitalize;
1181
+ declare namespace string_d {
1182
+ export { string_d_camelCaseToSpaceUpper as camelCaseToSpaceUpper, string_d_camelCaseToUpperUnderscore as camelCaseToUpperUnderscore, string_d_capitalize as capitalize, string_d_capitalizeFirstOnly as capitalizeFirstOnly, string_d_createRandomString as createRandomString, string_d_maxLengthWithEllipse as maxLengthWithEllipse, string_d_maxLengthWithMiddleEllipsis as maxLengthWithMiddleEllipsis, string_d_snakeCaseToCamelCase as snakeCaseToCamelCase, string_d_underscoreToCapitalize as underscoreToCapitalize };
1183
+ }
1184
+
1185
+ /**
1186
+ * Takes a number and formats it nicely.
1187
+ *
1188
+ * @example numberWithCommas(12345)
1189
+ * // returns 12,345
1190
+ */
1191
+ declare function numberWithCommas(value: number): string;
1192
+ /**
1193
+ * Takes a number and returns it, rounded up to the maximum decimal places specified.
1194
+ *
1195
+ * @example maxDecimalPlaces(0.1694915254237288, 2)
1196
+ * // returns 0.17
1197
+ *
1198
+ * @example maxDecimalPlaces(0.1694915254237288, 3)
1199
+ * // returns 0.169
1200
+ *
1201
+ * @example maxDecimalPlaces(12.902, 2)
1202
+ * // returns 12.9
1203
+ */
1204
+ declare function maxDecimalPlaces(value: number, decimalPlaces: number): number;
1205
+ declare function formatConfidence(confidence: number): number;
1206
+
1207
+ declare const number_d_formatConfidence: typeof formatConfidence;
1208
+ declare const number_d_maxDecimalPlaces: typeof maxDecimalPlaces;
1209
+ declare const number_d_numberWithCommas: typeof numberWithCommas;
1210
+ declare namespace number_d {
1211
+ export { number_d_formatConfidence as formatConfidence, number_d_maxDecimalPlaces as maxDecimalPlaces, number_d_numberWithCommas as numberWithCommas };
1212
+ }
1213
+
1214
+ export { animation as ANIMATION, Radio as AbstractRadio, RadioGroup as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button, allColors as COLORS, CirclePulse, CircleSpinner, ConfirmModal, DatePicker, Drawer, EditableInput, GlobalStyles, Icon, IconButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, PercentageRing, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RandomLoadingMessage, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Shrug, SingleCombobox, StyledWizard, typography as TYPOGRAPHY, TextInput, TextTruncate, Toggle, Wizard, WizardCard, WizardSection, WizardWithSidebar, color_d as colorUtils, faIcons, indicons, number_d as numberUtils, string_d as stringUtils };
package/lib/index.esm.js CHANGED
@@ -2317,6 +2317,42 @@ const SingleCombobox = React__default.forwardRef((props, ref) => {
2317
2317
  return jsx(ComboboxComponent, {});
2318
2318
  });
2319
2319
 
2320
+ const mix = function (color_1, color_2, weight) {
2321
+ function d2h(d) {
2322
+ return d.toString(16);
2323
+ } // convert a decimal value to hex
2324
+ function h2d(h) {
2325
+ return parseInt(h, 16);
2326
+ } // convert a hex value to decimal
2327
+ function s2l(hex) {
2328
+ return `${hex}${hex}`;
2329
+ }
2330
+ weight = typeof weight !== 'undefined' ? weight : 50; // set the weight to 50%, if that argument is omitted
2331
+ color_1 = color_1.replace(/#/g, '');
2332
+ color_2 = color_2.replace(/#/g, '');
2333
+ // check if colors are shorthand or longhand - covert to longhand
2334
+ color_1 = color_1.length === 3 ? s2l(color_1) : color_1;
2335
+ color_2 = color_2.length === 3 ? s2l(color_2) : color_2;
2336
+ let color = '#';
2337
+ for (let i = 0; i <= 5; i += 2) {
2338
+ // loop through each of the 3 hex pairs—red, green, and blue
2339
+ const v1 = h2d(color_1.substr(i, 2)); // extract the current pairs
2340
+ const v2 = h2d(color_2.substr(i, 2));
2341
+ // combine the current pairs from each source color, according to the specified weight
2342
+ let val = d2h(Math.floor(v2 + (v1 - v2) * (weight / 100.0)));
2343
+ while (val.length < 2) {
2344
+ val = '0' + val;
2345
+ } // prepend a '0' if val results in a single digit
2346
+ color += val; // concatenate val to our new color string
2347
+ }
2348
+ return color; // PROFIT!
2349
+ };
2350
+ const shade = (color, percentage) => {
2351
+ return mix('#000000', color, percentage);
2352
+ };
2353
+ const tint = (color, percentage) => {
2354
+ return mix('#ffffff', color, percentage);
2355
+ };
2320
2356
  /**
2321
2357
  * Converts hex color values to rgb or rgba values if a opacity is supplied
2322
2358
  * @param hex
@@ -2337,7 +2373,120 @@ const hexToRgb = (hex, opacity) => {
2337
2373
  }
2338
2374
  return undefined;
2339
2375
  };
2376
+ /**
2377
+ * Takes a 3- or 6-character hex color value, and returns an object containing
2378
+ * its equivalent HSL values.
2379
+ *
2380
+ * @see {@link https://css-tricks.com/converting-color-spaces-in-javascript/}
2381
+ * @see {@link https://gist.github.com/mjackson/5311256}
2382
+ */
2383
+ function hexToHsl(hexColor) {
2384
+ // convert to 6-character hex string, if necessary
2385
+ const fullHexColor = (() => {
2386
+ if (hexColor.length === 4) {
2387
+ return ('#' +
2388
+ hexColor
2389
+ .replace('#', '')
2390
+ .split('')
2391
+ .reduce((acc, char) => (acc += char + char), ''));
2392
+ }
2393
+ return hexColor;
2394
+ })();
2395
+ const rgbValues = {
2396
+ red: parseInt(fullHexColor.slice(1, 3), 16) / 255,
2397
+ green: parseInt(fullHexColor.slice(3, 5), 16) / 255,
2398
+ blue: parseInt(fullHexColor.slice(-2), 16) / 255,
2399
+ };
2400
+ const allValues = Object.values(rgbValues);
2401
+ const channelMax = Math.max(...allValues);
2402
+ const channelMin = Math.min(...allValues);
2403
+ const channelDelta = channelMax - channelMin;
2404
+ const hslValues = {
2405
+ hue: 0,
2406
+ saturation: 0,
2407
+ lightness: (channelMax + channelMin) / 2,
2408
+ };
2409
+ if (channelDelta !== 0) {
2410
+ // calculate hue
2411
+ if (channelMax === rgbValues.red) {
2412
+ hslValues.hue = ((rgbValues.green - rgbValues.blue) / channelDelta) % 6;
2413
+ }
2414
+ else if (channelMax === rgbValues.green) {
2415
+ hslValues.hue = (rgbValues.blue - rgbValues.red) / channelDelta + 2;
2416
+ }
2417
+ else {
2418
+ hslValues.hue = (rgbValues.red - rgbValues.green) / channelDelta + 4;
2419
+ }
2420
+ // calculate saturation
2421
+ hslValues.saturation = channelDelta / (1 - Math.abs(2 * hslValues.lightness - 1));
2422
+ }
2423
+ hslValues.hue = Math.round(hslValues.hue * 60);
2424
+ hslValues.saturation = +(hslValues.saturation * 100).toFixed(0);
2425
+ hslValues.lightness = +(hslValues.lightness * 100).toFixed(0);
2426
+ // make negative hues positive
2427
+ if (hslValues.hue < 0) {
2428
+ hslValues.hue += 360;
2429
+ }
2430
+ return hslValues;
2431
+ }
2340
2432
 
2433
+ var color = /*#__PURE__*/Object.freeze({
2434
+ __proto__: null,
2435
+ hexToHsl: hexToHsl,
2436
+ hexToRgb: hexToRgb,
2437
+ mix: mix,
2438
+ shade: shade,
2439
+ tint: tint
2440
+ });
2441
+
2442
+ const camelCaseToUpperUnderscore = (string) => {
2443
+ return string
2444
+ .replace(/([A-Z])/g, function ($1) {
2445
+ return '_' + $1;
2446
+ })
2447
+ .toUpperCase();
2448
+ };
2449
+ const camelCaseToSpaceUpper = (string) => {
2450
+ return (string
2451
+ // insert a space before all caps
2452
+ .replace(/([A-Z])/g, ' $1')
2453
+ // uppercase the first character
2454
+ .replace(/^./, function (str) {
2455
+ return str.toUpperCase();
2456
+ }));
2457
+ };
2458
+ const underscoreToCapitalize = (string) => {
2459
+ return (string
2460
+ // replace all _ with spaces
2461
+ .replace(/_/g, ' ')
2462
+ // uppercase the first character
2463
+ .replace(/^./, function (str) {
2464
+ return str.toUpperCase();
2465
+ }));
2466
+ };
2467
+ const snakeCaseToCamelCase = (string) => {
2468
+ const parts = string.split('_').map((part, i) => {
2469
+ if (i > 0) {
2470
+ return part.replace(/^./, function (str) {
2471
+ return str.toUpperCase();
2472
+ });
2473
+ }
2474
+ else {
2475
+ return part;
2476
+ }
2477
+ });
2478
+ return parts.join().replace(/,/g, '');
2479
+ };
2480
+ function capitalize(string) {
2481
+ if (typeof string !== 'string')
2482
+ return '';
2483
+ return string.slice(0, 1).toUpperCase() + string.slice(1).toLowerCase();
2484
+ }
2485
+ function capitalizeFirstOnly(string) {
2486
+ if (typeof string !== 'string')
2487
+ return '';
2488
+ return string.slice(0, 1).toUpperCase() + string.slice(1);
2489
+ }
2341
2490
  /**
2342
2491
  * Generates a random string of English alphabet characters. Defaults to a length of 8.
2343
2492
  */
@@ -2349,6 +2498,33 @@ function createRandomString(length) {
2349
2498
  }
2350
2499
  return result;
2351
2500
  }
2501
+ const maxLengthWithEllipse = (string, maxLength) => {
2502
+ if (string.length <= maxLength) {
2503
+ return string;
2504
+ }
2505
+ else {
2506
+ return string.slice(0, maxLength - 2).concat('...');
2507
+ }
2508
+ };
2509
+ const maxLengthWithMiddleEllipsis = (string, maxLength) => {
2510
+ const frontSegment = string.slice(0, Math.floor(maxLength / 2) - 2);
2511
+ const endSegmentLength = string.length - (Math.floor(maxLength / 2) - 1);
2512
+ const endSegment = string.slice(endSegmentLength, string.length);
2513
+ return string.length <= maxLength ? string : `${frontSegment}...${endSegment}`;
2514
+ };
2515
+
2516
+ var string = /*#__PURE__*/Object.freeze({
2517
+ __proto__: null,
2518
+ camelCaseToSpaceUpper: camelCaseToSpaceUpper,
2519
+ camelCaseToUpperUnderscore: camelCaseToUpperUnderscore,
2520
+ capitalize: capitalize,
2521
+ capitalizeFirstOnly: capitalizeFirstOnly,
2522
+ createRandomString: createRandomString,
2523
+ maxLengthWithEllipse: maxLengthWithEllipse,
2524
+ maxLengthWithMiddleEllipsis: maxLengthWithMiddleEllipsis,
2525
+ snakeCaseToCamelCase: snakeCaseToCamelCase,
2526
+ underscoreToCapitalize: underscoreToCapitalize
2527
+ });
2352
2528
 
2353
2529
  /**
2354
2530
  * Takes a number and formats it nicely.
@@ -2359,6 +2535,31 @@ function createRandomString(length) {
2359
2535
  function numberWithCommas(value) {
2360
2536
  return new Intl.NumberFormat(navigator.language || 'en-US').format(value);
2361
2537
  }
2538
+ /**
2539
+ * Takes a number and returns it, rounded up to the maximum decimal places specified.
2540
+ *
2541
+ * @example maxDecimalPlaces(0.1694915254237288, 2)
2542
+ * // returns 0.17
2543
+ *
2544
+ * @example maxDecimalPlaces(0.1694915254237288, 3)
2545
+ * // returns 0.169
2546
+ *
2547
+ * @example maxDecimalPlaces(12.902, 2)
2548
+ * // returns 12.9
2549
+ */
2550
+ function maxDecimalPlaces(value, decimalPlaces) {
2551
+ return +value.toFixed(decimalPlaces);
2552
+ }
2553
+ function formatConfidence(confidence) {
2554
+ return Math.min(Math.floor(confidence * 100), 99);
2555
+ }
2556
+
2557
+ var number = /*#__PURE__*/Object.freeze({
2558
+ __proto__: null,
2559
+ formatConfidence: formatConfidence,
2560
+ maxDecimalPlaces: maxDecimalPlaces,
2561
+ numberWithCommas: numberWithCommas
2562
+ });
2362
2563
 
2363
2564
  const cardTableLoading = keyframes `
2364
2565
  25% {
@@ -25880,5 +26081,5 @@ const Toggle = (props) => {
25880
26081
  }), "data-cy": props['data-cy'], id: id, children: [jsx("input", { "aria-label": props['aria-label'], type: "checkbox", disabled: disabled, checked: value, onChange: onChange }), jsx("span", { className: "slider round" }), checkedIconName && (jsx(Icon, { name: checkedIconName, size: [iconSize || 5], className: "checked-icon" })), notCheckedIconName && (jsx(Icon, { name: notCheckedIconName, size: [iconSize || 5], className: "not-checked-icon" }))] }));
25881
26082
  };
25882
26083
 
25883
- export { animation as ANIMATION, Radio$1 as AbstractRadio, RadioGroup$1 as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button$1 as Button, allColors as COLORS, CirclePulse, CircleSpinner, ConfirmModal, DatePicker, Drawer, EditableInput, GlobalStyles, Icon, IconButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, PercentageRing, Radio, RadioGroup, RandomLoadingMessage, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Shrug, SingleCombobox, StyledWizard, typography as TYPOGRAPHY, TextInput, TextTruncate, Toggle, Wizard, WizardCard, WizardSection, WizardWithSidebar, faIcons, indicons };
26084
+ export { animation as ANIMATION, Radio$1 as AbstractRadio, RadioGroup$1 as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button$1 as Button, allColors as COLORS, CirclePulse, CircleSpinner, ConfirmModal, DatePicker, Drawer, EditableInput, GlobalStyles, Icon, IconButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, PercentageRing, Radio, RadioGroup, RandomLoadingMessage, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Shrug, SingleCombobox, StyledWizard, typography as TYPOGRAPHY, TextInput, TextTruncate, Toggle, Wizard, WizardCard, WizardSection, WizardWithSidebar, color as colorUtils, faIcons, indicons, number as numberUtils, string as stringUtils };
25884
26085
  //# sourceMappingURL=index.esm.js.map