@spfx-fast/sharepoint-ui 0.4.2 → 0.5.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/QUICKSTART.md +18 -0
- package/README.md +19 -24
- package/components.json +240 -5694
- package/dist/accordion.d.ts +11 -0
- package/dist/accordion.js +4 -0
- package/dist/alert.d.ts +3 -0
- package/dist/alert.js +4 -0
- package/dist/attachment-list.d.ts +15 -0
- package/dist/attachment-list.js +14 -0
- package/dist/avatar-group.d.ts +12 -0
- package/dist/avatar-group.js +7 -0
- package/dist/avatar.d.ts +6 -0
- package/dist/avatar.js +5 -0
- package/dist/badge.d.ts +3 -0
- package/dist/badge.js +4 -0
- package/dist/breadcrumb.d.ts +10 -0
- package/dist/breadcrumb.js +9 -0
- package/dist/button-group.d.ts +6 -0
- package/dist/button-group.js +4 -0
- package/dist/button.d.ts +3 -0
- package/dist/button.js +4 -0
- package/dist/card.d.ts +3 -0
- package/dist/card.js +4 -0
- package/dist/carousel.d.ts +11 -0
- package/dist/carousel.js +6 -0
- package/dist/checkbox.d.ts +3 -0
- package/dist/checkbox.js +4 -0
- package/dist/combobox.d.ts +9 -0
- package/dist/combobox.js +6 -0
- package/dist/command-bar.d.ts +6 -0
- package/dist/command-bar.js +4 -0
- package/dist/copy-button.d.ts +7 -0
- package/dist/copy-button.js +19 -0
- package/dist/data-grid.d.ts +25 -0
- package/dist/data-grid.js +39 -0
- package/dist/date-range-picker.d.ts +12 -0
- package/dist/date-range-picker.js +4 -0
- package/dist/dialog.d.ts +9 -0
- package/dist/dialog.js +21 -0
- package/dist/divider.d.ts +3 -0
- package/dist/divider.js +4 -0
- package/dist/drawer.d.ts +6 -0
- package/dist/drawer.js +5 -0
- package/dist/empty-state.d.ts +7 -0
- package/dist/empty-state.js +5 -0
- package/dist/field.d.ts +15 -0
- package/dist/field.js +11 -0
- package/dist/file-dropzone.d.ts +15 -0
- package/dist/file-dropzone.js +21 -0
- package/dist/filter-bar.d.ts +9 -0
- package/dist/filter-bar.js +9 -0
- package/dist/image.d.ts +5 -0
- package/dist/image.js +4 -0
- package/dist/index.d.ts +68 -76
- package/dist/index.js +60 -66
- package/dist/input.d.ts +3 -0
- package/dist/input.js +4 -0
- package/dist/label.d.ts +3 -0
- package/dist/label.js +4 -0
- package/dist/link.d.ts +3 -0
- package/dist/link.js +9 -0
- package/dist/list-view.d.ts +29 -0
- package/dist/list-view.js +14 -0
- package/dist/list.d.ts +6 -0
- package/dist/list.js +5 -0
- package/dist/lookup-picker.d.ts +12 -0
- package/dist/lookup-picker.js +4 -0
- package/dist/menu.d.ts +6 -0
- package/dist/menu.js +4 -0
- package/dist/nav.d.ts +12 -0
- package/dist/nav.js +4 -0
- package/dist/pagination.d.ts +11 -0
- package/dist/pagination.js +5 -0
- package/dist/person-picker.d.ts +13 -0
- package/dist/person-picker.js +4 -0
- package/dist/persona.d.ts +7 -0
- package/dist/persona.js +5 -0
- package/dist/popover.d.ts +6 -0
- package/dist/popover.js +4 -0
- package/dist/progress-bar.d.ts +5 -0
- package/dist/progress-bar.js +5 -0
- package/dist/radio-group.d.ts +6 -0
- package/dist/radio-group.js +4 -0
- package/dist/radio.d.ts +3 -0
- package/dist/radio.js +4 -0
- package/dist/rating.d.ts +8 -0
- package/dist/rating.js +5 -0
- package/dist/react.d.ts +1 -4583
- package/dist/react.js +1 -6837
- package/dist/select.d.ts +3 -0
- package/dist/select.js +4 -0
- package/dist/sharepoint-field.d.ts +18 -0
- package/dist/sharepoint-field.js +54 -0
- package/dist/skeleton.d.ts +6 -0
- package/dist/skeleton.js +9 -0
- package/dist/spinner.d.ts +5 -0
- package/dist/spinner.js +4 -0
- package/dist/swatch-picker.d.ts +17 -0
- package/dist/swatch-picker.js +11 -0
- package/dist/switch.d.ts +3 -0
- package/dist/switch.js +4 -0
- package/dist/table.d.ts +6 -0
- package/dist/table.js +4 -0
- package/dist/tabs.d.ts +14 -0
- package/dist/tabs.js +30 -0
- package/dist/tag-group.d.ts +6 -0
- package/dist/tag-group.js +4 -0
- package/dist/tag-picker.d.ts +12 -0
- package/dist/tag-picker.js +4 -0
- package/dist/tag.d.ts +7 -0
- package/dist/tag.js +5 -0
- package/dist/text.d.ts +5 -0
- package/dist/text.js +4 -0
- package/dist/textarea.d.ts +3 -0
- package/dist/textarea.js +4 -0
- package/dist/theme.d.ts +15 -167
- package/dist/theme.js +36 -162
- package/dist/toast.d.ts +9 -0
- package/dist/toast.js +12 -0
- package/dist/tree.d.ts +13 -0
- package/dist/tree.js +9 -0
- package/dist/view-card.d.ts +8 -0
- package/dist/view-card.js +4 -0
- package/dist/view-switcher.d.ts +13 -0
- package/dist/view-switcher.js +7 -0
- package/dist/virtual-list.d.ts +11 -0
- package/dist/virtual-list.js +25 -0
- package/measurements.json +365 -0
- package/package.json +19 -42
- package/src/theme.css +125 -0
- package/AGENTS.md +0 -211
- package/dist/appearance.d.ts +0 -6
- package/dist/appearance.js +0 -217
- package/dist/elements/accordion.d.ts +0 -9
- package/dist/elements/accordion.js +0 -338
- package/dist/elements/alert.d.ts +0 -2
- package/dist/elements/alert.js +0 -62
- package/dist/elements/avatar-group-primitives.d.ts +0 -3
- package/dist/elements/avatar-group-primitives.js +0 -189
- package/dist/elements/avatar-group.d.ts +0 -2
- package/dist/elements/avatar-group.js +0 -110
- package/dist/elements/avatar.d.ts +0 -4
- package/dist/elements/avatar.js +0 -251
- package/dist/elements/badge.d.ts +0 -8
- package/dist/elements/badge.js +0 -182
- package/dist/elements/breadcrumb.d.ts +0 -4
- package/dist/elements/breadcrumb.js +0 -233
- package/dist/elements/button-group.d.ts +0 -1
- package/dist/elements/button-group.js +0 -20
- package/dist/elements/button-variants.d.ts +0 -6
- package/dist/elements/button-variants.js +0 -339
- package/dist/elements/button.d.ts +0 -5
- package/dist/elements/button.js +0 -233
- package/dist/elements/card-primitives.d.ts +0 -3
- package/dist/elements/card-primitives.js +0 -83
- package/dist/elements/card.d.ts +0 -5
- package/dist/elements/card.js +0 -213
- package/dist/elements/carousel.d.ts +0 -92
- package/dist/elements/carousel.js +0 -1112
- package/dist/elements/color-picker.d.ts +0 -24
- package/dist/elements/color-picker.js +0 -1004
- package/dist/elements/combobox.d.ts +0 -1
- package/dist/elements/combobox.js +0 -1012
- package/dist/elements/data-grid-model.d.ts +0 -117
- package/dist/elements/data-grid-model.js +0 -294
- package/dist/elements/data-grid.d.ts +0 -29
- package/dist/elements/data-grid.js +0 -1567
- package/dist/elements/date-picker.d.ts +0 -1
- package/dist/elements/date-picker.js +0 -486
- package/dist/elements/dialog.d.ts +0 -23
- package/dist/elements/dialog.js +0 -409
- package/dist/elements/divider.d.ts +0 -2
- package/dist/elements/divider.js +0 -66
- package/dist/elements/drawer.d.ts +0 -3
- package/dist/elements/drawer.js +0 -308
- package/dist/elements/field-composition.d.ts +0 -26
- package/dist/elements/field-composition.js +0 -133
- package/dist/elements/field.d.ts +0 -1
- package/dist/elements/field.js +0 -67
- package/dist/elements/file-upload.d.ts +0 -6
- package/dist/elements/file-upload.js +0 -211
- package/dist/elements/floating-position.d.ts +0 -26
- package/dist/elements/floating-position.js +0 -39
- package/dist/elements/image.d.ts +0 -28
- package/dist/elements/image.js +0 -38
- package/dist/elements/info.d.ts +0 -9
- package/dist/elements/info.js +0 -102
- package/dist/elements/input.d.ts +0 -5
- package/dist/elements/input.js +0 -255
- package/dist/elements/label.d.ts +0 -15
- package/dist/elements/label.js +0 -56
- package/dist/elements/link.d.ts +0 -1
- package/dist/elements/link.js +0 -92
- package/dist/elements/list.d.ts +0 -19
- package/dist/elements/list.js +0 -297
- package/dist/elements/menu.d.ts +0 -33
- package/dist/elements/menu.js +0 -1103
- package/dist/elements/message-bar.d.ts +0 -10
- package/dist/elements/message-bar.js +0 -299
- package/dist/elements/nav.d.ts +0 -32
- package/dist/elements/nav.js +0 -791
- package/dist/elements/overflow.d.ts +0 -9
- package/dist/elements/overflow.js +0 -218
- package/dist/elements/persona.d.ts +0 -3
- package/dist/elements/persona.js +0 -125
- package/dist/elements/popover.d.ts +0 -77
- package/dist/elements/popover.js +0 -840
- package/dist/elements/progress-bar.d.ts +0 -4
- package/dist/elements/progress-bar.js +0 -82
- package/dist/elements/radio-group.d.ts +0 -1
- package/dist/elements/radio-group.js +0 -303
- package/dist/elements/rating-display.d.ts +0 -2
- package/dist/elements/rating-display.js +0 -125
- package/dist/elements/rating.d.ts +0 -2
- package/dist/elements/rating.js +0 -206
- package/dist/elements/rich-text-editor.d.ts +0 -18
- package/dist/elements/rich-text-editor.js +0 -508
- package/dist/elements/search.d.ts +0 -3
- package/dist/elements/search.js +0 -207
- package/dist/elements/select.d.ts +0 -6
- package/dist/elements/select.js +0 -291
- package/dist/elements/shared.d.ts +0 -19
- package/dist/elements/shared.js +0 -396
- package/dist/elements/skeleton.d.ts +0 -6
- package/dist/elements/skeleton.js +0 -91
- package/dist/elements/slider.d.ts +0 -1
- package/dist/elements/slider.js +0 -248
- package/dist/elements/spin-button.d.ts +0 -7
- package/dist/elements/spin-button.js +0 -499
- package/dist/elements/spinner.d.ts +0 -4
- package/dist/elements/spinner.js +0 -124
- package/dist/elements/swatch-picker.d.ts +0 -5
- package/dist/elements/swatch-picker.js +0 -363
- package/dist/elements/table.d.ts +0 -21
- package/dist/elements/table.js +0 -261
- package/dist/elements/tabs.d.ts +0 -1
- package/dist/elements/tabs.js +0 -276
- package/dist/elements/tag-picker.d.ts +0 -29
- package/dist/elements/tag-picker.js +0 -697
- package/dist/elements/tags.d.ts +0 -21
- package/dist/elements/tags.js +0 -421
- package/dist/elements/teaching-popover.d.ts +0 -32
- package/dist/elements/teaching-popover.js +0 -412
- package/dist/elements/text.d.ts +0 -9
- package/dist/elements/text.js +0 -75
- package/dist/elements/textarea.d.ts +0 -1
- package/dist/elements/textarea.js +0 -182
- package/dist/elements/toast.d.ts +0 -25
- package/dist/elements/toast.js +0 -337
- package/dist/elements/toaster.d.ts +0 -6
- package/dist/elements/toaster.js +0 -356
- package/dist/elements/toggle.d.ts +0 -2
- package/dist/elements/toggle.js +0 -246
- package/dist/elements/toolbar.d.ts +0 -12
- package/dist/elements/toolbar.js +0 -381
- package/dist/elements/tooltip.d.ts +0 -76
- package/dist/elements/tooltip.js +0 -510
- package/dist/elements/tree-model.d.ts +0 -19
- package/dist/elements/tree-model.js +0 -34
- package/dist/elements/tree.d.ts +0 -5
- package/dist/elements/tree.js +0 -273
- package/dist/elements/view-card.d.ts +0 -2
- package/dist/elements/view-card.js +0 -78
- package/dist/elements/virtual-list.d.ts +0 -41
- package/dist/elements/virtual-list.js +0 -369
- package/dist/elements.d.ts +0 -72
- package/dist/elements.js +0 -207
- package/dist/virtualizer-hooks.d.ts +0 -80
- package/dist/virtualizer-hooks.js +0 -253
- package/scripts/generate-token-index.mjs +0 -43
- package/scripts/sync-component-catalog-signatures.mjs +0 -55
- package/scripts/validate-component-catalog.mjs +0 -44
- package/skills/sharepoint-ui/SKILL.md +0 -12
- package/skills/sharepoint-ui/references/choosing-components.md +0 -20
- package/skills/sharepoint-ui/references/sharepoint-patterns.md +0 -17
- package/tokens.json +0 -3777
package/dist/theme.js
CHANGED
|
@@ -1,167 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
spacing: { ...merged.spacing, ...theme?.spacing },
|
|
12
|
-
shape: { ...merged.shape, ...theme?.shape },
|
|
13
|
-
elevation: { ...merged.elevation, ...theme?.elevation },
|
|
14
|
-
materials: { ...merged.materials, ...theme?.materials },
|
|
15
|
-
motion: { ...merged.motion, ...theme?.motion },
|
|
16
|
-
layers: { ...merged.layers, ...theme?.layers },
|
|
17
|
-
customProperties: { ...merged.customProperties, ...theme?.customProperties }
|
|
18
|
-
}), {});
|
|
19
|
-
}
|
|
20
|
-
const designTokenMap = {
|
|
21
|
-
"colors.accent": "--spui-ui-accent", "colors.accentHover": "--spui-ui-accent-hover", "colors.accentPressed": "--spui-ui-accent-pressed",
|
|
22
|
-
"colors.accentSubtle": "--spui-ui-accent-subtle", "colors.accentSubtleHover": "--spui-ui-accent-subtle-hover", "colors.accentSubtlePressed": "--spui-ui-accent-subtle-pressed", "colors.accentForeground": "--spui-ui-accent-text", "colors.secondaryHover": "--spui-button-secondary-hover",
|
|
23
|
-
"colors.foreground": "--spui-ui-text", "colors.foregroundMuted": "--spui-ui-muted", "colors.foregroundTertiary": "--spui-ui-text-muted", "colors.foregroundSubtle": "--spui-ui-foreground-subtle",
|
|
24
|
-
"colors.foregroundDisabled": "--spui-ui-foreground-disabled", "colors.canvas": "--spui-ui-canvas",
|
|
25
|
-
"colors.surface": "--spui-ui-surface", "colors.surfaceHover": "--spui-ui-surface-hover", "colors.surfaceAlt": "--spui-ui-surface-alt", "colors.surfaceSecondary": "--spui-ui-surface-secondary", "colors.surfaceSubtle": "--spui-ui-surface-subtle", "colors.surfaceRaised": "--spui-ui-surface-raised",
|
|
26
|
-
"colors.surfaceSunken": "--spui-ui-surface-sunken", "colors.border": "--spui-ui-stroke", "colors.borderSubtle": "--spui-ui-border-subtle",
|
|
27
|
-
"colors.borderStrong": "--spui-ui-border-strong", "colors.borderFocus": "--spui-ui-border-focus", "colors.borderDisabled": "--spui-ui-border-disabled",
|
|
28
|
-
"colors.selectedBackground": "--spui-selection-background", "colors.selectedBackgroundHover": "--spui-selection-background-hover", "colors.selectedForeground": "--spui-selection-foreground",
|
|
29
|
-
"colors.selectedBorder": "--spui-selection-border", "colors.link": "--spui-link-color", "colors.linkVisited": "--spui-link-visited", "colors.overlay": "--spui-overlay-scrim",
|
|
30
|
-
"colors.info": "--spui-ui-info", "colors.infoSurface": "--spui-ui-info-surface",
|
|
31
|
-
"colors.success": "--spui-ui-success", "colors.successSurface": "--spui-ui-success-surface", "colors.warning": "--spui-ui-warning",
|
|
32
|
-
"colors.warningSurface": "--spui-ui-warning-surface", "colors.danger": "--spui-ui-danger", "colors.dangerSurface": "--spui-ui-danger-surface", "colors.focus": "--spui-ui-focus", "colors.focusRing": "--spui-focus-ring",
|
|
33
|
-
"typography.fontFamily": "--spui-font-family", "typography.fontFamilyMono": "--spui-font-family-mono",
|
|
34
|
-
"typography.fontSize": "--spui-text-font-size", "typography.fontSizeSmall": "--spui-text-font-size-small",
|
|
35
|
-
"typography.fontSizeLarge": "--spui-text-font-size-large", "typography.fontSizeHeading": "--spui-text-font-size-heading",
|
|
36
|
-
"typography.fontWeight": "--spui-text-font-weight", "typography.fontWeightStrong": "--spui-text-font-weight-strong",
|
|
37
|
-
"typography.lineHeight": "--spui-text-line-height", "typography.lineHeightHeading": "--spui-text-line-height-heading",
|
|
38
|
-
"typography.fontSize100": "--fontSizeBase100", "typography.fontSize200": "--fontSizeBase200", "typography.fontSize300": "--fontSizeBase300",
|
|
39
|
-
"typography.fontSize400": "--fontSizeBase400", "typography.fontSize500": "--fontSizeBase500", "typography.fontSize600": "--fontSizeBase600",
|
|
40
|
-
"typography.fontSize700": "--fontSizeHero700", "typography.fontSize800": "--fontSizeHero800", "typography.fontSize900": "--fontSizeHero900", "typography.fontSize1000": "--fontSizeHero1000",
|
|
41
|
-
"typography.fontSize1100": "--spui-text-font-size-1100", "typography.fontSize1200": "--spui-text-font-size-1200",
|
|
42
|
-
"typography.lineHeight100": "--lineHeightBase100", "typography.lineHeight200": "--lineHeightBase200", "typography.lineHeight300": "--lineHeightBase300",
|
|
43
|
-
"typography.lineHeight400": "--lineHeightBase400", "typography.lineHeight500": "--lineHeightBase500", "typography.lineHeight600": "--lineHeightBase600",
|
|
44
|
-
"typography.lineHeight700": "--lineHeightHero700", "typography.lineHeight800": "--lineHeightHero800", "typography.lineHeight900": "--lineHeightHero900", "typography.lineHeight1000": "--lineHeightHero1000",
|
|
45
|
-
"typography.lineHeight1100": "--spui-text-line-height-1100", "typography.lineHeight1200": "--spui-text-line-height-1200",
|
|
46
|
-
"typography.fontWeightRegular": "--fontWeightRegular", "typography.fontWeightMedium": "--fontWeightMedium",
|
|
47
|
-
"typography.fontWeightSemibold": "--fontWeightSemibold", "typography.fontWeightBold": "--fontWeightBold",
|
|
48
|
-
"typography.letterSpacing": "--spui-text-letter-spacing",
|
|
49
|
-
"spacing.controlHeight": "--spui-control-height", "spacing.controlGap": "--spui-control-gap", "spacing.controlPaddingInline": "--spui-control-padding-inline",
|
|
50
|
-
"spacing.controlPaddingBlock": "--spui-control-padding-block", "spacing.cardPadding": "--spui-card-padding", "spacing.fieldGap": "--spui-field-gap",
|
|
51
|
-
"spacing.sectionGap": "--spui-section-gap", "spacing.listGap": "--spui-list-gap", "spacing.touchTargetMin": "--spui-touch-target-min",
|
|
52
|
-
"shape.controlRadius": "--spui-control-radius", "shape.inputRadius": "--spui-input-radius", "shape.cardRadius": "--spui-card-radius",
|
|
53
|
-
"shape.surfaceRadius": "--spui-surface-radius", "shape.pillRadius": "--spui-pill-radius", "shape.focusRingWidth": "--spui-focus-ring-width",
|
|
54
|
-
"elevation.cardShadow": "--spui-card-shadow", "elevation.controlShadow": "--spui-control-shadow", "elevation.popoverShadow": "--spui-popover-shadow",
|
|
55
|
-
"elevation.overlayShadow": "--spui-overlay-shadow", "elevation.focusShadow": "--spui-focus-shadow",
|
|
56
|
-
"materials.glassBlur": "--spui-glass-blur", "materials.glassSaturation": "--spui-glass-saturation",
|
|
57
|
-
"materials.glassSurfaceOpacity": "--spui-glass-surface-opacity", "materials.glassCanvasOpacity": "--spui-glass-canvas-opacity", "materials.glassBorderOpacity": "--spui-glass-border-opacity",
|
|
58
|
-
"motion.durationFast": "--spui-motion-duration-fast", "motion.durationNormal": "--spui-motion-duration-normal", "motion.durationSlow": "--spui-motion-duration-slow",
|
|
59
|
-
"motion.easingStandard": "--spui-motion-easing-standard", "motion.easingEmphasized": "--spui-motion-easing-emphasized",
|
|
60
|
-
"layers.dropdown": "--spui-layer-dropdown", "layers.popover": "--spui-layer-popover", "layers.toast": "--spui-layer-toast"
|
|
1
|
+
import { createContext, createElement, useContext } from "react";
|
|
2
|
+
const defaults = {
|
|
3
|
+
accent: "#0f6cbd",
|
|
4
|
+
accentText: "#ffffff",
|
|
5
|
+
background: "#f5f5f5",
|
|
6
|
+
border: "#d1d1d1",
|
|
7
|
+
radius: "4px",
|
|
8
|
+
surface: "#ffffff",
|
|
9
|
+
text: "#242424",
|
|
10
|
+
muted: "#616161",
|
|
61
11
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"--spui-link-color": `var(--spui-semantic-link, color-mix(in srgb, ${accent} 55%, var(--spui-ui-text) 45%))`,
|
|
81
|
-
"--spui-focus-ring": "var(--spui-ui-border-focus)",
|
|
82
|
-
"--spui-ui-info": accent,
|
|
83
|
-
"--spui-ui-info-surface": `color-mix(in srgb, ${accent} 12%, var(--spui-ui-surface))`,
|
|
84
|
-
"--spui-primary-background": accent,
|
|
85
|
-
"--spui-primary-hover": `color-mix(in srgb, ${accent} 84%, black)`
|
|
86
|
-
});
|
|
87
|
-
if (accent && !theme?.colors?.accentForeground) {
|
|
88
|
-
const hex = /^#([\da-f]{3}|[\da-f]{6})$/i.exec(accent)?.[1];
|
|
89
|
-
if (hex) {
|
|
90
|
-
const normalized = hex.length === 3 ? [...hex].map(value => value + value).join("") : hex;
|
|
91
|
-
const channels = normalized.match(/[\da-f]{2}/gi).map(value => Number.parseInt(value, 16) / 255).map(value => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4);
|
|
92
|
-
const luminance = channels[0] * 0.2126 + channels[1] * 0.7152 + channels[2] * 0.0722;
|
|
93
|
-
result["--spui-ui-accent-text"] = luminance > 0.179 ? "#000000" : "#ffffff";
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
for (const [group, values] of Object.entries(theme ?? {})) {
|
|
97
|
-
if (group === "brandColor" || group === "palette" || group === "customProperties")
|
|
98
|
-
continue;
|
|
99
|
-
for (const [name, value] of Object.entries(values ?? {})) {
|
|
100
|
-
if (value !== undefined) {
|
|
101
|
-
const token = designTokenMap[`${group}.${name}`];
|
|
102
|
-
if (token)
|
|
103
|
-
result[token] = String(value);
|
|
104
|
-
}
|
|
12
|
+
const sharePointVars = {
|
|
13
|
+
accent: "--themePrimary",
|
|
14
|
+
accentText: "--white",
|
|
15
|
+
background: "--neutralLighterAlt",
|
|
16
|
+
border: "--neutralQuaternaryAlt",
|
|
17
|
+
surface: "--white",
|
|
18
|
+
text: "--neutralPrimary",
|
|
19
|
+
muted: "--neutralSecondary",
|
|
20
|
+
};
|
|
21
|
+
const ThemeContext = createContext(defaults);
|
|
22
|
+
export function createSharePointTheme(overrides = {}) {
|
|
23
|
+
const inherited = {};
|
|
24
|
+
if (typeof document !== "undefined") {
|
|
25
|
+
const style = getComputedStyle(document.documentElement);
|
|
26
|
+
for (const [token, variable] of Object.entries(sharePointVars)) {
|
|
27
|
+
const value = style.getPropertyValue(variable).trim();
|
|
28
|
+
if (value)
|
|
29
|
+
inherited[token] = value;
|
|
105
30
|
}
|
|
106
31
|
}
|
|
107
|
-
|
|
108
|
-
for (const [name, value] of Object.entries(theme?.customProperties ?? {})) {
|
|
109
|
-
if (name.startsWith("--") && name.length > 2)
|
|
110
|
-
result[name] = String(value);
|
|
111
|
-
}
|
|
112
|
-
return result;
|
|
32
|
+
return { ...defaults, ...inherited, ...overrides };
|
|
113
33
|
}
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (theme) {
|
|
122
|
-
for (const [group, values] of Object.entries({ palette: theme.palette, semantic: theme.semanticColors })) {
|
|
123
|
-
for (const [name, value] of Object.entries(values ?? {})) {
|
|
124
|
-
if (!value)
|
|
125
|
-
continue;
|
|
126
|
-
const property = `--spui-${group}-${toKebab(name)}`;
|
|
127
|
-
style.setProperty(property, value);
|
|
128
|
-
names.add(property);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
for (const [group, values] of Object.entries({ effects: theme.effects, spacing: theme.spacing, "default-font-style": theme.defaultFontStyle })) {
|
|
132
|
-
for (const [name, value] of Object.entries(values ?? {})) {
|
|
133
|
-
if (typeof value !== "string" && typeof value !== "number")
|
|
134
|
-
continue;
|
|
135
|
-
const property = `--spui-${group}-${toKebab(name)}`;
|
|
136
|
-
style.setProperty(property, String(value));
|
|
137
|
-
names.add(property);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
for (const [name, values] of Object.entries(theme.fonts ?? {})) {
|
|
141
|
-
for (const [propertyName, value] of Object.entries(values ?? {})) {
|
|
142
|
-
if (typeof value !== "string" && typeof value !== "number")
|
|
143
|
-
continue;
|
|
144
|
-
const property = `--spui-fonts-${toKebab(name)}-${toKebab(propertyName)}`;
|
|
145
|
-
style.setProperty(property, String(value));
|
|
146
|
-
names.add(property);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
style.setProperty("--spui-is-inverted", theme.isInverted ? "1" : "0");
|
|
150
|
-
names.add("--spui-is-inverted");
|
|
151
|
-
}
|
|
152
|
-
for (const [name, value] of Object.entries(fluentTokens ?? {})) {
|
|
153
|
-
if (typeof value !== "string" && typeof value !== "number")
|
|
154
|
-
continue;
|
|
155
|
-
const property = name.startsWith("--") ? name : `--${name}`;
|
|
156
|
-
style.setProperty(property, String(value));
|
|
157
|
-
names.add(property);
|
|
158
|
-
}
|
|
159
|
-
target.dataset.spuiAppearance = options.appearance ?? "fluent";
|
|
160
|
-
const styleTokens = getSharePointUIStyleTokens(options.appearance, { ...getSharePointUIDesignTokens(options.theme), ...options.tokens }, options.baseAppearance, options.density);
|
|
161
|
-
for (const [property, value] of Object.entries(styleTokens)) {
|
|
162
|
-
style.setProperty(property, String(value));
|
|
163
|
-
names.add(property);
|
|
164
|
-
}
|
|
165
|
-
style.colorScheme = String(styleTokens["--spui-color-scheme"] ?? "light");
|
|
166
|
-
appliedProperties.set(target, names);
|
|
34
|
+
export function SharePointThemeProvider({ children, theme, }) {
|
|
35
|
+
const value = createSharePointTheme(theme);
|
|
36
|
+
const style = Object.fromEntries(Object.entries(theme ?? {}).map(([key, token]) => [`--spui-${key}`, token]));
|
|
37
|
+
return createElement(ThemeContext.Provider, { value }, createElement("div", { className: "spui-theme", style }, children));
|
|
38
|
+
}
|
|
39
|
+
export function useSharePointTheme() {
|
|
40
|
+
return useContext(ThemeContext);
|
|
167
41
|
}
|
package/dist/toast.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
export type ToastProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
3
|
+
open: boolean;
|
|
4
|
+
message: ReactNode;
|
|
5
|
+
durationMs?: number;
|
|
6
|
+
dismissLabel?: string;
|
|
7
|
+
onDismiss: () => void;
|
|
8
|
+
};
|
|
9
|
+
export declare function Toast({ open, message, durationMs, dismissLabel, onDismiss, className, ...props }: ToastProps): ReactElement | null;
|
package/dist/toast.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createElement, useEffect } from "react";
|
|
2
|
+
export function Toast({ open, message, durationMs = 5000, dismissLabel = "Dismiss", onDismiss, className = "", ...props }) {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
if (!open || durationMs <= 0)
|
|
5
|
+
return;
|
|
6
|
+
const timer = setTimeout(onDismiss, durationMs);
|
|
7
|
+
return () => clearTimeout(timer);
|
|
8
|
+
}, [open, durationMs, onDismiss]);
|
|
9
|
+
if (!open)
|
|
10
|
+
return null;
|
|
11
|
+
return createElement("div", { ...props, role: "status", "aria-live": "polite", className: `spui-toast ${className}`.trim() }, createElement("span", null, message), createElement("button", { type: "button", "aria-label": dismissLabel, onClick: onDismiss }, dismissLabel));
|
|
12
|
+
}
|
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
export type TreeNode = {
|
|
3
|
+
id: string;
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
href?: string;
|
|
6
|
+
children?: readonly TreeNode[];
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type TreeProps = Omit<HTMLAttributes<HTMLUListElement>, "children" | "aria-label"> & {
|
|
10
|
+
label: string;
|
|
11
|
+
items: readonly TreeNode[];
|
|
12
|
+
};
|
|
13
|
+
export declare function Tree({ label, items, className, ...props }: TreeProps): ReactElement;
|
package/dist/tree.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
function renderNodes(nodes) {
|
|
3
|
+
return nodes.map(node => createElement("li", { key: node.id }, node.children?.length
|
|
4
|
+
? createElement("details", { open: node.defaultOpen }, createElement("summary", null, node.href ? createElement("a", { href: node.href }, node.label) : node.label), createElement("ul", null, renderNodes(node.children)))
|
|
5
|
+
: node.href ? createElement("a", { href: node.href }, node.label) : node.label));
|
|
6
|
+
}
|
|
7
|
+
export function Tree({ label, items, className = "", ...props }) {
|
|
8
|
+
return createElement("ul", { ...props, "aria-label": label, className: `spui-tree ${className}`.trim() }, renderNodes(items));
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
export type ViewCardProps = Omit<HTMLAttributes<HTMLElement>, "children" | "title"> & {
|
|
3
|
+
title: ReactNode;
|
|
4
|
+
subtitle?: ReactNode;
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export declare function ViewCard({ title, subtitle, description, className, children, ...props }: ViewCardProps): ReactElement;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
export function ViewCard({ title, subtitle, description, className = "", children, ...props }) {
|
|
3
|
+
return createElement("article", { ...props, className: `spui-view-card ${className}`.trim() }, createElement("h2", null, title), subtitle && createElement("p", { className: "spui-view-subtitle" }, subtitle), description && createElement("p", null, description), children);
|
|
4
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactElement } from "react";
|
|
2
|
+
export type ViewOption = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type ViewSwitcherProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "aria-label"> & {
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
views: readonly ViewOption[];
|
|
11
|
+
onChange: (value: string) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function ViewSwitcher({ label, value, views, onChange, className, ...props }: ViewSwitcherProps): ReactElement;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
export function ViewSwitcher({ label, value, views, onChange, className = "", ...props }) {
|
|
3
|
+
return createElement("div", { ...props, role: "group", "aria-label": label, className: `spui-view-switcher ${className}`.trim() }, views.map(view => createElement("button", {
|
|
4
|
+
key: view.value, type: "button", disabled: view.disabled,
|
|
5
|
+
"aria-pressed": value === view.value, onClick: () => onChange(view.value),
|
|
6
|
+
}, view.label)));
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
export type VirtualListProps<Item> = Omit<HTMLAttributes<HTMLDivElement>, "children" | "aria-label"> & {
|
|
3
|
+
label: string;
|
|
4
|
+
items: readonly Item[];
|
|
5
|
+
itemHeight: number;
|
|
6
|
+
height: number;
|
|
7
|
+
getItemKey: (item: Item, index: number) => string;
|
|
8
|
+
renderItem: (item: Item, index: number) => ReactNode;
|
|
9
|
+
overscan?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function VirtualList<Item>({ label, items, itemHeight, height, getItemKey, renderItem, overscan, className, style, ...props }: VirtualListProps<Item>): ReactElement;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createElement, useState } from "react";
|
|
2
|
+
export function VirtualList({ label, items, itemHeight, height, getItemKey, renderItem, overscan = 3, className = "", style, ...props }) {
|
|
3
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
4
|
+
const rowHeight = Math.max(1, itemHeight);
|
|
5
|
+
const viewportHeight = Math.max(1, height);
|
|
6
|
+
const extra = Math.max(0, Math.floor(overscan));
|
|
7
|
+
const start = Math.max(0, Math.floor(scrollTop / rowHeight) - extra);
|
|
8
|
+
const end = Math.min(items.length, start + Math.ceil(viewportHeight / rowHeight) + extra * 2);
|
|
9
|
+
const onScroll = (event) => setScrollTop(event.currentTarget.scrollTop);
|
|
10
|
+
return createElement("div", {
|
|
11
|
+
...props,
|
|
12
|
+
role: "list",
|
|
13
|
+
"aria-label": label,
|
|
14
|
+
tabIndex: 0,
|
|
15
|
+
className: `spui-virtual-list ${className}`.trim(),
|
|
16
|
+
style: { ...style, height: viewportHeight, overflowY: "auto" },
|
|
17
|
+
onScroll,
|
|
18
|
+
}, createElement("div", { role: "presentation", "aria-hidden": true, style: { height: start * rowHeight } }), items.slice(start, end).map((item, offset) => {
|
|
19
|
+
const index = start + offset;
|
|
20
|
+
return createElement("div", {
|
|
21
|
+
key: getItemKey(item, index), role: "listitem", "aria-posinset": index + 1, "aria-setsize": items.length,
|
|
22
|
+
className: "spui-virtual-list-item", style: { height: rowHeight },
|
|
23
|
+
}, renderItem(item, index));
|
|
24
|
+
}), createElement("div", { role: "presentation", "aria-hidden": true, style: { height: (items.length - end) * rowHeight } }));
|
|
25
|
+
}
|