@ndlib/component-library 1.0.28 → 1.0.41

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/README.md CHANGED
@@ -78,6 +78,22 @@ Dependencies must be installed before storybook can be started. Dependencies can
78
78
 
79
79
  To build and deploy your storybook locally for development, run `yarn start`
80
80
 
81
+ ## Testing locally
82
+
83
+ If you wish to test your changes locally in another project that uses the component library, use the following steps:
84
+
85
+ 1. Run `yarn build`
86
+ 2. Enter `pwd` in the terminal to generate the path where the component library is located on your machine
87
+ 3. In the package.json of the project you wish to test the locally modified component library in, replace the version of the component library with `"file:///<PATH>"`
88
+ 4. Run `yarn install` or `npm run install`
89
+
90
+ If you need to make a change in the component library and test again:
91
+
92
+ 1. Rerun `yarn build` in the component library
93
+ 2. In your other project, change the package.json to use the version number again instead of the path
94
+ 3. Run `yarn install` or `npm run install` again
95
+ 4. Change the version back to the path, and run `yarn install` or `npm run install` again
96
+
81
97
  ## Deploying Storybook
82
98
 
83
99
  Whenever a commit is added to the main branch, the contents of the `/docs` folder will be deployed to our Github pages site.
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { ConsentBanner } from './consentBanner';
2
+ import { ConsentBanner } from '.';
3
3
  declare global {
4
4
  interface Window {
5
5
  clarity?: unknown;
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- import { ConsentBanner } from './consentBanner';
11
+ import { ConsentBanner } from '.';
12
12
  function clearConsent() {
13
13
  try {
14
14
  localStorage.removeItem('clarityConsent');
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { render, screen, waitFor } from '@testing-library/react';
12
12
  import userEvent from '@testing-library/user-event';
13
- import { ConsentBanner } from './consentBanner';
13
+ import { ConsentBanner } from '.';
14
14
  function cleanupClarityScripts() {
15
15
  document
16
16
  .querySelectorAll('script[src*="clarity.ms"]')
@@ -79,7 +79,7 @@ export const Heading = (_a) => {
79
79
  if (type !== GROUP_TYPE.REGION && !standalone) {
80
80
  flagInDevelopment('Heading component should be used within a Group component with property type={GROUP_TYPE.REGION} or given the standalone flag');
81
81
  }
82
- const headerProps = Object.assign({ id: id, role: 'heading', 'aria-level': level, sx: Object.assign(Object.assign({ py: 0, borderBottom: underline ? 'solid 2px' : undefined, borderBottomColor: underlineColor ? underlineColor : COLOR.SECONDARY, color: COLOR.PRIMARY, mt: topMargin }, getTypographyStyles(typography)), sx) }, rest);
82
+ const headerProps = Object.assign({ id: id, role: 'heading', 'aria-level': level, sx: Object.assign(Object.assign({ py: 0, borderBottom: underline ? 'solid 2px' : undefined, borderBottomColor: underlineColor ? underlineColor : COLOR.SECONDARY, color: (sx === null || sx === void 0 ? void 0 : sx.color) || COLOR.PRIMARY, mt: topMargin }, getTypographyStyles(typography)), sx) }, rest);
83
83
  switch (level) {
84
84
  case 1:
85
85
  return _jsx("h1", Object.assign({}, headerProps));
package/dist/index.d.ts CHANGED
@@ -35,6 +35,7 @@ export { Checkbox } from './components/elements/Checkbox';
35
35
  export { CheckboxV2 } from './components/elements/CheckboxV2';
36
36
  export { CheckboxGroup } from './components/elements/CheckboxGroup';
37
37
  export { CheckboxGroupV2 } from './components/elements/CheckboxGroupV2';
38
+ export { ConsentBanner } from './components/elements/ConsentBanner';
38
39
  export { Radio } from './components/elements/Radio';
39
40
  export { RadioGroup } from './components/elements/RadioGroup';
40
41
  export { List, ListItem, LIST_SIZE } from './components/elements/List';
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ export { Checkbox } from './components/elements/Checkbox';
34
34
  export { CheckboxV2 } from './components/elements/CheckboxV2';
35
35
  export { CheckboxGroup } from './components/elements/CheckboxGroup';
36
36
  export { CheckboxGroupV2 } from './components/elements/CheckboxGroupV2';
37
+ export { ConsentBanner } from './components/elements/ConsentBanner';
37
38
  export { Radio } from './components/elements/Radio';
38
39
  export { RadioGroup } from './components/elements/RadioGroup';
39
40
  export { List, ListItem, LIST_SIZE } from './components/elements/List';
@@ -4,6 +4,7 @@ export declare const DEFAULT_ALLOWED_ATTRIBUTES: {
4
4
  iframe: string[];
5
5
  img: string[];
6
6
  p: string[];
7
+ span: string[];
7
8
  figure: string[];
8
9
  a: sanitize.AllowedAttribute[];
9
10
  };
@@ -1,9 +1,14 @@
1
1
  import sanitize from 'sanitize-html';
2
+ const BRAND_COLORS = ['#000000', '#0c2340', '#1c4f8f', '#ae9142'].map((c) => c.toLowerCase());
3
+ const isAllowedColor = (styleString) => {
4
+ return BRAND_COLORS.some((color) => styleString.toLowerCase().includes(color));
5
+ };
2
6
  export const DEFAULT_ALLOWED_TAGS = sanitize.defaults.allowedTags.concat([
3
7
  'iframe',
4
8
  'img',
5
9
  'p',
6
10
  'figure',
11
+ 'span',
7
12
  ]);
8
13
  export const DEFAULT_ALLOWED_ATTRIBUTES = Object.assign(Object.assign({}, sanitize.defaults.allowedAttributes), { iframe: [
9
14
  'src',
@@ -13,7 +18,7 @@ export const DEFAULT_ALLOWED_ATTRIBUTES = Object.assign(Object.assign({}, saniti
13
18
  'allowfullscreen',
14
19
  'webkitallowfullscreen',
15
20
  'mozallowfullscreen',
16
- ], img: ['*'], p: ['*'], figure: ['class'], a: sanitize.defaults.allowedAttributes.a.concat([
21
+ ], img: ['*'], p: ['*'], span: ['style'], figure: ['class'], a: sanitize.defaults.allowedAttributes.a.concat([
17
22
  'id',
18
23
  'class',
19
24
  'data-card-width',
@@ -23,5 +28,24 @@ export const sanitizeHtml = (content) => {
23
28
  return sanitize(content, {
24
29
  allowedTags: DEFAULT_ALLOWED_TAGS,
25
30
  allowedAttributes: DEFAULT_ALLOWED_ATTRIBUTES,
31
+ transformTags: {
32
+ span: (_tagName, attribs) => {
33
+ const newAttributes = {};
34
+ if (attribs.style) {
35
+ const colorMatch = attribs.style.match(/color\s*:\s*([^;]+)/i);
36
+ if (colorMatch) {
37
+ const colorValue = colorMatch[0];
38
+ if (isAllowedColor(colorValue) &&
39
+ !colorValue.includes('transparent')) {
40
+ newAttributes.style = colorValue;
41
+ }
42
+ }
43
+ }
44
+ return {
45
+ tagName: 'span',
46
+ attribs: newAttributes,
47
+ };
48
+ },
49
+ },
26
50
  });
27
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/component-library",
3
- "version": "1.0.28",
3
+ "version": "1.0.41",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [
@@ -17,6 +17,11 @@
17
17
  "type": "git",
18
18
  "url": "https://github.com/ndlibrary/hesburgh-component-library.git"
19
19
  },
20
+ "publishConfig": {
21
+ "access": "public",
22
+ "registry": "https://registry.npmjs.org/",
23
+ "provenance": false
24
+ },
20
25
  "scripts": {
21
26
  "prepare": "husky install",
22
27
  "test-build": "echo '\n\nTesting Build...' && tsc --noEmit",