@yahoo/uds-create-config 4.26.0 → 4.26.2

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,18 @@
1
+ //#region src/spec/glyph-members.d.ts
2
+ /** Library slug → member name → the member, as a component's glyph prop takes it. */
3
+ type GlyphMemberMap<Member> = ReadonlyMap<string, ReadonlyMap<string, Member>>;
4
+ /**
5
+ * The member an `icon:` ref names (`icon:phosphor/StarIcon`, with or without a source qualifier).
6
+ * The member is the last segment of the path; a library nested in a folder keeps the rest as its
7
+ * slug. `undefined` for a value that is not a ref, a ref of another kind, or a library or member the
8
+ * map does not hold.
9
+ */
10
+ declare function glyphMemberFor<Member>({
11
+ ref,
12
+ members
13
+ }: {
14
+ ref: unknown;
15
+ members: GlyphMemberMap<Member>;
16
+ }): Member | undefined;
17
+ //#endregion
18
+ export { GlyphMemberMap, glyphMemberFor };
@@ -0,0 +1,18 @@
1
+ import { isRef, splitRef } from "../framework/utils/ref-grammar.js";
2
+ //#region src/spec/glyph-members.ts
3
+ /**
4
+ * The member an `icon:` ref names (`icon:phosphor/StarIcon`, with or without a source qualifier).
5
+ * The member is the last segment of the path; a library nested in a folder keeps the rest as its
6
+ * slug. `undefined` for a value that is not a ref, a ref of another kind, or a library or member the
7
+ * map does not hold.
8
+ */
9
+ function glyphMemberFor({ ref, members }) {
10
+ if (!isRef(ref)) return void 0;
11
+ const parts = splitRef(ref);
12
+ if (parts.kind !== "icon") return void 0;
13
+ const slash = parts.path.lastIndexOf("/");
14
+ if (slash <= 0) return void 0;
15
+ return members.get(parts.path.slice(0, slash))?.get(parts.path.slice(slash + 1));
16
+ }
17
+ //#endregion
18
+ export { glyphMemberFor };