@telus-uds/components-web 1.2.0 → 1.4.0
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/CHANGELOG.md +34 -2
- package/lib/Breadcrumbs/Breadcrumbs.js +247 -0
- package/lib/Breadcrumbs/Item/Item.js +165 -0
- package/lib/Breadcrumbs/index.js +15 -0
- package/lib/Callout/Callout.js +121 -0
- package/lib/Callout/index.js +13 -0
- package/lib/DatePicker/CalendarContainer.js +221 -0
- package/lib/DatePicker/DatePicker.js +329 -0
- package/lib/DatePicker/dictionary.js +134 -0
- package/lib/DatePicker/index.js +13 -0
- package/lib/DatePicker/reactDatesCss.js +12 -0
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +75 -0
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +95 -0
- package/lib/ExpandCollapseMini/index.js +13 -0
- package/lib/Footnote/Footnote.js +571 -0
- package/lib/Footnote/FootnoteLink.js +149 -0
- package/lib/Footnote/dictionary.js +19 -0
- package/lib/Footnote/index.js +16 -0
- package/lib/OrderedList/Item.js +162 -0
- package/lib/OrderedList/ItemBase.js +42 -0
- package/lib/OrderedList/OrderedList.js +94 -0
- package/lib/OrderedList/OrderedListBase.js +68 -0
- package/lib/OrderedList/constants.js +9 -0
- package/lib/OrderedList/index.js +16 -0
- package/lib/PreviewCard/AuthorDate.js +64 -0
- package/lib/PreviewCard/PreviewCard.js +236 -0
- package/lib/PreviewCard/index.js +13 -0
- package/lib/PriceLockup/PriceLockup.js +237 -0
- package/lib/PriceLockup/index.js +13 -0
- package/lib/PriceLockup/tokens.js +131 -0
- package/lib/ResponsiveImage/ResponsiveImage.js +115 -0
- package/lib/ResponsiveImage/index.js +13 -0
- package/lib/Ribbon/Ribbon.js +0 -1
- package/lib/Span/Span.js +88 -0
- package/lib/Span/index.js +13 -0
- package/lib/index.js +91 -1
- package/lib/shared/FullBleedContent/FullBleedContent.js +121 -0
- package/lib/shared/FullBleedContent/getFullBleedBorderRadius.js +73 -0
- package/lib/shared/FullBleedContent/index.js +29 -0
- package/lib/shared/FullBleedContent/useFullBleedContentProps.js +73 -0
- package/lib/utils/index.js +32 -0
- package/lib/utils/logger.js +31 -0
- package/lib/utils/media.js +54 -0
- package/lib/utils/renderStructuredContent.js +89 -0
- package/lib/utils/useTypographyTheme.js +32 -0
- package/lib-module/Breadcrumbs/Breadcrumbs.js +228 -0
- package/lib-module/Breadcrumbs/Item/Item.js +141 -0
- package/lib-module/Breadcrumbs/index.js +1 -0
- package/lib-module/Callout/Callout.js +106 -0
- package/lib-module/Callout/index.js +2 -0
- package/lib-module/DatePicker/CalendarContainer.js +208 -0
- package/lib-module/DatePicker/DatePicker.js +302 -0
- package/lib-module/DatePicker/dictionary.js +127 -0
- package/lib-module/DatePicker/index.js +2 -0
- package/lib-module/DatePicker/reactDatesCss.js +3 -0
- package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +56 -0
- package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +80 -0
- package/lib-module/ExpandCollapseMini/index.js +2 -0
- package/lib-module/Footnote/Footnote.js +541 -0
- package/lib-module/Footnote/FootnoteLink.js +130 -0
- package/lib-module/Footnote/dictionary.js +12 -0
- package/lib-module/Footnote/index.js +4 -0
- package/lib-module/OrderedList/Item.js +139 -0
- package/lib-module/OrderedList/ItemBase.js +28 -0
- package/lib-module/OrderedList/OrderedList.js +71 -0
- package/lib-module/OrderedList/OrderedListBase.js +48 -0
- package/lib-module/OrderedList/constants.js +2 -0
- package/lib-module/OrderedList/index.js +4 -0
- package/lib-module/PreviewCard/AuthorDate.js +53 -0
- package/lib-module/PreviewCard/PreviewCard.js +211 -0
- package/lib-module/PreviewCard/index.js +2 -0
- package/lib-module/PriceLockup/PriceLockup.js +213 -0
- package/lib-module/PriceLockup/index.js +2 -0
- package/lib-module/PriceLockup/tokens.js +120 -0
- package/lib-module/ResponsiveImage/ResponsiveImage.js +100 -0
- package/lib-module/ResponsiveImage/index.js +2 -0
- package/lib-module/Ribbon/Ribbon.js +1 -2
- package/lib-module/Span/Span.js +70 -0
- package/lib-module/Span/index.js +2 -0
- package/lib-module/index.js +10 -0
- package/lib-module/shared/FullBleedContent/FullBleedContent.js +106 -0
- package/lib-module/shared/FullBleedContent/getFullBleedBorderRadius.js +65 -0
- package/lib-module/shared/FullBleedContent/index.js +4 -0
- package/lib-module/shared/FullBleedContent/useFullBleedContentProps.js +65 -0
- package/lib-module/utils/index.js +5 -1
- package/lib-module/utils/logger.js +18 -0
- package/lib-module/utils/media.js +46 -0
- package/lib-module/utils/renderStructuredContent.js +77 -0
- package/lib-module/utils/useTypographyTheme.js +24 -0
- package/package.json +9 -4
- package/src/Breadcrumbs/Breadcrumbs.jsx +222 -0
- package/src/Breadcrumbs/Item/Item.jsx +127 -0
- package/src/Breadcrumbs/index.js +1 -0
- package/src/Callout/Callout.jsx +76 -0
- package/src/Callout/index.js +3 -0
- package/src/DatePicker/CalendarContainer.jsx +210 -0
- package/src/DatePicker/DatePicker.jsx +303 -0
- package/src/DatePicker/dictionary.js +92 -0
- package/src/DatePicker/index.js +3 -0
- package/src/DatePicker/reactDatesCss.js +892 -0
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +48 -0
- package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +67 -0
- package/src/ExpandCollapseMini/index.js +3 -0
- package/src/Footnote/Footnote.jsx +468 -0
- package/src/Footnote/FootnoteLink.jsx +120 -0
- package/src/Footnote/dictionary.js +12 -0
- package/src/Footnote/index.js +6 -0
- package/src/OrderedList/Item.jsx +121 -0
- package/src/OrderedList/ItemBase.jsx +18 -0
- package/src/OrderedList/OrderedList.jsx +61 -0
- package/src/OrderedList/OrderedListBase.jsx +38 -0
- package/src/OrderedList/constants.js +2 -0
- package/src/OrderedList/index.js +6 -0
- package/src/PreviewCard/AuthorDate.jsx +31 -0
- package/src/PreviewCard/PreviewCard.jsx +201 -0
- package/src/PreviewCard/index.js +3 -0
- package/src/PriceLockup/PriceLockup.jsx +210 -0
- package/src/PriceLockup/index.js +3 -0
- package/src/PriceLockup/tokens.js +58 -0
- package/src/ResponsiveImage/ResponsiveImage.jsx +77 -0
- package/src/ResponsiveImage/index.js +3 -0
- package/src/Ribbon/Ribbon.jsx +0 -1
- package/src/Span/Span.jsx +66 -0
- package/src/Span/index.js +3 -0
- package/src/index.js +10 -0
- package/src/shared/FullBleedContent/FullBleedContent.jsx +90 -0
- package/src/shared/FullBleedContent/getFullBleedBorderRadius.js +55 -0
- package/src/shared/FullBleedContent/index.js +6 -0
- package/src/shared/FullBleedContent/useFullBleedContentProps.js +63 -0
- package/src/utils/index.js +5 -1
- package/src/utils/logger.js +20 -0
- package/src/utils/media.js +40 -0
- package/src/utils/renderStructuredContent.jsx +73 -0
- package/src/utils/useTypographyTheme.js +14 -0
- package/types/Callout.d.ts +13 -0
- package/types/DatePicker.d.ts +21 -0
- package/types/Footnote.d.ts +21 -0
- package/types/FootnoteLink.d.ts +20 -0
- package/types/PriceLockup.d.ts +22 -0
- package/types/common.d.ts +14 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const deprecate = (componentName, message) => {
|
|
2
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3
|
+
return
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
console.warn(`[Allium] [Deprecate] ${componentName}: ${message}`) // eslint-disable-line no-console
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const warn = (componentName, message) => {
|
|
10
|
+
if (process.env.NODE_ENV === 'production') {
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
console.warn(`[Allium] ${componentName}: ${message}`) // eslint-disable-line no-console
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
deprecate,
|
|
19
|
+
warn
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { viewports } from '@telus-uds/system-constants'
|
|
2
|
+
|
|
3
|
+
export default function media() {
|
|
4
|
+
return {
|
|
5
|
+
query: {},
|
|
6
|
+
from(breakpoint) {
|
|
7
|
+
if (breakpoint !== viewports.xs) {
|
|
8
|
+
this.query.minWidth = breakpoint
|
|
9
|
+
}
|
|
10
|
+
return this
|
|
11
|
+
},
|
|
12
|
+
until(breakpoint) {
|
|
13
|
+
this.query.maxWidth = breakpoint
|
|
14
|
+
return this
|
|
15
|
+
},
|
|
16
|
+
and(custom) {
|
|
17
|
+
this.query.and = custom
|
|
18
|
+
return this
|
|
19
|
+
},
|
|
20
|
+
css(style) {
|
|
21
|
+
const { minWidth, maxWidth, and } = this.query
|
|
22
|
+
|
|
23
|
+
const min = minWidth ? `(min-width: ${viewports.map.get(minWidth)}px)` : undefined
|
|
24
|
+
const max = maxWidth ? `(max-width: ${viewports.map.get(maxWidth) - 1}px)` : undefined
|
|
25
|
+
|
|
26
|
+
if (typeof min !== 'undefined' || typeof max !== 'undefined' || typeof and !== 'undefined') {
|
|
27
|
+
const mediaQuery = `@media ${[min, max, and].filter((a) => a).join(' and ')}`
|
|
28
|
+
this.query = {}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
[mediaQuery]: {
|
|
32
|
+
...(typeof style === 'function' ? style() : style)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return typeof style === 'function' ? style() : style
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Link } from '@telus-uds/components-base'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Takes a string content and marks up all the links in it by wrapping them
|
|
6
|
+
* in `Link` component.
|
|
7
|
+
*/
|
|
8
|
+
const generateLinks = (content) => {
|
|
9
|
+
const linkRegex = /<\s*a([^>]*)>(.*?)<\s*\/\s*a>/g
|
|
10
|
+
const attributeRegex = /(\w+)\s*=\s*((["'])(.*?)\3|(?=\s|\/>))/g
|
|
11
|
+
|
|
12
|
+
const parts = content.split(linkRegex)
|
|
13
|
+
if (parts.length === 1) {
|
|
14
|
+
return parts
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Start with first anchor text, attributes will be in the previous part
|
|
18
|
+
for (let i = 2; i < parts.length; i += 3) {
|
|
19
|
+
const o = {}
|
|
20
|
+
// Get attributes from previous part
|
|
21
|
+
const attributes = parts[i - 1].trim()
|
|
22
|
+
|
|
23
|
+
// Create object from attributes
|
|
24
|
+
const matchedAttributes = attributes.match(attributeRegex)
|
|
25
|
+
if (matchedAttributes) {
|
|
26
|
+
matchedAttributes.forEach((attribute) => {
|
|
27
|
+
const split = attribute.split('=')
|
|
28
|
+
o[split[0]] = split[1].substr(1, split[1].length - 2)
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
// Remove anchor attributes from parts
|
|
32
|
+
parts[i - 1] = undefined
|
|
33
|
+
// Replace anchor text with Link in parts
|
|
34
|
+
parts[i] = (
|
|
35
|
+
<Link {...o} key={i}>
|
|
36
|
+
{parts[i]}
|
|
37
|
+
</Link>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return parts
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Takes an array of strings and in each element replaces the breaks with `<br>` tags.
|
|
46
|
+
*/
|
|
47
|
+
const generateBreaks = (parts) => {
|
|
48
|
+
const breakRegex = /<br\s?\/*>/g
|
|
49
|
+
|
|
50
|
+
const partsWithBreaks = parts
|
|
51
|
+
|
|
52
|
+
for (let i = 0; i < partsWithBreaks.length; i += 1) {
|
|
53
|
+
if (typeof partsWithBreaks[i] === 'string' && partsWithBreaks[i].search(breakRegex) !== -1) {
|
|
54
|
+
const toSplit = partsWithBreaks[i].split(breakRegex)
|
|
55
|
+
for (let x = 1; x < toSplit.length; x += 2) {
|
|
56
|
+
toSplit.splice(x, 0, <br key={`break-${i}-${x}`} />)
|
|
57
|
+
}
|
|
58
|
+
partsWithBreaks[i] = toSplit
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return partsWithBreaks
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const renderStructuredContent = (content) => {
|
|
66
|
+
if (typeof content !== 'string') {
|
|
67
|
+
return content
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return generateBreaks(generateLinks(content))
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default renderStructuredContent
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { applyTextStyles, useTheme, useThemeTokens, useViewport } from '@telus-uds/components-base'
|
|
2
|
+
|
|
3
|
+
const useTypographyTheme = (variant, tokens) => {
|
|
4
|
+
const viewport = useViewport()
|
|
5
|
+
const themeTokens = useThemeTokens('Typography', tokens, variant, { viewport })
|
|
6
|
+
const { themeOptions } = useTheme()
|
|
7
|
+
const { fontSize, lineHeight, ...rnStyles } = applyTextStyles({
|
|
8
|
+
...themeTokens,
|
|
9
|
+
themeOptions
|
|
10
|
+
})
|
|
11
|
+
return { ...rnStyles, fontSize: `${fontSize}px`, lineHeight: `${lineHeight}px` }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default useTypographyTheme
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentType, ElementType, ReactNode } from 'react'
|
|
2
|
+
import type { HTMLAttrs, Variant } from './common'
|
|
3
|
+
|
|
4
|
+
export interface CalloutProps extends HTMLAttrs {
|
|
5
|
+
children: ReactNode
|
|
6
|
+
variant?: Variant
|
|
7
|
+
icon?: ElementType
|
|
8
|
+
verticalAlign?: 'top' | 'middle' | 'bottom'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare const Callout: ComponentType<CalloutProps>
|
|
12
|
+
|
|
13
|
+
export default Callout
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentType } from 'react'
|
|
2
|
+
import type { HTMLAttrs } from './common'
|
|
3
|
+
|
|
4
|
+
export interface DatePickerProps extends HTMLAttrs {
|
|
5
|
+
id: string
|
|
6
|
+
copy?: 'en' | 'fr'
|
|
7
|
+
date?: any
|
|
8
|
+
feedback?: string
|
|
9
|
+
onDateChange?: (date: any) => void
|
|
10
|
+
isDayDisabled?: (date: any) => boolean
|
|
11
|
+
label?: string
|
|
12
|
+
inline?: boolean
|
|
13
|
+
hint?: string
|
|
14
|
+
hintPosition?: 'inline' | 'below'
|
|
15
|
+
tooltip?: string
|
|
16
|
+
validation?: 'error' | 'success'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare const DatePicker: ComponentType<DatePickerProps>
|
|
20
|
+
|
|
21
|
+
export default DatePicker
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react'
|
|
2
|
+
import type { HTMLAttrs, Variant } from './common'
|
|
3
|
+
|
|
4
|
+
type copyShape = {
|
|
5
|
+
close: string
|
|
6
|
+
heading: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface FootnoteProps extends HTMLAttrs {
|
|
10
|
+
children: ReactNode
|
|
11
|
+
variant?: Variant
|
|
12
|
+
copy?: 'en' | 'fr' | copyShape
|
|
13
|
+
content?: string
|
|
14
|
+
isOpen?: boolean
|
|
15
|
+
number?: number
|
|
16
|
+
onClose: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare const Footnote: ComponentType<FootnoteProps>
|
|
20
|
+
|
|
21
|
+
export default Footnote
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react'
|
|
2
|
+
import type { HTMLAttrs, Variant } from './common'
|
|
3
|
+
|
|
4
|
+
type copyShape = {
|
|
5
|
+
close: string
|
|
6
|
+
heading: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface FootnoteLinkProps extends HTMLAttrs {
|
|
10
|
+
children: ReactNode
|
|
11
|
+
number: number | string | [number] | [string]
|
|
12
|
+
variant?: Variant
|
|
13
|
+
copy?: 'en' | 'fr' | copyShape
|
|
14
|
+
fontSize?: number | string
|
|
15
|
+
onClick: MouseEvent
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare const FootnoteLink: ComponentType<FootnoteLinkProps>
|
|
19
|
+
|
|
20
|
+
export default FootnoteLink
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react'
|
|
2
|
+
import type { HTMLAttrs, Variant } from './common'
|
|
3
|
+
|
|
4
|
+
export interface PriceLockupProps extends HTMLAttrs {
|
|
5
|
+
children: ReactNode
|
|
6
|
+
variant?: Variant
|
|
7
|
+
size?: 'small' | 'medium' | 'large'
|
|
8
|
+
signDirection?: 'left' | 'right'
|
|
9
|
+
footnoteLinks?: [number] | [string]
|
|
10
|
+
topText?: string
|
|
11
|
+
price: number
|
|
12
|
+
currencySymbol?: string
|
|
13
|
+
rateText?: string
|
|
14
|
+
bottomText?: string
|
|
15
|
+
onClickFootnote?: MouseEvent
|
|
16
|
+
strikeThrough?: boolean
|
|
17
|
+
a11yText?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare const PriceLockup: ComponentType<PriceLockupProps>
|
|
21
|
+
|
|
22
|
+
export default PriceLockup
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AriaRole, AriaAttributes } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface HTMLAttrs extends AriaAttributes {
|
|
4
|
+
dataSet?: Record<string, any>
|
|
5
|
+
id?: string
|
|
6
|
+
loading?: 'eager' | 'lazy'
|
|
7
|
+
role?: AriaRole
|
|
8
|
+
src?: string
|
|
9
|
+
tabIndex?: string | number
|
|
10
|
+
testID?: string
|
|
11
|
+
title?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type Variant = Record<string, string | number | boolean>
|