@ohos-ports/instructure-ui-breadcrumb 11.7.5-beta.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 +1330 -0
- package/LICENSE.md +28 -0
- package/README.md +46 -0
- package/es/Breadcrumb/v1/BreadcrumbLink/index.js +119 -0
- package/es/Breadcrumb/v1/BreadcrumbLink/props.js +26 -0
- package/es/Breadcrumb/v1/index.js +113 -0
- package/es/Breadcrumb/v1/props.js +26 -0
- package/es/Breadcrumb/v1/styles.js +106 -0
- package/es/Breadcrumb/v1/theme.js +49 -0
- package/es/Breadcrumb/v2/BreadcrumbLink/index.js +121 -0
- package/es/Breadcrumb/v2/BreadcrumbLink/props.js +26 -0
- package/es/Breadcrumb/v2/index.js +133 -0
- package/es/Breadcrumb/v2/props.js +26 -0
- package/es/Breadcrumb/v2/styles.js +77 -0
- package/es/exports/a.js +24 -0
- package/es/exports/b.js +24 -0
- package/lib/Breadcrumb/v1/BreadcrumbLink/index.js +125 -0
- package/lib/Breadcrumb/v1/BreadcrumbLink/props.js +31 -0
- package/lib/Breadcrumb/v1/index.js +125 -0
- package/lib/Breadcrumb/v1/props.js +31 -0
- package/lib/Breadcrumb/v1/styles.js +112 -0
- package/lib/Breadcrumb/v1/theme.js +55 -0
- package/lib/Breadcrumb/v2/BreadcrumbLink/index.js +127 -0
- package/lib/Breadcrumb/v2/BreadcrumbLink/props.js +31 -0
- package/lib/Breadcrumb/v2/index.js +145 -0
- package/lib/Breadcrumb/v2/props.js +31 -0
- package/lib/Breadcrumb/v2/styles.js +83 -0
- package/lib/exports/a.js +18 -0
- package/lib/exports/b.js +18 -0
- package/lib/package.json +1 -0
- package/package.json +90 -0
- package/scripts/fix-instructure-exports.js +137 -0
- package/src/Breadcrumb/v1/BreadcrumbLink/index.tsx +122 -0
- package/src/Breadcrumb/v1/BreadcrumbLink/props.ts +102 -0
- package/src/Breadcrumb/v1/README.md +141 -0
- package/src/Breadcrumb/v1/index.tsx +143 -0
- package/src/Breadcrumb/v1/props.ts +63 -0
- package/src/Breadcrumb/v1/styles.ts +116 -0
- package/src/Breadcrumb/v1/theme.ts +55 -0
- package/src/Breadcrumb/v2/BreadcrumbLink/index.tsx +123 -0
- package/src/Breadcrumb/v2/BreadcrumbLink/props.ts +101 -0
- package/src/Breadcrumb/v2/README.md +141 -0
- package/src/Breadcrumb/v2/index.tsx +157 -0
- package/src/Breadcrumb/v2/props.ts +64 -0
- package/src/Breadcrumb/v2/styles.ts +86 -0
- package/src/exports/a.ts +27 -0
- package/src/exports/b.ts +27 -0
- package/tsconfig.build.json +24 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +4 -0
- package/types/Breadcrumb/v1/BreadcrumbLink/index.d.ts +31 -0
- package/types/Breadcrumb/v1/BreadcrumbLink/index.d.ts.map +1 -0
- package/types/Breadcrumb/v1/BreadcrumbLink/props.d.ts +49 -0
- package/types/Breadcrumb/v1/BreadcrumbLink/props.d.ts.map +1 -0
- package/types/Breadcrumb/v1/index.d.ts +35 -0
- package/types/Breadcrumb/v1/index.d.ts.map +1 -0
- package/types/Breadcrumb/v1/props.d.ts +30 -0
- package/types/Breadcrumb/v1/props.d.ts.map +1 -0
- package/types/Breadcrumb/v1/styles.d.ts +15 -0
- package/types/Breadcrumb/v1/styles.d.ts.map +1 -0
- package/types/Breadcrumb/v1/theme.d.ts +10 -0
- package/types/Breadcrumb/v1/theme.d.ts.map +1 -0
- package/types/Breadcrumb/v2/BreadcrumbLink/index.d.ts +31 -0
- package/types/Breadcrumb/v2/BreadcrumbLink/index.d.ts.map +1 -0
- package/types/Breadcrumb/v2/BreadcrumbLink/props.d.ts +49 -0
- package/types/Breadcrumb/v2/BreadcrumbLink/props.d.ts.map +1 -0
- package/types/Breadcrumb/v2/index.d.ts +35 -0
- package/types/Breadcrumb/v2/index.d.ts.map +1 -0
- package/types/Breadcrumb/v2/props.d.ts +30 -0
- package/types/Breadcrumb/v2/props.d.ts.map +1 -0
- package/types/Breadcrumb/v2/styles.d.ts +14 -0
- package/types/Breadcrumb/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +4 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +4 -0
- package/types/exports/b.d.ts.map +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ohos-ports/instructure-ui-breadcrumb",
|
|
3
|
+
"version": "11.7.5-beta.0",
|
|
4
|
+
"description": "A breadcrumb component",
|
|
5
|
+
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
|
+
"module": "./es/index.js",
|
|
7
|
+
"main": "./lib/index.js",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/ohos-ports/ohos-ports.git",
|
|
12
|
+
"directory": "ports/instructure-ui-breadcrumb/11.7.5"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://instructure.github.io/instructure-ui/",
|
|
15
|
+
"bugs": "https://github.com/ohos-ports/ohos-ports/issues",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@babel/runtime": "^7.29.7",
|
|
19
|
+
"@instructure/emotion": "11.7.5",
|
|
20
|
+
"@instructure/shared-types": "11.7.5",
|
|
21
|
+
"@instructure/ui-icons": "11.7.5",
|
|
22
|
+
"@instructure/ui-link": "11.7.5",
|
|
23
|
+
"@instructure/ui-react-utils": "11.7.5",
|
|
24
|
+
"@instructure/ui-themes": "11.7.5",
|
|
25
|
+
"@instructure/ui-tooltip": "11.7.5",
|
|
26
|
+
"@instructure/ui-truncate-text": "11.7.5",
|
|
27
|
+
"@instructure/ui-view": "11.7.5",
|
|
28
|
+
"@instructure/ui-utils": "11.7.5"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
32
|
+
"@testing-library/react": "16.3.2",
|
|
33
|
+
"vitest": "^4.1.9",
|
|
34
|
+
"@instructure/ui-babel-preset": "11.7.5",
|
|
35
|
+
"@instructure/ui-scripts": "11.7.5",
|
|
36
|
+
"@instructure/ui-axe-check": "11.7.5"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": ">=18 <=19"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"sideEffects": false,
|
|
45
|
+
"exports": {
|
|
46
|
+
"./lib/*": "./lib/*",
|
|
47
|
+
"./es/*": "./es/*",
|
|
48
|
+
"./types/*": "./types/*",
|
|
49
|
+
"./package.json": "./package.json",
|
|
50
|
+
"./src/*": "./src/*",
|
|
51
|
+
".": {
|
|
52
|
+
"src": "./src/exports/a.ts",
|
|
53
|
+
"types": "./types/exports/a.d.ts",
|
|
54
|
+
"import": "./es/exports/a.js",
|
|
55
|
+
"require": "./lib/exports/a.js",
|
|
56
|
+
"default": "./es/exports/a.js"
|
|
57
|
+
},
|
|
58
|
+
"./v11_6": {
|
|
59
|
+
"src": "./src/exports/a.ts",
|
|
60
|
+
"types": "./types/exports/a.d.ts",
|
|
61
|
+
"import": "./es/exports/a.js",
|
|
62
|
+
"require": "./lib/exports/a.js",
|
|
63
|
+
"default": "./es/exports/a.js"
|
|
64
|
+
},
|
|
65
|
+
"./v11_7": {
|
|
66
|
+
"src": "./src/exports/b.ts",
|
|
67
|
+
"types": "./types/exports/b.d.ts",
|
|
68
|
+
"import": "./es/exports/b.js",
|
|
69
|
+
"require": "./lib/exports/b.js",
|
|
70
|
+
"default": "./es/exports/b.js"
|
|
71
|
+
},
|
|
72
|
+
"./latest": {
|
|
73
|
+
"src": "./src/exports/b.ts",
|
|
74
|
+
"types": "./types/exports/b.d.ts",
|
|
75
|
+
"import": "./es/exports/b.js",
|
|
76
|
+
"require": "./lib/exports/b.js",
|
|
77
|
+
"default": "./es/exports/b.js"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"scripts": {
|
|
81
|
+
"lint": "ui-scripts lint",
|
|
82
|
+
"lint:fix": "ui-scripts lint --fix",
|
|
83
|
+
"clean": "ui-scripts clean",
|
|
84
|
+
"build": "ui-scripts build --modules es,cjs",
|
|
85
|
+
"build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
|
|
86
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
87
|
+
"ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false",
|
|
88
|
+
"postinstall": "node scripts/fix-instructure-exports.js"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Postinstall fix for Node.js >= 22 (strict exports resolution).
|
|
4
|
+
*
|
|
5
|
+
* Problem: @instructure/* packages publish wildcard "folder passthrough"
|
|
6
|
+
* exports such as:
|
|
7
|
+
* "./lib/*": "./lib/*"
|
|
8
|
+
* and consumers require *directory* subpaths, e.g.
|
|
9
|
+
* require("@instructure/ui-svg-images/lib/SVGIcon")
|
|
10
|
+
* Older Node.js versions resolved such targets to <dir>/index.js with a
|
|
11
|
+
* deprecation warning (DEP0155-style behaviour); modern Node.js (>= v22,
|
|
12
|
+
* strict in v26) refuses to resolve exports targets to directories, so the
|
|
13
|
+
* module graph fails with MODULE_NOT_FOUND / ERR_PACKAGE_PATH_NOT_EXPORTED.
|
|
14
|
+
*
|
|
15
|
+
* Fix: for every installed package whose exports contain a passthrough
|
|
16
|
+
* wildcard (key === value, e.g. "./lib/*"), add explicit mappings
|
|
17
|
+
* "./lib/<dir>": "./lib/<dir>/index.js"
|
|
18
|
+
* for every directory under that base that contains an index file. Exact
|
|
19
|
+
* string matches always win over wildcard patterns in Node's exports
|
|
20
|
+
* algorithm, so this restores the legacy directory resolution without
|
|
21
|
+
* touching any other behaviour.
|
|
22
|
+
*
|
|
23
|
+
* Run automatically via the package "postinstall" script.
|
|
24
|
+
*/
|
|
25
|
+
'use strict'
|
|
26
|
+
|
|
27
|
+
const fs = require('fs')
|
|
28
|
+
const path = require('path')
|
|
29
|
+
|
|
30
|
+
const INDEX_FILES = ['index.js', 'index.cjs', 'index.mjs']
|
|
31
|
+
|
|
32
|
+
// Collect [relativeDir] pairs for every directory under `baseDir`
|
|
33
|
+
// (recursively) that contains an index file.
|
|
34
|
+
function collectIndexDirs (baseDir, rel = '') {
|
|
35
|
+
const out = []
|
|
36
|
+
let entries
|
|
37
|
+
try {
|
|
38
|
+
entries = fs.readdirSync(baseDir, { withFileTypes: true })
|
|
39
|
+
} catch (e) {
|
|
40
|
+
return out
|
|
41
|
+
}
|
|
42
|
+
for (const entry of entries) {
|
|
43
|
+
if (!entry.isDirectory()) continue
|
|
44
|
+
const relPath = rel ? `${rel}/${entry.name}` : entry.name
|
|
45
|
+
const dir = path.join(baseDir, entry.name)
|
|
46
|
+
for (const idx of INDEX_FILES) {
|
|
47
|
+
if (fs.existsSync(path.join(dir, idx))) {
|
|
48
|
+
out.push(relPath)
|
|
49
|
+
break
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
out.push(...collectIndexDirs(dir, relPath))
|
|
53
|
+
}
|
|
54
|
+
return out
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function patchExports (pkgDir) {
|
|
58
|
+
const pkgJsonPath = path.join(pkgDir, 'package.json')
|
|
59
|
+
let pkg
|
|
60
|
+
try {
|
|
61
|
+
pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'))
|
|
62
|
+
} catch (e) {
|
|
63
|
+
return false
|
|
64
|
+
}
|
|
65
|
+
if (!pkg.exports || typeof pkg.exports !== 'object') return false
|
|
66
|
+
|
|
67
|
+
let changed = false
|
|
68
|
+
for (const [key, value] of Object.entries(pkg.exports)) {
|
|
69
|
+
if (typeof value !== 'string') continue
|
|
70
|
+
// Only handle passthrough wildcards like "./lib/*": "./lib/*"
|
|
71
|
+
const m = key.match(/^\.\/([^*]+)\*$/)
|
|
72
|
+
if (!m || value !== key) continue
|
|
73
|
+
const base = m[1] // e.g. "lib/"
|
|
74
|
+
const baseDir = path.join(pkgDir, base)
|
|
75
|
+
for (const rel of collectIndexDirs(baseDir)) {
|
|
76
|
+
const sub = `./${base}${rel}`
|
|
77
|
+
if (!(sub in pkg.exports)) {
|
|
78
|
+
pkg.exports[sub] = `${sub}/index.js`
|
|
79
|
+
changed = true
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (changed) {
|
|
84
|
+
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2) + '\n')
|
|
85
|
+
}
|
|
86
|
+
return changed
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Find the nearest node_modules directory by walking up from `startDir`.
|
|
90
|
+
// When this package is installed as a dependency, the consumer's
|
|
91
|
+
// node_modules is an ancestor of __dirname (e.g.
|
|
92
|
+
// <root>/node_modules/@ohos-ports/instructure-ui-breadcrumb/scripts),
|
|
93
|
+
// so we walk up until we find it.
|
|
94
|
+
function findNodeModules (startDir) {
|
|
95
|
+
let dir = startDir
|
|
96
|
+
while (true) {
|
|
97
|
+
const candidate = path.join(dir, 'node_modules')
|
|
98
|
+
try {
|
|
99
|
+
if (fs.statSync(candidate).isDirectory()) return candidate
|
|
100
|
+
} catch (e) {
|
|
101
|
+
// not found, keep walking up
|
|
102
|
+
}
|
|
103
|
+
const parent = path.dirname(dir)
|
|
104
|
+
if (parent === dir) return null
|
|
105
|
+
dir = parent
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function main () {
|
|
110
|
+
const nm = findNodeModules(__dirname)
|
|
111
|
+
if (!nm) {
|
|
112
|
+
console.log('[fix-instructure-exports] no node_modules, skipping')
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
let patched = 0
|
|
116
|
+
const visit = (dir) => {
|
|
117
|
+
let entries
|
|
118
|
+
try {
|
|
119
|
+
entries = fs.readdirSync(dir, { withFileTypes: true })
|
|
120
|
+
} catch (e) {
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
for (const entry of entries) {
|
|
124
|
+
if (!entry.isDirectory()) continue
|
|
125
|
+
const full = path.join(dir, entry.name)
|
|
126
|
+
if (entry.name.startsWith('@')) {
|
|
127
|
+
visit(full)
|
|
128
|
+
} else if (fs.existsSync(path.join(full, 'package.json'))) {
|
|
129
|
+
if (patchExports(full)) patched++
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
visit(nm)
|
|
134
|
+
console.log(`[fix-instructure-exports] patched ${patched} package(s)`)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
main()
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { Component } from 'react'
|
|
26
|
+
|
|
27
|
+
import { TruncateText } from '@instructure/ui-truncate-text/v11_6'
|
|
28
|
+
import { Link } from '@instructure/ui-link/v11_6'
|
|
29
|
+
import { omitProps } from '@instructure/ui-react-utils'
|
|
30
|
+
import { Tooltip } from '@instructure/ui-tooltip/v11_6'
|
|
31
|
+
|
|
32
|
+
import { allowedProps } from './props.js'
|
|
33
|
+
import type { BreadcrumbLinkProps, BreadcrumbLinkState } from './props'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
---
|
|
37
|
+
parent: Breadcrumb
|
|
38
|
+
id: Breadcrumb.Link
|
|
39
|
+
---
|
|
40
|
+
**/
|
|
41
|
+
|
|
42
|
+
class BreadcrumbLink extends Component<
|
|
43
|
+
BreadcrumbLinkProps,
|
|
44
|
+
BreadcrumbLinkState
|
|
45
|
+
> {
|
|
46
|
+
static displayName = 'BreadcrumbLink'
|
|
47
|
+
static readonly componentId = 'Breadcrumb.Link'
|
|
48
|
+
|
|
49
|
+
static allowedProps = allowedProps
|
|
50
|
+
static defaultProps = {}
|
|
51
|
+
|
|
52
|
+
ref: Element | null = null
|
|
53
|
+
|
|
54
|
+
handleRef = (el: Element | null) => {
|
|
55
|
+
this.ref = el
|
|
56
|
+
}
|
|
57
|
+
constructor(props: BreadcrumbLinkProps) {
|
|
58
|
+
super(props)
|
|
59
|
+
|
|
60
|
+
this.state = {
|
|
61
|
+
isTruncated: false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
handleTruncation(isTruncated: boolean) {
|
|
65
|
+
if (isTruncated !== this.state.isTruncated) {
|
|
66
|
+
this.setState({ isTruncated })
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
render() {
|
|
71
|
+
const {
|
|
72
|
+
children,
|
|
73
|
+
href,
|
|
74
|
+
renderIcon,
|
|
75
|
+
iconPlacement,
|
|
76
|
+
onClick,
|
|
77
|
+
onMouseEnter,
|
|
78
|
+
isCurrentPage
|
|
79
|
+
} = this.props
|
|
80
|
+
|
|
81
|
+
const { isTruncated } = this.state
|
|
82
|
+
const props = omitProps(this.props, BreadcrumbLink.allowedProps)
|
|
83
|
+
|
|
84
|
+
const isInteractive = onClick || href
|
|
85
|
+
return (
|
|
86
|
+
<Tooltip
|
|
87
|
+
renderTip={children}
|
|
88
|
+
preventTooltip={!isTruncated}
|
|
89
|
+
// this wraps the achor/button tag in a span and puts the aria-describedby on that instead of the anchor/button tag
|
|
90
|
+
// to avoid SRs reading the text twice when there is already an aria-label
|
|
91
|
+
{...(isInteractive && { as: 'span' })}
|
|
92
|
+
>
|
|
93
|
+
<Link
|
|
94
|
+
{...props}
|
|
95
|
+
href={href}
|
|
96
|
+
renderIcon={renderIcon}
|
|
97
|
+
iconPlacement={iconPlacement}
|
|
98
|
+
onClick={onClick}
|
|
99
|
+
onMouseEnter={onMouseEnter}
|
|
100
|
+
isWithinText={false}
|
|
101
|
+
elementRef={this.handleRef}
|
|
102
|
+
forceButtonRole={false}
|
|
103
|
+
{...(isCurrentPage && { 'aria-current': 'page' })}
|
|
104
|
+
{...(isTruncated && {
|
|
105
|
+
...(typeof children === 'string' && { 'aria-label': children }),
|
|
106
|
+
...(!isInteractive && { role: 'text' })
|
|
107
|
+
})}
|
|
108
|
+
data-cid="BreadcrumbLink"
|
|
109
|
+
>
|
|
110
|
+
<TruncateText
|
|
111
|
+
onUpdate={(isTruncated) => this.handleTruncation(isTruncated)}
|
|
112
|
+
>
|
|
113
|
+
<span aria-hidden={isTruncated}>{children}</span>
|
|
114
|
+
</TruncateText>
|
|
115
|
+
</Link>
|
|
116
|
+
</Tooltip>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default BreadcrumbLink
|
|
122
|
+
export { BreadcrumbLink }
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import React from 'react'
|
|
26
|
+
import type {
|
|
27
|
+
PickPropsWithExceptions,
|
|
28
|
+
OtherHTMLAttributes,
|
|
29
|
+
Renderable
|
|
30
|
+
} from '@instructure/shared-types'
|
|
31
|
+
import type { ViewOwnProps } from '@instructure/ui-view/v11_6'
|
|
32
|
+
import type { LinkProps } from '@instructure/ui-link/v11_6'
|
|
33
|
+
|
|
34
|
+
type BreadcrumbLinkOwnProps = {
|
|
35
|
+
/**
|
|
36
|
+
* Content to render as the crumb, generally should be text.
|
|
37
|
+
*/
|
|
38
|
+
children: React.ReactNode
|
|
39
|
+
/**
|
|
40
|
+
* Link the crumb should direct to; if an href is provided, the crumb will render as a link
|
|
41
|
+
*/
|
|
42
|
+
href?: string
|
|
43
|
+
/**
|
|
44
|
+
* If the Breadcrumb.Link has an onClick prop (and no href), it will render as a button
|
|
45
|
+
*/
|
|
46
|
+
onClick?: (event: React.MouseEvent<ViewOwnProps, MouseEvent>) => void
|
|
47
|
+
/**
|
|
48
|
+
* Fires when the Link is hovered
|
|
49
|
+
*/
|
|
50
|
+
onMouseEnter?: (event: React.MouseEvent<ViewOwnProps, MouseEvent>) => void
|
|
51
|
+
/**
|
|
52
|
+
* Sets the font-size of the breadcrumb text
|
|
53
|
+
*/
|
|
54
|
+
size?: 'small' | 'medium' | 'large'
|
|
55
|
+
/**
|
|
56
|
+
* Add an icon to the Breadcrumb.Link
|
|
57
|
+
*/
|
|
58
|
+
renderIcon?: Renderable
|
|
59
|
+
/**
|
|
60
|
+
* Place the icon before or after the text in the Breadcrumb.Link
|
|
61
|
+
*/
|
|
62
|
+
iconPlacement?: 'start' | 'end'
|
|
63
|
+
/**
|
|
64
|
+
* Whether the page this breadcrumb points to is the current one. If true, it sets aria-current="page".
|
|
65
|
+
* If this prop is not set to true on any breadcrumb element, the one recieving the aria-current="page" will always be the last element, unless the last element's isCurrentPage prop is explicity set to false.
|
|
66
|
+
*/
|
|
67
|
+
isCurrentPage?: boolean
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
type PropKeys = keyof BreadcrumbLinkOwnProps
|
|
71
|
+
|
|
72
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
73
|
+
|
|
74
|
+
type BreadcrumbLinkProps = PickPropsWithExceptions<
|
|
75
|
+
LinkProps,
|
|
76
|
+
| 'children'
|
|
77
|
+
| 'href'
|
|
78
|
+
| 'onClick'
|
|
79
|
+
| 'renderIcon'
|
|
80
|
+
| 'iconPlacement'
|
|
81
|
+
| 'isWithinText'
|
|
82
|
+
| 'elementRef'
|
|
83
|
+
> &
|
|
84
|
+
BreadcrumbLinkOwnProps &
|
|
85
|
+
OtherHTMLAttributes<BreadcrumbLinkOwnProps & LinkProps>
|
|
86
|
+
const allowedProps: AllowedPropKeys = [
|
|
87
|
+
'children',
|
|
88
|
+
'href',
|
|
89
|
+
'iconPlacement',
|
|
90
|
+
'onClick',
|
|
91
|
+
'onMouseEnter',
|
|
92
|
+
'renderIcon',
|
|
93
|
+
'size',
|
|
94
|
+
'isCurrentPage'
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
type BreadcrumbLinkState = {
|
|
98
|
+
isTruncated: boolean
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type { BreadcrumbLinkProps, BreadcrumbLinkState }
|
|
102
|
+
export { allowedProps }
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
describes: Breadcrumb
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Breadcrumbs enable users to quickly see their location within a path of navigation.
|
|
6
|
+
Long breadcrumb text will be automatically truncated, ensuring the list always
|
|
7
|
+
remains on a single line.
|
|
8
|
+
|
|
9
|
+
**Breadcrumbs are best suited for tablet-sized (~768px) screens and larger.**
|
|
10
|
+
For smaller screens, use a [Link](Link) that returns the user to the previous page or view.
|
|
11
|
+
The example below is implemented with [Responsive](Responsive). Resize the browser window to see
|
|
12
|
+
Breadcrumb become a Link at under 768px.
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
---
|
|
16
|
+
type: example
|
|
17
|
+
---
|
|
18
|
+
<Responsive
|
|
19
|
+
query={{
|
|
20
|
+
tablet: { minWidth: 768 }
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
{(props, matches) => {
|
|
24
|
+
if (matches.includes('tablet')) {
|
|
25
|
+
return (
|
|
26
|
+
<Breadcrumb label="breadcrumb">
|
|
27
|
+
<Breadcrumb.Link href="#">Student Forecast</Breadcrumb.Link>
|
|
28
|
+
<Breadcrumb.Link href="#">University of Utah</Breadcrumb.Link>
|
|
29
|
+
<Breadcrumb.Link href="#">University of Utah Colleges</Breadcrumb.Link>
|
|
30
|
+
<Breadcrumb.Link>College of Life Sciences</Breadcrumb.Link>
|
|
31
|
+
</Breadcrumb>
|
|
32
|
+
)
|
|
33
|
+
} else {
|
|
34
|
+
return (
|
|
35
|
+
<Link
|
|
36
|
+
href="#"
|
|
37
|
+
isWithinText={false}
|
|
38
|
+
renderIcon={IconArrowOpenStartLine}
|
|
39
|
+
>
|
|
40
|
+
<TruncateText>University of Utah Colleges</TruncateText>
|
|
41
|
+
</Link>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
}}
|
|
45
|
+
</Responsive>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Change the `size` prop to control the font-size of the breadcrumbs (default is `medium`).
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
---
|
|
52
|
+
type: example
|
|
53
|
+
---
|
|
54
|
+
<div>
|
|
55
|
+
<Breadcrumb size="small" label="breadcrumb" margin="none none medium">
|
|
56
|
+
<Breadcrumb.Link href="https://instructure.github.io/instructure-ui/">English 204</Breadcrumb.Link>
|
|
57
|
+
<Breadcrumb.Link
|
|
58
|
+
onClick={function () {
|
|
59
|
+
console.log("This Breadcrumb.Link was clicked!")
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
Exploring John Updike
|
|
63
|
+
</Breadcrumb.Link>
|
|
64
|
+
<Breadcrumb.Link href="https://instructure.github.io/instructure-ui/">The Rabbit Novels</Breadcrumb.Link>
|
|
65
|
+
<Breadcrumb.Link>Rabbit Is Rich</Breadcrumb.Link>
|
|
66
|
+
</Breadcrumb>
|
|
67
|
+
<View as="div" width="40rem">
|
|
68
|
+
<Breadcrumb label="breadcrumb" margin="none none medium">
|
|
69
|
+
<Breadcrumb.Link href="https://instructure.github.io/instructure-ui/">English 204</Breadcrumb.Link>
|
|
70
|
+
<Breadcrumb.Link
|
|
71
|
+
onClick={function () {
|
|
72
|
+
console.log("This Breadcrumb.Link was clicked!")
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
Exploring John Updike
|
|
76
|
+
</Breadcrumb.Link>
|
|
77
|
+
<Breadcrumb.Link href="https://instructure.github.io/instructure-ui/">The Rabbit Novels</Breadcrumb.Link>
|
|
78
|
+
<Breadcrumb.Link>Rabbit Is Rich</Breadcrumb.Link>
|
|
79
|
+
</Breadcrumb>
|
|
80
|
+
</View>
|
|
81
|
+
<Breadcrumb size="large" label="breadcrumb">
|
|
82
|
+
<Breadcrumb.Link href="https://instructure.github.io/instructure-ui/">English 204</Breadcrumb.Link>
|
|
83
|
+
<Breadcrumb.Link
|
|
84
|
+
onClick={function () {
|
|
85
|
+
console.log("This Breadcrumb.Link was clicked!")
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
Exploring John Updike
|
|
89
|
+
</Breadcrumb.Link>
|
|
90
|
+
<Breadcrumb.Link href="https://instructure.github.io/instructure-ui/">The Rabbit Novels</Breadcrumb.Link>
|
|
91
|
+
<Breadcrumb.Link>Rabbit Is Rich</Breadcrumb.Link>
|
|
92
|
+
</Breadcrumb>
|
|
93
|
+
</div>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Icons
|
|
97
|
+
|
|
98
|
+
You can include icons in `Breadcrumb.Link`:
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
---
|
|
102
|
+
type: example
|
|
103
|
+
---
|
|
104
|
+
<Breadcrumb label="Breadcrumb with icons">
|
|
105
|
+
<Breadcrumb.Link renderIcon={<IconBankLine size="small" />} href="#Breadcrumb">Item Bank</Breadcrumb.Link>
|
|
106
|
+
<Breadcrumb.Link renderIcon={<IconClockLine size="small" />} onClick={() => {}}>History</Breadcrumb.Link>
|
|
107
|
+
<Breadcrumb.Link renderIcon={IconPlusLine} iconPlacement="end">New Question</Breadcrumb.Link>
|
|
108
|
+
</Breadcrumb>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Guidelines
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
---
|
|
115
|
+
type: embed
|
|
116
|
+
---
|
|
117
|
+
<Guidelines>
|
|
118
|
+
<Figure recommendation="yes" title="Do">
|
|
119
|
+
<Figure.Item>Place Breadcrumb near the top of the page</Figure.Item>
|
|
120
|
+
<Figure.Item>Show hierarchy, not history</Figure.Item>
|
|
121
|
+
<Figure.Item>Keep Breadcrumb titles short but descriptive</Figure.Item>
|
|
122
|
+
</Figure>
|
|
123
|
+
<Figure recommendation="no" title="Don't">
|
|
124
|
+
<Figure.Item>Use Breadcrumb if you are taking users through a multi-step process</Figure.Item>
|
|
125
|
+
<Figure.Item>Use Breadcrumb in mobile layouts: use a Link to the previous page/view instead</Figure.Item>
|
|
126
|
+
</Figure>
|
|
127
|
+
</Guidelines>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
---
|
|
132
|
+
type: embed
|
|
133
|
+
---
|
|
134
|
+
<Guidelines>
|
|
135
|
+
<Figure recommendation="a11y" title="Accessibility">
|
|
136
|
+
<Figure.Item>
|
|
137
|
+
To indicate the current element within a breadcrumb, the <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current">aria-current</a> attribute is used. In this component, aria-current="page" will automatically be applied to the last element, and we recommend that the current page always be the last element in the breadcrumb. If the last element is not the current page, the isCurrentPage property should be applied to the relevant Breadcrumb.Link to ensure compatibility with screen readers.
|
|
138
|
+
</Figure.Item>
|
|
139
|
+
</Figure>
|
|
140
|
+
</Guidelines>
|
|
141
|
+
```
|