@ng-native/components 0.22.2 → 0.23.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/android/build.gradle +22 -0
- package/android/src/main/java/dev/ngnative/components/ContextMenuAccessibility.kt +71 -0
- package/android/src/main/java/dev/ngnative/components/ContextMenuGesture.kt +161 -0
- package/android/src/main/java/dev/ngnative/components/ContextMenuPopup.kt +197 -0
- package/android/src/main/java/dev/ngnative/components/MenuHost.kt +45 -0
- package/android/src/main/java/dev/ngnative/components/MenuWindowCallback.kt +76 -0
- package/android/src/main/java/dev/ngnative/components/MenusModule.kt +85 -0
- package/android/src/main/java/dev/ngnative/components/Shortcut.kt +144 -0
- package/android/src/main/java/dev/ngnative/components/WindowWrapper.kt +22 -0
- package/dist/activity-indicator.d.ts +4 -1
- package/dist/activity-indicator.js +6 -2
- package/dist/activity-indicator.js.map +1 -1
- package/dist/context-menu.d.ts +52 -0
- package/dist/context-menu.js +101 -0
- package/dist/context-menu.js.map +1 -0
- package/dist/drag-and-drop.d.ts +52 -0
- package/dist/drag-and-drop.js +112 -0
- package/dist/drag-and-drop.js.map +1 -0
- package/dist/gesture-backend.d.ts +32 -2
- package/dist/gesture-backend.js.map +1 -1
- package/dist/gesture-dispatch.d.ts +8 -1
- package/dist/gesture-dispatch.js +60 -16
- package/dist/gesture-dispatch.js.map +1 -1
- package/dist/gesture-interaction.d.ts +13 -0
- package/dist/gesture-interaction.js +97 -0
- package/dist/gesture-interaction.js.map +1 -0
- package/dist/gesture-tracking.d.ts +18 -0
- package/dist/gesture-tracking.js +28 -0
- package/dist/gesture-tracking.js.map +1 -0
- package/dist/gestures-web.d.ts +3 -1
- package/dist/gestures-web.js +5 -2
- package/dist/gestures-web.js.map +1 -1
- package/dist/gestures.d.ts +1 -0
- package/dist/gestures.js +45 -3
- package/dist/gestures.js.map +1 -1
- package/dist/image.d.ts +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/interaction-observer.d.ts +11 -0
- package/dist/interaction-observer.js +12 -0
- package/dist/interaction-observer.js.map +1 -0
- package/dist/keyboard-avoiding-view.js +3 -3
- package/dist/keyboard-avoiding-view.js.map +1 -1
- package/dist/markdown-stream.d.ts +3 -1
- package/dist/markdown-stream.js +14 -2
- package/dist/markdown-stream.js.map +1 -1
- package/dist/markdown.d.ts +2 -0
- package/dist/markdown.js +5 -3
- package/dist/markdown.js.map +1 -1
- package/dist/menu.d.ts +71 -0
- package/dist/menu.js +193 -0
- package/dist/menu.js.map +1 -0
- package/dist/modal.d.ts +30 -1
- package/dist/modal.js +67 -6
- package/dist/modal.js.map +1 -1
- package/dist/native-button.d.ts +54 -0
- package/dist/native-button.js +100 -0
- package/dist/native-button.js.map +1 -0
- package/dist/native-gesture.d.ts +9 -1
- package/dist/native-gesture.js +32 -3
- package/dist/native-gesture.js.map +1 -1
- package/dist/native-id.d.ts +10 -0
- package/dist/native-id.js +70 -0
- package/dist/native-id.js.map +1 -0
- package/dist/pressable.d.ts +31 -0
- package/dist/pressable.js +102 -9
- package/dist/pressable.js.map +1 -1
- package/dist/safe-area-provider.js +15 -8
- package/dist/safe-area-provider.js.map +1 -1
- package/dist/scroll-view-props.d.ts +7 -1
- package/dist/scroll-view-props.js +54 -3
- package/dist/scroll-view-props.js.map +1 -1
- package/dist/section-list.js +2 -2
- package/dist/section-list.js.map +1 -1
- package/dist/shortcut.d.ts +21 -0
- package/dist/shortcut.js +34 -0
- package/dist/shortcut.js.map +1 -0
- package/dist/sidebar-item.d.ts +53 -0
- package/dist/sidebar-item.js +152 -0
- package/dist/sidebar-item.js.map +1 -0
- package/dist/sidebar-section.d.ts +21 -0
- package/dist/sidebar-section.js +74 -0
- package/dist/sidebar-section.js.map +1 -0
- package/dist/sidebar.d.ts +47 -0
- package/dist/sidebar.js +110 -0
- package/dist/sidebar.js.map +1 -0
- package/dist/split-view.d.ts +63 -0
- package/dist/split-view.js +121 -0
- package/dist/split-view.js.map +1 -0
- package/dist/switch.d.ts +9 -1
- package/dist/switch.js +23 -2
- package/dist/switch.js.map +1 -1
- package/dist/text-input.d.ts +8 -3
- package/dist/text-input.js +10 -4
- package/dist/text-input.js.map +1 -1
- package/dist/transforms.d.ts +5 -0
- package/dist/transforms.js +7 -0
- package/dist/transforms.js.map +1 -1
- package/dist/tray-icon.d.ts +18 -0
- package/dist/tray-icon.js +46 -0
- package/dist/tray-icon.js.map +1 -0
- package/dist/view-base.d.ts +42 -1
- package/dist/view-base.js +67 -39
- package/dist/view-base.js.map +1 -1
- package/dist/virtual-list.js +12 -1
- package/dist/virtual-list.js.map +1 -1
- package/dist/written-props.js +25 -0
- package/dist/written-props.js.map +1 -1
- package/expo-module.config.json +6 -0
- package/ios/NgNativeButtonComponentView.mm +132 -0
- package/ios/NgNativeButtonMetrics.h +28 -0
- package/ios/NgNativeButtonMetrics.mm +68 -0
- package/ios/NgNativeButtonShadowNode.h +65 -0
- package/ios/NgNativeButtonShadowNode.mm +40 -0
- package/ios/NgNativeComponents.podspec +28 -0
- package/ios/NgNativeDragAndDrop.mm +342 -0
- package/ios/NgNativeDropItems.h +29 -0
- package/ios/NgNativeDropItems.mm +55 -0
- package/ios/NgNativeMenuBuilding.h +40 -0
- package/ios/NgNativeMenuBuilding.mm +217 -0
- package/ios/NgNativeMenus.mm +320 -0
- package/ios/NgNativeResponderHooks.h +53 -0
- package/ios/NgNativeResponderHooks.mm +215 -0
- package/ios/NgNativeSceneKeys.h +36 -0
- package/ios/NgNativeSceneKeys.mm +56 -0
- package/ios/NgNativeSplitView.mm +433 -0
- package/ios/NgNativeSplitViewDelegate.h +29 -0
- package/ios/NgNativeSplitViewDelegate.mm +122 -0
- package/ios/NgNativeSplitViewShadowNodes.h +115 -0
- package/ios/NgNativeSplitViewShadowNodes.mm +31 -0
- package/ios/NgNativeUndo.mm +107 -0
- package/ios/NgNativeUndoSteps.h +17 -0
- package/ios/NgNativeUndoSteps.mm +22 -0
- package/ios/NgNativeViewBinder.h +54 -0
- package/ios/NgNativeViewBinder.mm +225 -0
- package/ios/NgNativeWindows.mm +1126 -0
- package/package.json +13 -5
package/dist/markdown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,SAAS,EACT,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,KAAK,EACL,YAAY,EACZ,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAc,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,cAAc,EACd,YAAY,EACZ,WAAW,GAKZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;;AAgBjC;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,cAAc,CACrD,uBAAuB,EACvB,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAC1C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAG,OAA0B;IACtE,OAAO,EAAE,OAAO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AS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1F,CAAC;uGA7LU,QAAQ;2FAAR,QAAQ,q2BAhIT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyHT,6uFA1HS,KAAK,mTAAE,eAAe,0HAAE,UAAU,0TAAE,YAAY,4GAAE,IAAI,mYAAE,IAAI;;2FAiI3D,QAAQ;kBAnIpB,SAAS;+BACE,UAAU,WACX,CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,YAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyHT,QAEK;wBACJ,gBAAgB,EAAE,oBAAoB;wBACtC,oBAAoB,EAAE,wBAAwB;qBAC/C","sourcesContent":["/**\n * Markdown, drawn as native views and text.\n *\n * Its own entry point because it parses with `marked`, an optional peer dependency an app installs\n * only when it renders Markdown: the barrel never imports it, so an app that does not is not asked\n * for it.\n *\n * ```ts\n * import { Markdown } from '@ng-native/components/markdown';\n * ```\n */\nimport {\n Component,\n Injector,\n InjectionToken,\n booleanAttribute,\n computed,\n inject,\n input,\n linkedSignal,\n output,\n type Provider,\n} from '@angular/core';\nimport { DeepLinks } from '@ng-native/device';\nimport { nativePlatform } from '@ng-native/fabric';\nimport { lexer, type Token } from 'marked';\nimport type { ImageLoadEvent, LayoutEvent } from './events.ts';\nimport { Image } from './image.ts';\nimport {\n blockKey,\n linkSchemeSet,\n markdownBlocks,\n opensOnPress,\n shareBlocks,\n type AppLinkSchemes,\n type MarkdownBlock,\n type MarkdownElement,\n type MarkdownInline,\n} from './markdown-blocks.ts';\nimport { MarkdownColumns } from './markdown-columns.ts';\nimport { MarkdownStream } from './markdown-stream.ts';\nimport { ScrollView } from './scroll-view.ts';\nimport { TemplateSlot } from './template-slot.ts';\nimport { Text } from './text.ts';\nimport { View } from './view.ts';\n\nexport type { MarkdownElement } from './markdown-blocks.ts';\n\n/** Classes for the elements a document is drawn with, each one in place of the default. */\nexport type MarkdownClasses = Partial<Readonly<Record<MarkdownElement, string>>>;\n\n/** `(linkPress)`: a link was pressed. */\nexport interface MarkdownLinkPress {\n /** The target as written, after its entities are decoded and its scheme was allowed. */\n readonly href: string;\n readonly title: string | null;\n /** Keep the link from being opened, to handle it in the app instead. */\n preventDefault(): void;\n}\n\n/**\n * The schemes, beyond `http`, `https`, `mailto` and `tel`, that every `<markdown>` draws links in\n * unless its own `linkSchemes` is set. See `provideMarkdownLinkSchemes`.\n */\nexport const MARKDOWN_LINK_SCHEMES = new InjectionToken<readonly string[]>(\n 'MARKDOWN_LINK_SCHEMES',\n { providedIn: 'root', factory: () => [] },\n);\n\n/**\n * Make links in the app's own schemes links in every `<markdown>`, such as `myapp:item/42`:\n * drawn as links and reported through `(linkPress)`, and never opened by default. A\n * `[linkSchemes]` input on one `<markdown>` replaces this list for that one.\n *\n * ```ts\n * providers: [provideMarkdownLinkSchemes('myapp')]\n * ```\n */\nexport function provideMarkdownLinkSchemes(...schemes: readonly string[]): Provider {\n return { provide: MARKDOWN_LINK_SCHEMES, useValue: schemes };\n}\n\nconst ELEMENTS: readonly MarkdownElement[] = [\n ...['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'blockquote', 'ul', 'ol', 'li', 'marker'],\n ...['pre', 'code', 'strong', 'em', 'del', 'a', 'hr', 'img', 'table', 'tr', 'th', 'td'],\n] as MarkdownElement[];\n\nconst DEFAULT_CLASSES = Object.fromEntries(\n ELEMENTS.map((element) => [element, `md-${element}`]),\n) as Readonly<Record<MarkdownElement, string>>;\n\ntype MarkdownLink = Extract<MarkdownInline, { kind: 'link' }>;\n\n/** A loaded image's own width in points, and its width over its height. */\ninterface ImageSize {\n readonly width: number;\n readonly ratio: number;\n}\n\ntype ImageBlock = Extract<MarkdownBlock, { kind: 'image' }>;\n\n/** Every image in `blocks`, however deep in quotes and lists. */\nfunction imageBlocks(\n blocks: readonly MarkdownBlock[],\n into = new Set<ImageBlock>(),\n): Set<ImageBlock> {\n for (const block of blocks) {\n if (block.kind === 'image') into.add(block);\n else if (block.kind === 'blockquote') imageBlocks(block.children, into);\n else if (block.kind === 'list') {\n for (const item of block.items) imageBlocks(item.children, into);\n }\n }\n return into;\n}\n\n/**\n * A Markdown document as `<text>`, `<view>`, `<image>` and `<scroll-view>`: headings, paragraphs,\n * emphasis, inline code, links, quotes, ordered, unordered and task lists, code blocks, rules,\n * tables and images.\n *\n * `source` is parsed with `marked.lexer`; `tokens` takes tokens lexed already, and wins when both\n * are set. A paragraph is one `<text>` with a nested `<text>` for each emphasis, code span and\n * link, so it wraps as one run; an image is lifted out to a block of its own.\n *\n * Nothing in the document is interpreted. Raw HTML is drawn as the text it is written as, a link\n * is followed only to `http`, `https`, `mailto`, `tel` or a relative target, and an image is\n * loaded only over `http` or `https`; anything else is drawn as its text.\n *\n * Each element carries a default class, `md-h1`, `md-p`, `md-a` and so on, styled in light and\n * dark. `classes` replaces one by its element's name, so a global stylesheet or Tailwind styles it\n * instead: `{ h1: 'text-3xl font-bold' }`. Put the default back beside your own to keep both.\n *\n * For a source that grows as it streams in, an answer arriving a few words at a time, set\n * `streaming` until it is complete. The blocks before the last one are then kept as they are and\n * only the last is lexed and converted again, unless a chunk defines or changes a link reference,\n * which can change a block already kept, and the whole source is lexed again. Syntax still open at its end, a code span, an emphasis, a link,\n * an image or a table row, is held back until it closes. Of a code fence only an unfinished\n * opening line is held back, and its code then streams as it arrives. Clearing `streaming` draws\n * the whole source as written, and `tokens` are always drawn as given. A block that did not\n * change keeps its views, streaming or not.\n *\n * A pressed link is `(linkPress)`. An absolute target is then opened with `DeepLinks.open` unless\n * a handler calls `preventDefault()`; a relative one is only reported, for the app to route.\n *\n * A link in the app's own scheme, `myapp:item/42`, is drawn as plain text unless the scheme is\n * listed in `linkSchemes`, or app-wide with `provideMarkdownLinkSchemes`. A listed scheme is drawn\n * as a link and reported through `(linkPress)`, and is never opened: the app routes it. The input\n * replaces the provider's list when it is set, even to an empty one. Schemes are matched without\n * regard to case, and the list is read as a value: give a new array to change it.\n */\n@Component({\n selector: 'markdown',\n imports: [Image, MarkdownColumns, ScrollView, TemplateSlot, Text, View],\n template: `\n <ng-template #blockTemplate let-list>\n @for (block of list; track blockKey(block)) {\n @switch (block.kind) {\n @case ('heading') {\n <text [class]=\"classFor(block.element)\" accessibilityRole=\"header\"\n ><ng-container *templateSlot=\"inlineTemplate; context: { $implicit: block.children }\"\n /></text>\n }\n @case ('paragraph') {\n <text [class]=\"classFor('p')\"\n ><ng-container *templateSlot=\"inlineTemplate; context: { $implicit: block.children }\"\n /></text>\n }\n @case ('image') {\n <image\n [src]=\"block.src\"\n [alt]=\"block.alt || undefined\"\n resizeMode=\"contain\"\n [class]=\"classFor('img')\"\n [style.--md-img-width]=\"imageWidth(block.src)\"\n [style.aspectRatio]=\"sizes().get(block.src)?.ratio ?? null\"\n [style.height]=\"imageHeight(block)\"\n (load)=\"sizeImage(block.src, $any($event))\"\n (layout)=\"layOutImage(block, $any($event))\"\n />\n }\n @case ('blockquote') {\n <view [class]=\"classFor('blockquote')\">\n <ng-container *templateSlot=\"blockTemplate; context: { $implicit: block.children }\" />\n </view>\n }\n @case ('list') {\n <view [class]=\"classFor(block.element)\">\n @for (item of block.items; track $index) {\n <view [class]=\"classFor('li')\">\n <text [class]=\"classFor('marker')\">{{ item.marker }}</text>\n <view class=\"md-li-body\">\n <ng-container\n *templateSlot=\"blockTemplate; context: { $implicit: item.children }\"\n />\n </view>\n </view>\n }\n </view>\n }\n @case ('code') {\n <scroll-view horizontal [class]=\"classFor('pre')\">\n <text selectable class=\"md-pre-text\">{{ block.text }}</text>\n </scroll-view>\n }\n @case ('hr') {\n <view [class]=\"classFor('hr')\"></view>\n }\n @case ('table') {\n <scroll-view horizontal>\n <view\n [class]=\"classFor('table')\"\n [markdownColumns]=\"block\"\n #columns=\"markdownColumns\"\n >\n <view [class]=\"classFor('tr')\">\n @for (cell of block.header; track $index; let column = $index) {\n <view class=\"md-cell\" [style.minWidth]=\"columns.width(column)\">\n <text\n [class]=\"classFor('th')\"\n (layout)=\"columns.measure(0, column, $any($event))\"\n ><ng-container *templateSlot=\"inlineTemplate; context: { $implicit: cell }\"\n /></text>\n </view>\n }\n </view>\n @for (row of block.rows; track $index; let r = $index) {\n <view [class]=\"classFor('tr')\">\n @for (cell of row; track $index; let column = $index) {\n <view class=\"md-cell md-cell-body\" [style.minWidth]=\"columns.width(column)\">\n <text\n [class]=\"classFor('td')\"\n (layout)=\"columns.measure(r + 1, column, $any($event))\"\n ><ng-container\n *templateSlot=\"inlineTemplate; context: { $implicit: cell }\"\n /></text>\n </view>\n }\n </view>\n }\n </view>\n </scroll-view>\n }\n }\n }\n </ng-template>\n\n <ng-template #inlineTemplate let-runs>\n @for (run of runs; track $index) {\n @switch (run.kind) {\n @case ('text') {\n <ng-container>{{ run.text }}</ng-container>\n }\n @case ('code') {\n <text [class]=\"classFor('code')\">{{ run.text }}</text>\n }\n @case ('link') {\n <text\n [class]=\"classFor('a')\"\n pressable\n [accessibilityHint]=\"run.title ?? undefined\"\n (press)=\"followLink(run)\"\n ><ng-container *templateSlot=\"inlineTemplate; context: { $implicit: run.children }\"\n /></text>\n }\n @default {\n <text [class]=\"classFor(run.kind)\"\n ><ng-container *templateSlot=\"inlineTemplate; context: { $implicit: run.children }\"\n /></text>\n }\n }\n }\n </ng-template>\n\n <ng-container *templateSlot=\"blockTemplate; context: { $implicit: blocks() }\" />\n `,\n styleUrl: './markdown.css',\n host: {\n '[class.md-ios]': \"platform === 'ios'\",\n '[class.md-android]': \"platform === 'android'\",\n },\n})\nexport class Markdown {\n private readonly injector = inject(Injector);\n /** Which monospace font code is drawn in, as the platform names it. */\n protected readonly platform = nativePlatform();\n\n /** The Markdown to draw. */\n readonly source = input<string>();\n /** Tokens `marked.lexer` made already, drawn in place of `source`. */\n readonly tokens = input<readonly Token[]>();\n /**\n * Whether `source` is still arriving, a chunk at a time. While it is, only its last block is\n * lexed again, unless a link reference changes, and syntax still open at its end is held back.\n * See the class note.\n */\n readonly streaming = input(false, { transform: booleanAttribute });\n /**\n * Schemes besides `http`, `https`, `mailto` and `tel` whose links are drawn as links and\n * reported through `(linkPress)`, never opened. Replaces `provideMarkdownLinkSchemes` when set.\n * See the class note.\n */\n readonly linkSchemes = input<readonly string[]>();\n /** A class for an element, in place of its default. See the class note. */\n readonly classes = input<MarkdownClasses>({});\n /** A link was pressed. See the class note. */\n readonly linkPress = output<MarkdownLinkPress>();\n\n private readonly stream = new MarkdownStream();\n protected readonly blockKey = blockKey;\n\n /**\n * The blocks each token the stream kept was drawn as. A kept token is the same object from one\n * chunk to the next, so its blocks are not converted or compared again; a source lexed whole\n * makes new tokens, and so new blocks.\n */\n private streamed = new WeakMap<Token, readonly MarkdownBlock[]>();\n /** The schemes `streamed` was converted with; its blocks are stale once they change. */\n private streamedFor: AppLinkSchemes | undefined;\n\n private readonly providedSchemes = inject(MARKDOWN_LINK_SCHEMES);\n\n /** The schemes links are drawn in, the same set while the list reads the same. */\n private readonly appSchemes = computed(\n () => linkSchemeSet(this.linkSchemes() ?? this.providedSchemes),\n { equal: (a, b) => a.size === b.size && [...a].every((scheme) => b.has(scheme)) },\n );\n\n private readonly lexed = computed(() => {\n const tokens = this.tokens();\n if (tokens) return { tokens, streamed: false };\n const streamed = this.streaming();\n return { tokens: this.lex(this.source() ?? '', streamed), streamed };\n });\n\n /** The document's blocks, with each one that did not change kept, so it is not drawn again. */\n protected readonly blocks = linkedSignal({\n source: () => ({ ...this.lexed(), schemes: this.appSchemes() }),\n computation: ({ tokens, streamed, schemes }, previous?: { value: readonly MarkdownBlock[] }) =>\n streamed\n ? this.streamedBlocks(tokens, previous?.value, schemes)\n : shareBlocks(previous?.value, markdownBlocks(tokens, schemes)),\n });\n\n private readonly classOf = computed(() => ({ ...DEFAULT_CLASSES, ...this.classes() }));\n\n /**\n * Each image's own width and its width over its height, once it has loaded, so it is drawn at its\n * own size and shape, as a browser draws it, and no wider than the document. The width reaches\n * the image as `--md-img-width`, which `.md-img` reads, so a class of the app's own still sets\n * the width. An image the document no longer has is forgotten when the document changes.\n */\n protected readonly sizes = linkedSignal<readonly MarkdownBlock[], ReadonlyMap<string, ImageSize>>(\n {\n source: this.blocks,\n computation: (blocks, previous) => {\n const kept = new Map<string, ImageSize>();\n if (!previous) return kept;\n const present = new Set([...imageBlocks(blocks)].map((block) => block.src));\n for (const [src, size] of previous.value) if (present.has(src)) kept.set(src, size);\n return kept;\n },\n },\n );\n\n /**\n * The width each image is laid out at where that is less than its own, narrowed by\n * `max-width`. Yoga takes an image's height from its width before `max-width` narrows it, where\n * CSS takes it after, so a narrowed image is given the height its ratio makes of the width it\n * has. An image no longer in the document is forgotten when the document changes.\n */\n protected readonly narrowed = linkedSignal<\n readonly MarkdownBlock[],\n ReadonlyMap<ImageBlock, number>\n >({\n source: this.blocks,\n computation: (blocks, previous) => {\n const kept = new Map<ImageBlock, number>();\n if (!previous) return kept;\n const present = imageBlocks(blocks);\n for (const [block, width] of previous.value) if (present.has(block)) kept.set(block, width);\n return kept;\n },\n });\n\n private lex(source: string, streaming: boolean): readonly Token[] {\n return streaming ? this.stream.lex(source) : lexer(source);\n }\n\n /** `tokens`' blocks, converting and sharing only those of tokens the stream had not kept. */\n private streamedBlocks(\n tokens: readonly Token[],\n previous: readonly MarkdownBlock[] | undefined,\n schemes: AppLinkSchemes,\n ): readonly MarkdownBlock[] {\n if (this.streamedFor !== schemes) {\n this.streamed = new WeakMap();\n this.streamedFor = schemes;\n }\n const kept: MarkdownBlock[] = [];\n let at = 0;\n for (; at < tokens.length; at++) {\n const blocks = this.streamed.get(tokens[at]!);\n if (!blocks) break;\n kept.push(...blocks);\n }\n const rest = tokens.slice(at);\n const converted = rest.map((token) => markdownBlocks([token], schemes));\n // The blocks drawn after the kept ones, when those are still the ones drawn first.\n const drawn = !kept.length || previous?.[kept.length - 1] === kept.at(-1);\n const was = drawn ? previous?.slice(kept.length) : undefined;\n const shared = shareBlocks(was, converted.flat());\n let from = 0;\n rest.forEach((token, i) => {\n const count = converted[i]!.length;\n this.streamed.set(token, shared.slice(from, (from += count)));\n });\n return [...kept, ...shared];\n }\n\n protected classFor(element: MarkdownElement): string {\n return this.classOf()[element];\n }\n\n protected imageWidth(src: string): string | null {\n const size = this.sizes().get(src);\n return size ? `${size.width}px` : null;\n }\n\n /** The class's height until the image loads, then its ratio's, or a narrowed image's own. */\n protected imageHeight(block: ImageBlock): number | 'auto' | null {\n const size = this.sizes().get(block.src);\n if (!size) return null;\n const width = this.narrowed().get(block);\n return width === undefined ? 'auto' : width / size.ratio;\n }\n\n protected layOutImage(block: ImageBlock, event: Partial<LayoutEvent>): void {\n const width = event.nativeEvent?.layout?.width;\n const size = this.sizes().get(block.src);\n if (width === undefined || !size) return;\n const narrowed = width < size.width ? width : undefined;\n if (this.narrowed().get(block) === narrowed) return;\n this.narrowed.update((all) => {\n const next = new Map(all);\n if (narrowed === undefined) next.delete(block);\n else next.set(block, narrowed);\n return next;\n });\n }\n\n protected sizeImage(src: string, event: Partial<ImageLoadEvent>): void {\n const source = event.nativeEvent?.source;\n if (!source) return;\n const { width, height } = source;\n if (!(width > 0 && height > 0)) return;\n // A url's or a data url's scale is 1, so the load event's pixels are the points a browser's\n // CSS pixels are.\n this.sizes.update((sizes) => new Map(sizes).set(src, { width, ratio: width / height }));\n }\n\n protected followLink(link: MarkdownLink): void {\n let prevented = false;\n this.linkPress.emit({\n href: link.href,\n title: link.title,\n preventDefault: () => {\n prevented = true;\n },\n });\n if (!prevented && opensOnPress(link.href)) this.injector.get(DeepLinks).open(link.href);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"markd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,w1BAhIT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyHT,6uFA1HS,KAAK,mTAAE,eAAe,0HAAE,UAAU,0TAAE,YAAY,4GAAE,IAAI,mYAAE,IAAI;;2FAiI3D,QAAQ;kBAnIpB,SAAS;+BACE,UAAU,WACX,CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,YAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyHT,QAEK;wBACJ,gBAAgB,EAAE,OAAO;wBACzB,oBAAoB,EAAE,wBAAwB;qBAC/C","sourcesContent":["/**\n * Markdown, drawn as native views and text.\n *\n * Its own entry point because it parses with `marked`, an optional peer dependency an app installs\n * only when it renders Markdown: the barrel never imports it, so an app that does not is not asked\n * for it.\n *\n * ```ts\n * import { Markdown } from '@ng-native/components/markdown';\n * ```\n */\nimport {\n Component,\n Injector,\n InjectionToken,\n booleanAttribute,\n computed,\n inject,\n input,\n linkedSignal,\n output,\n type Provider,\n} from '@angular/core';\nimport { DeepLinks } from '@ng-native/device';\nimport { isApplePlatform, nativePlatform } from '@ng-native/fabric';\nimport { lexer, type Token } from 'marked';\nimport type { ImageLoadEvent, LayoutEvent } from './events.ts';\nimport { Image } from './image.ts';\nimport {\n blockKey,\n linkSchemeSet,\n markdownBlocks,\n opensOnPress,\n shareBlocks,\n type AppLinkSchemes,\n type MarkdownBlock,\n type MarkdownElement,\n type MarkdownInline,\n} from './markdown-blocks.ts';\nimport { MarkdownColumns } from './markdown-columns.ts';\nimport { MarkdownStream } from './markdown-stream.ts';\nimport { ScrollView } from './scroll-view.ts';\nimport { TemplateSlot } from './template-slot.ts';\nimport { Text } from './text.ts';\nimport { View } from './view.ts';\n\nexport type { MarkdownElement } from './markdown-blocks.ts';\n\n/** Classes for the elements a document is drawn with, each one in place of the default. */\nexport type MarkdownClasses = Partial<Readonly<Record<MarkdownElement, string>>>;\n\n/** `(linkPress)`: a link was pressed. */\nexport interface MarkdownLinkPress {\n /** The target as written, after its entities are decoded and its scheme was allowed. */\n readonly href: string;\n readonly title: string | null;\n /** Keep the link from being opened, to handle it in the app instead. */\n preventDefault(): void;\n}\n\n/**\n * The schemes, beyond `http`, `https`, `mailto` and `tel`, that every `<markdown>` draws links in\n * unless its own `linkSchemes` is set. See `provideMarkdownLinkSchemes`.\n */\nexport const MARKDOWN_LINK_SCHEMES = new InjectionToken<readonly string[]>(\n 'MARKDOWN_LINK_SCHEMES',\n { providedIn: 'root', factory: () => [] },\n);\n\n/**\n * Make links in the app's own schemes links in every `<markdown>`, such as `myapp:item/42`:\n * drawn as links and reported through `(linkPress)`, and never opened by default. A\n * `[linkSchemes]` input on one `<markdown>` replaces this list for that one.\n *\n * ```ts\n * providers: [provideMarkdownLinkSchemes('myapp')]\n * ```\n */\nexport function provideMarkdownLinkSchemes(...schemes: readonly string[]): Provider {\n return { provide: MARKDOWN_LINK_SCHEMES, useValue: schemes };\n}\n\nconst ELEMENTS: readonly MarkdownElement[] = [\n ...['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'blockquote', 'ul', 'ol', 'li', 'marker'],\n ...['pre', 'code', 'strong', 'em', 'del', 'a', 'hr', 'img', 'table', 'tr', 'th', 'td'],\n] as MarkdownElement[];\n\nconst DEFAULT_CLASSES = Object.fromEntries(\n ELEMENTS.map((element) => [element, `md-${element}`]),\n) as Readonly<Record<MarkdownElement, string>>;\n\ntype MarkdownLink = Extract<MarkdownInline, { kind: 'link' }>;\n\n/** A loaded image's own width in points, and its width over its height. */\ninterface ImageSize {\n readonly width: number;\n readonly ratio: number;\n}\n\ntype ImageBlock = Extract<MarkdownBlock, { kind: 'image' }>;\n\n/** Every image in `blocks`, however deep in quotes and lists. */\nfunction imageBlocks(\n blocks: readonly MarkdownBlock[],\n into = new Set<ImageBlock>(),\n): Set<ImageBlock> {\n for (const block of blocks) {\n if (block.kind === 'image') into.add(block);\n else if (block.kind === 'blockquote') imageBlocks(block.children, into);\n else if (block.kind === 'list') {\n for (const item of block.items) imageBlocks(item.children, into);\n }\n }\n return into;\n}\n\n/**\n * A Markdown document as `<text>`, `<view>`, `<image>` and `<scroll-view>`: headings, paragraphs,\n * emphasis, inline code, links, quotes, ordered, unordered and task lists, code blocks, rules,\n * tables and images.\n *\n * `source` is parsed with `marked.lexer`; `tokens` takes tokens lexed already, and wins when both\n * are set. A paragraph is one `<text>` with a nested `<text>` for each emphasis, code span and\n * link, so it wraps as one run; an image is lifted out to a block of its own.\n *\n * Nothing in the document is interpreted. Raw HTML is drawn as the text it is written as, a link\n * is followed only to `http`, `https`, `mailto`, `tel` or a relative target, and an image is\n * loaded only over `http` or `https`; anything else is drawn as its text.\n *\n * Each element carries a default class, `md-h1`, `md-p`, `md-a` and so on, styled in light and\n * dark. `classes` replaces one by its element's name, so a global stylesheet or Tailwind styles it\n * instead: `{ h1: 'text-3xl font-bold' }`. Put the default back beside your own to keep both.\n *\n * For a source that grows as it streams in, an answer arriving a few words at a time, set\n * `streaming` until it is complete. The blocks before the last one are then kept as they are and\n * only the last is lexed and converted again, unless a chunk defines or changes a link reference,\n * which can change a block already kept, and the whole source is lexed again. Syntax still open at its end, a code span, an emphasis, a link,\n * an image or a table row, is held back until it closes. Of a code fence only an unfinished\n * opening line is held back, and its code then streams as it arrives. Clearing `streaming` draws\n * the whole source as written, and `tokens` are always drawn as given. A block that did not\n * change keeps its views, streaming or not.\n *\n * A pressed link is `(linkPress)`. An absolute target is then opened with `DeepLinks.open` unless\n * a handler calls `preventDefault()`; a relative one is only reported, for the app to route.\n *\n * A link in the app's own scheme, `myapp:item/42`, is drawn as plain text unless the scheme is\n * listed in `linkSchemes`, or app-wide with `provideMarkdownLinkSchemes`. A listed scheme is drawn\n * as a link and reported through `(linkPress)`, and is never opened: the app routes it. The input\n * replaces the provider's list when it is set, even to an empty one. Schemes are matched without\n * regard to case, and the list is read as a value: give a new array to change it.\n */\n@Component({\n selector: 'markdown',\n imports: [Image, MarkdownColumns, ScrollView, TemplateSlot, Text, View],\n template: `\n <ng-template #blockTemplate let-list>\n @for (block of list; track blockKey(block)) {\n @switch (block.kind) {\n @case ('heading') {\n <text [class]=\"classFor(block.element)\" accessibilityRole=\"header\"\n ><ng-container *templateSlot=\"inlineTemplate; context: { $implicit: block.children }\"\n /></text>\n }\n @case ('paragraph') {\n <text [class]=\"classFor('p')\"\n ><ng-container *templateSlot=\"inlineTemplate; context: { $implicit: block.children }\"\n /></text>\n }\n @case ('image') {\n <image\n [src]=\"block.src\"\n [alt]=\"block.alt || undefined\"\n resizeMode=\"contain\"\n [class]=\"classFor('img')\"\n [style.--md-img-width]=\"imageWidth(block.src)\"\n [style.aspectRatio]=\"sizes().get(block.src)?.ratio ?? null\"\n [style.height]=\"imageHeight(block)\"\n (load)=\"sizeImage(block.src, $any($event))\"\n (layout)=\"layOutImage(block, $any($event))\"\n />\n }\n @case ('blockquote') {\n <view [class]=\"classFor('blockquote')\">\n <ng-container *templateSlot=\"blockTemplate; context: { $implicit: block.children }\" />\n </view>\n }\n @case ('list') {\n <view [class]=\"classFor(block.element)\">\n @for (item of block.items; track $index) {\n <view [class]=\"classFor('li')\">\n <text [class]=\"classFor('marker')\">{{ item.marker }}</text>\n <view class=\"md-li-body\">\n <ng-container\n *templateSlot=\"blockTemplate; context: { $implicit: item.children }\"\n />\n </view>\n </view>\n }\n </view>\n }\n @case ('code') {\n <scroll-view horizontal [class]=\"classFor('pre')\">\n <text selectable class=\"md-pre-text\">{{ block.text }}</text>\n </scroll-view>\n }\n @case ('hr') {\n <view [class]=\"classFor('hr')\"></view>\n }\n @case ('table') {\n <scroll-view horizontal>\n <view\n [class]=\"classFor('table')\"\n [markdownColumns]=\"block\"\n #columns=\"markdownColumns\"\n >\n <view [class]=\"classFor('tr')\">\n @for (cell of block.header; track $index; let column = $index) {\n <view class=\"md-cell\" [style.minWidth]=\"columns.width(column)\">\n <text\n [class]=\"classFor('th')\"\n (layout)=\"columns.measure(0, column, $any($event))\"\n ><ng-container *templateSlot=\"inlineTemplate; context: { $implicit: cell }\"\n /></text>\n </view>\n }\n </view>\n @for (row of block.rows; track $index; let r = $index) {\n <view [class]=\"classFor('tr')\">\n @for (cell of row; track $index; let column = $index) {\n <view class=\"md-cell md-cell-body\" [style.minWidth]=\"columns.width(column)\">\n <text\n [class]=\"classFor('td')\"\n (layout)=\"columns.measure(r + 1, column, $any($event))\"\n ><ng-container\n *templateSlot=\"inlineTemplate; context: { $implicit: cell }\"\n /></text>\n </view>\n }\n </view>\n }\n </view>\n </scroll-view>\n }\n }\n }\n </ng-template>\n\n <ng-template #inlineTemplate let-runs>\n @for (run of runs; track $index) {\n @switch (run.kind) {\n @case ('text') {\n <ng-container>{{ run.text }}</ng-container>\n }\n @case ('code') {\n <text [class]=\"classFor('code')\">{{ run.text }}</text>\n }\n @case ('link') {\n <text\n [class]=\"classFor('a')\"\n pressable\n [accessibilityHint]=\"run.title ?? undefined\"\n (press)=\"followLink(run)\"\n ><ng-container *templateSlot=\"inlineTemplate; context: { $implicit: run.children }\"\n /></text>\n }\n @default {\n <text [class]=\"classFor(run.kind)\"\n ><ng-container *templateSlot=\"inlineTemplate; context: { $implicit: run.children }\"\n /></text>\n }\n }\n }\n </ng-template>\n\n <ng-container *templateSlot=\"blockTemplate; context: { $implicit: blocks() }\" />\n `,\n styleUrl: './markdown.css',\n host: {\n '[class.md-ios]': 'apple',\n '[class.md-android]': \"platform === 'android'\",\n },\n})\nexport class Markdown {\n private readonly injector = inject(Injector);\n /** Which monospace font code is drawn in, as the platform names it. */\n protected readonly platform = nativePlatform();\n /** Menlo, which iOS and macOS both have. */\n protected readonly apple = isApplePlatform();\n\n /** The Markdown to draw. */\n readonly source = input<string>();\n /** Tokens `marked.lexer` made already, drawn in place of `source`. */\n readonly tokens = input<readonly Token[]>();\n /**\n * Whether `source` is still arriving, a chunk at a time. While it is, only its last block is\n * lexed again, unless a link reference changes, and syntax still open at its end is held back.\n * See the class note.\n */\n readonly streaming = input(false, { transform: booleanAttribute });\n /**\n * Schemes besides `http`, `https`, `mailto` and `tel` whose links are drawn as links and\n * reported through `(linkPress)`, never opened. Replaces `provideMarkdownLinkSchemes` when set.\n * See the class note.\n */\n readonly linkSchemes = input<readonly string[]>();\n /** A class for an element, in place of its default. See the class note. */\n readonly classes = input<MarkdownClasses>({});\n /** A link was pressed. See the class note. */\n readonly linkPress = output<MarkdownLinkPress>();\n\n private readonly stream = new MarkdownStream();\n protected readonly blockKey = blockKey;\n\n /**\n * The blocks each token the stream kept was drawn as. A kept token is the same object from one\n * chunk to the next, so its blocks are not converted or compared again; a source lexed whole\n * makes new tokens, and so new blocks.\n */\n private streamed = new WeakMap<Token, readonly MarkdownBlock[]>();\n /** The schemes `streamed` was converted with; its blocks are stale once they change. */\n private streamedFor: AppLinkSchemes | undefined;\n\n private readonly providedSchemes = inject(MARKDOWN_LINK_SCHEMES);\n\n /** The schemes links are drawn in, the same set while the list reads the same. */\n private readonly appSchemes = computed(\n () => linkSchemeSet(this.linkSchemes() ?? this.providedSchemes),\n { equal: (a, b) => a.size === b.size && [...a].every((scheme) => b.has(scheme)) },\n );\n\n private readonly lexed = computed(() => {\n const tokens = this.tokens();\n if (tokens) return { tokens, streamed: false };\n const streamed = this.streaming();\n return { tokens: this.lex(this.source() ?? '', streamed), streamed };\n });\n\n /** The document's blocks, with each one that did not change kept, so it is not drawn again. */\n protected readonly blocks = linkedSignal({\n source: () => ({ ...this.lexed(), schemes: this.appSchemes() }),\n computation: ({ tokens, streamed, schemes }, previous?: { value: readonly MarkdownBlock[] }) =>\n streamed\n ? this.streamedBlocks(tokens, previous?.value, schemes)\n : shareBlocks(previous?.value, markdownBlocks(tokens, schemes)),\n });\n\n private readonly classOf = computed(() => ({ ...DEFAULT_CLASSES, ...this.classes() }));\n\n /**\n * Each image's own width and its width over its height, once it has loaded, so it is drawn at its\n * own size and shape, as a browser draws it, and no wider than the document. The width reaches\n * the image as `--md-img-width`, which `.md-img` reads, so a class of the app's own still sets\n * the width. An image the document no longer has is forgotten when the document changes.\n */\n protected readonly sizes = linkedSignal<readonly MarkdownBlock[], ReadonlyMap<string, ImageSize>>(\n {\n source: this.blocks,\n computation: (blocks, previous) => {\n const kept = new Map<string, ImageSize>();\n if (!previous) return kept;\n const present = new Set([...imageBlocks(blocks)].map((block) => block.src));\n for (const [src, size] of previous.value) if (present.has(src)) kept.set(src, size);\n return kept;\n },\n },\n );\n\n /**\n * The width each image is laid out at where that is less than its own, narrowed by\n * `max-width`. Yoga takes an image's height from its width before `max-width` narrows it, where\n * CSS takes it after, so a narrowed image is given the height its ratio makes of the width it\n * has. An image no longer in the document is forgotten when the document changes.\n */\n protected readonly narrowed = linkedSignal<\n readonly MarkdownBlock[],\n ReadonlyMap<ImageBlock, number>\n >({\n source: this.blocks,\n computation: (blocks, previous) => {\n const kept = new Map<ImageBlock, number>();\n if (!previous) return kept;\n const present = imageBlocks(blocks);\n for (const [block, width] of previous.value) if (present.has(block)) kept.set(block, width);\n return kept;\n },\n });\n\n private lex(source: string, streaming: boolean): readonly Token[] {\n return streaming ? this.stream.lex(source) : lexer(source);\n }\n\n /** `tokens`' blocks, converting and sharing only those of tokens the stream had not kept. */\n private streamedBlocks(\n tokens: readonly Token[],\n previous: readonly MarkdownBlock[] | undefined,\n schemes: AppLinkSchemes,\n ): readonly MarkdownBlock[] {\n if (this.streamedFor !== schemes) {\n this.streamed = new WeakMap();\n this.streamedFor = schemes;\n }\n const kept: MarkdownBlock[] = [];\n let at = 0;\n for (; at < tokens.length; at++) {\n const blocks = this.streamed.get(tokens[at]!);\n if (!blocks) break;\n kept.push(...blocks);\n }\n const rest = tokens.slice(at);\n const converted = rest.map((token) => markdownBlocks([token], schemes));\n // The blocks drawn after the kept ones, when those are still the ones drawn first.\n const drawn = !kept.length || previous?.[kept.length - 1] === kept.at(-1);\n const was = drawn ? previous?.slice(kept.length) : undefined;\n const shared = shareBlocks(was, converted.flat());\n let from = 0;\n rest.forEach((token, i) => {\n const count = converted[i]!.length;\n this.streamed.set(token, shared.slice(from, (from += count)));\n });\n return [...kept, ...shared];\n }\n\n protected classFor(element: MarkdownElement): string {\n return this.classOf()[element];\n }\n\n protected imageWidth(src: string): string | null {\n const size = this.sizes().get(src);\n return size ? `${size.width}px` : null;\n }\n\n /** The class's height until the image loads, then its ratio's, or a narrowed image's own. */\n protected imageHeight(block: ImageBlock): number | 'auto' | null {\n const size = this.sizes().get(block.src);\n if (!size) return null;\n const width = this.narrowed().get(block);\n return width === undefined ? 'auto' : width / size.ratio;\n }\n\n protected layOutImage(block: ImageBlock, event: Partial<LayoutEvent>): void {\n const width = event.nativeEvent?.layout?.width;\n const size = this.sizes().get(block.src);\n if (width === undefined || !size) return;\n const narrowed = width < size.width ? width : undefined;\n if (this.narrowed().get(block) === narrowed) return;\n this.narrowed.update((all) => {\n const next = new Map(all);\n if (narrowed === undefined) next.delete(block);\n else next.set(block, narrowed);\n return next;\n });\n }\n\n protected sizeImage(src: string, event: Partial<ImageLoadEvent>): void {\n const source = event.nativeEvent?.source;\n if (!source) return;\n const { width, height } = source;\n if (!(width > 0 && height > 0)) return;\n // A url's or a data url's scale is 1, so the load event's pixels are the points a browser's\n // CSS pixels are.\n this.sizes.update((sizes) => new Map(sizes).set(src, { width, ratio: width / height }));\n }\n\n protected followLink(link: MarkdownLink): void {\n let prevented = false;\n this.linkPress.emit({\n href: link.href,\n title: link.title,\n preventDefault: () => {\n prevented = true;\n },\n });\n if (!prevented && opensOnPress(link.href)) this.injector.get(DeepLinks).open(link.href);\n }\n}\n"]}
|
package/dist/menu.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menus written as elements: `<menu-bar>`, `<menu-group>`, `<menu-item>` and `<menu-separator>`.
|
|
3
|
+
* They draw nothing themselves. Each item registers itself with the menu it is written in, through
|
|
4
|
+
* `MENU_MODEL`, and the menu's owner draws it: `Menus` sends a `<menu-bar>` to the host, and a
|
|
5
|
+
* `[contextMenu]` or a `<native-header-item [menu]>` reads a template of items.
|
|
6
|
+
*/
|
|
7
|
+
import { type OutputEmitterRef } from '@angular/core';
|
|
8
|
+
import { type MenuGroupRole, type MenuRole } from '@ng-native/device';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
export { menuModelInTreeOrder, treeOrder } from '@ng-native/device';
|
|
11
|
+
/**
|
|
12
|
+
* One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. An
|
|
13
|
+
* item with a `menuRole` and no `(select)` does what the OS does for that role.
|
|
14
|
+
*/
|
|
15
|
+
export declare class MenuItem {
|
|
16
|
+
readonly label: import("@angular/core").InputSignal<string>;
|
|
17
|
+
/** What the item is for, where the OS has a standard one: it replaces that default. */
|
|
18
|
+
readonly menuRole: import("@angular/core").InputSignal<MenuRole | undefined>;
|
|
19
|
+
/** `mod+s`: Cmd on Apple's OSes, Ctrl on Android. */
|
|
20
|
+
readonly shortcut: import("@angular/core").InputSignal<string | undefined>;
|
|
21
|
+
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
22
|
+
/** A check mark. Bound two-way, it toggles as the item is chosen. */
|
|
23
|
+
readonly checked: import("@angular/core").ModelSignal<boolean | undefined>;
|
|
24
|
+
readonly destructive: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
25
|
+
readonly subtitle: import("@angular/core").InputSignal<string | undefined>;
|
|
26
|
+
/** An SF Symbol, on Apple's OSes. */
|
|
27
|
+
readonly sfSymbol: import("@angular/core").InputSignal<string | undefined>;
|
|
28
|
+
/** A drawable resource's name, on Android. */
|
|
29
|
+
readonly icon: import("@angular/core").InputSignal<string | undefined>;
|
|
30
|
+
readonly select: OutputEmitterRef<void>;
|
|
31
|
+
private readonly handled;
|
|
32
|
+
constructor();
|
|
33
|
+
/** One handler for the item's life: the id a host reports a choice by. See `menuActionId`. */
|
|
34
|
+
private readonly choose;
|
|
35
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MenuItem, never>;
|
|
36
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MenuItem, "menu-item", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "menuRole": { "alias": "menuRole"; "required": false; "isSignal": true; }; "shortcut": { "alias": "shortcut"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "destructive": { "alias": "destructive"; "required": false; "isSignal": true; }; "subtitle": { "alias": "subtitle"; "required": false; "isSignal": true; }; "sfSymbol": { "alias": "sfSymbol"; "required": false; "isSignal": true; }; "icon": { "alias": "icon"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; "select": "select"; }, never, never, true, never>;
|
|
37
|
+
}
|
|
38
|
+
/** A line between items. */
|
|
39
|
+
export declare class MenuSeparator {
|
|
40
|
+
constructor();
|
|
41
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MenuSeparator, never>;
|
|
42
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MenuSeparator, "menu-separator", never, {}, {}, never, never, true, never>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A submenu, a section of the menu it is in (`inline`), or in a `<menu-bar>` a menu of the bar. In
|
|
46
|
+
* a bar, a `menuRole` of `app`, `file`, `edit`, `view`, `window` or `help` adds its items to that
|
|
47
|
+
* standard menu.
|
|
48
|
+
*/
|
|
49
|
+
export declare class MenuGroup {
|
|
50
|
+
readonly label: import("@angular/core").InputSignal<string>;
|
|
51
|
+
readonly menuRole: import("@angular/core").InputSignal<MenuGroupRole | undefined>;
|
|
52
|
+
readonly inline: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
53
|
+
readonly sfSymbol: import("@angular/core").InputSignal<string | undefined>;
|
|
54
|
+
readonly icon: import("@angular/core").InputSignal<string | undefined>;
|
|
55
|
+
readonly destructive: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
56
|
+
private readonly own;
|
|
57
|
+
constructor();
|
|
58
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MenuGroup, never>;
|
|
59
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MenuGroup, "menu-group", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "menuRole": { "alias": "menuRole"; "required": false; "isSignal": true; }; "inline": { "alias": "inline"; "required": false; "isSignal": true; }; "sfSymbol": { "alias": "sfSymbol"; "required": false; "isSignal": true; }; "icon": { "alias": "icon"; "required": false; "isSignal": true; }; "destructive": { "alias": "destructive"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The app's menus in the menu bar, merged with the menus every desktop app has: App, Edit, View,
|
|
63
|
+
* Window and Help. On macOS and iPadOS it is the menu bar. On iPhone and Android nothing is drawn,
|
|
64
|
+
* and the items' shortcuts work from a hardware keyboard. It can be anywhere in the app, and
|
|
65
|
+
* follows what its items say for as long as it is there.
|
|
66
|
+
*/
|
|
67
|
+
export declare class MenuBar {
|
|
68
|
+
constructor();
|
|
69
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MenuBar, never>;
|
|
70
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MenuBar, "menu-bar", never, {}, {}, never, ["*"], true, never>;
|
|
71
|
+
}
|
package/dist/menu.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menus written as elements: `<menu-bar>`, `<menu-group>`, `<menu-item>` and `<menu-separator>`.
|
|
3
|
+
* They draw nothing themselves. Each item registers itself with the menu it is written in, through
|
|
4
|
+
* `MENU_MODEL`, and the menu's owner draws it: `Menus` sends a `<menu-bar>` to the host, and a
|
|
5
|
+
* `[contextMenu]` or a `<native-header-item [menu]>` reads a template of items.
|
|
6
|
+
*/
|
|
7
|
+
import { Component, DestroyRef, ElementRef, booleanAttribute, computed, inject, input, model, output, signal, } from '@angular/core';
|
|
8
|
+
import { MENU_MODEL, Menus, menuModelInTreeOrder, } from '@ng-native/device';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
export { menuModelInTreeOrder, treeOrder } from '@ng-native/device';
|
|
11
|
+
/** Register `entry` with the menu the element is written in, and take it out as it goes. */
|
|
12
|
+
function registerIn(entry, element) {
|
|
13
|
+
const menu = inject(MENU_MODEL, { optional: true, skipSelf: true });
|
|
14
|
+
if (!menu) {
|
|
15
|
+
console.warn(`[angular-native] <${element}> is outside a menu: write it in a <menu-bar>, a ` +
|
|
16
|
+
'<menu-group>, or a template given to [contextMenu] or <native-header-item [menu]>.');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const node = inject(ElementRef).nativeElement;
|
|
20
|
+
inject(DestroyRef).onDestroy(menu.register(entry, node));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Count an output's listeners, so an item knows whether the app handles it: as a signal, so the
|
|
24
|
+
* menu follows a listener added or removed after it was first sent.
|
|
25
|
+
*/
|
|
26
|
+
function listened(emitter) {
|
|
27
|
+
const listeners = signal(0, /* @ts-ignore */
|
|
28
|
+
...(ngDevMode ? [{ debugName: "listeners" }] : /* istanbul ignore next */ []));
|
|
29
|
+
const subscribe = emitter.subscribe.bind(emitter);
|
|
30
|
+
emitter.subscribe = (callback) => {
|
|
31
|
+
listeners.update((count) => count + 1);
|
|
32
|
+
const subscription = subscribe(callback);
|
|
33
|
+
let stopped = false;
|
|
34
|
+
return {
|
|
35
|
+
unsubscribe: () => {
|
|
36
|
+
if (stopped)
|
|
37
|
+
return;
|
|
38
|
+
stopped = true;
|
|
39
|
+
listeners.update((count) => count - 1);
|
|
40
|
+
subscription.unsubscribe();
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
return computed(() => listeners() > 0);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. An
|
|
48
|
+
* item with a `menuRole` and no `(select)` does what the OS does for that role.
|
|
49
|
+
*/
|
|
50
|
+
export class MenuItem {
|
|
51
|
+
label = input('', /* @ts-ignore */
|
|
52
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
53
|
+
/** What the item is for, where the OS has a standard one: it replaces that default. */
|
|
54
|
+
menuRole = input(/* @ts-ignore */
|
|
55
|
+
...(ngDevMode ? [undefined, { debugName: "menuRole" }] : /* istanbul ignore next */ []));
|
|
56
|
+
/** `mod+s`: Cmd on Apple's OSes, Ctrl on Android. */
|
|
57
|
+
shortcut = input(/* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [undefined, { debugName: "shortcut" }] : /* istanbul ignore next */ []));
|
|
59
|
+
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
60
|
+
/** A check mark. Bound two-way, it toggles as the item is chosen. */
|
|
61
|
+
checked = model(undefined, /* @ts-ignore */
|
|
62
|
+
...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
|
|
63
|
+
destructive = input(false, { ...(ngDevMode ? { debugName: "destructive" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
64
|
+
subtitle = input(/* @ts-ignore */
|
|
65
|
+
...(ngDevMode ? [undefined, { debugName: "subtitle" }] : /* istanbul ignore next */ []));
|
|
66
|
+
/** An SF Symbol, on Apple's OSes. */
|
|
67
|
+
sfSymbol = input(/* @ts-ignore */
|
|
68
|
+
...(ngDevMode ? [undefined, { debugName: "sfSymbol" }] : /* istanbul ignore next */ []));
|
|
69
|
+
/** A drawable resource's name, on Android. */
|
|
70
|
+
icon = input(/* @ts-ignore */
|
|
71
|
+
...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
72
|
+
select = output();
|
|
73
|
+
handled = listened(this.select);
|
|
74
|
+
constructor() {
|
|
75
|
+
registerIn(computed(() => {
|
|
76
|
+
const checked = this.checked();
|
|
77
|
+
const role = this.menuRole();
|
|
78
|
+
// An item with a role and no handler is the OS's: no `select`, so the host does it.
|
|
79
|
+
const own = !role || this.handled() || checked !== undefined;
|
|
80
|
+
return {
|
|
81
|
+
label: this.label(),
|
|
82
|
+
...(role && { menuRole: role }),
|
|
83
|
+
...(this.shortcut() && { shortcut: this.shortcut() }),
|
|
84
|
+
...(this.disabled() && { disabled: true }),
|
|
85
|
+
...(checked !== undefined && { checked }),
|
|
86
|
+
...(this.destructive() && { destructive: true }),
|
|
87
|
+
...(this.subtitle() && { subtitle: this.subtitle() }),
|
|
88
|
+
...(this.sfSymbol() && { sfSymbol: this.sfSymbol() }),
|
|
89
|
+
...(this.icon() && { icon: this.icon() }),
|
|
90
|
+
...(own && { select: this.choose }),
|
|
91
|
+
};
|
|
92
|
+
}), 'menu-item');
|
|
93
|
+
}
|
|
94
|
+
/** One handler for the item's life: the id a host reports a choice by. See `menuActionId`. */
|
|
95
|
+
choose = () => {
|
|
96
|
+
if (this.disabled())
|
|
97
|
+
return;
|
|
98
|
+
const checked = this.checked();
|
|
99
|
+
if (checked !== undefined)
|
|
100
|
+
this.checked.set(!checked);
|
|
101
|
+
this.select.emit();
|
|
102
|
+
};
|
|
103
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MenuItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
104
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: MenuItem, isStandalone: true, selector: "menu-item", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, menuRole: { classPropertyName: "menuRole", publicName: "menuRole", isSignal: true, isRequired: false, transformFunction: null }, shortcut: { classPropertyName: "shortcut", publicName: "shortcut", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, destructive: { classPropertyName: "destructive", publicName: "destructive", isSignal: true, isRequired: false, transformFunction: null }, subtitle: { classPropertyName: "subtitle", publicName: "subtitle", isSignal: true, isRequired: false, transformFunction: null }, sfSymbol: { classPropertyName: "sfSymbol", publicName: "sfSymbol", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange", select: "select" }, host: { properties: { "style.display": "\"none\"" } }, ngImport: i0, template: '', isInline: true });
|
|
105
|
+
}
|
|
106
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MenuItem, decorators: [{
|
|
107
|
+
type: Component,
|
|
108
|
+
args: [{
|
|
109
|
+
selector: 'menu-item',
|
|
110
|
+
template: '',
|
|
111
|
+
host: { '[style.display]': '"none"' },
|
|
112
|
+
}]
|
|
113
|
+
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], menuRole: [{ type: i0.Input, args: [{ isSignal: true, alias: "menuRole", required: false }] }], shortcut: [{ type: i0.Input, args: [{ isSignal: true, alias: "shortcut", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], destructive: [{ type: i0.Input, args: [{ isSignal: true, alias: "destructive", required: false }] }], subtitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "subtitle", required: false }] }], sfSymbol: [{ type: i0.Input, args: [{ isSignal: true, alias: "sfSymbol", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], select: [{ type: i0.Output, args: ["select"] }] } });
|
|
114
|
+
/** A line between items. */
|
|
115
|
+
export class MenuSeparator {
|
|
116
|
+
constructor() {
|
|
117
|
+
registerIn(computed(() => ({ separator: true })), 'menu-separator');
|
|
118
|
+
}
|
|
119
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MenuSeparator, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
120
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.2.0", type: MenuSeparator, isStandalone: true, selector: "menu-separator", host: { properties: { "style.display": "\"none\"" } }, ngImport: i0, template: '', isInline: true });
|
|
121
|
+
}
|
|
122
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MenuSeparator, decorators: [{
|
|
123
|
+
type: Component,
|
|
124
|
+
args: [{
|
|
125
|
+
selector: 'menu-separator',
|
|
126
|
+
template: '',
|
|
127
|
+
host: { '[style.display]': '"none"' },
|
|
128
|
+
}]
|
|
129
|
+
}], ctorParameters: () => [] });
|
|
130
|
+
/**
|
|
131
|
+
* A submenu, a section of the menu it is in (`inline`), or in a `<menu-bar>` a menu of the bar. In
|
|
132
|
+
* a bar, a `menuRole` of `app`, `file`, `edit`, `view`, `window` or `help` adds its items to that
|
|
133
|
+
* standard menu.
|
|
134
|
+
*/
|
|
135
|
+
export class MenuGroup {
|
|
136
|
+
label = input('', /* @ts-ignore */
|
|
137
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
138
|
+
menuRole = input(/* @ts-ignore */
|
|
139
|
+
...(ngDevMode ? [undefined, { debugName: "menuRole" }] : /* istanbul ignore next */ []));
|
|
140
|
+
inline = input(false, { ...(ngDevMode ? { debugName: "inline" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
141
|
+
sfSymbol = input(/* @ts-ignore */
|
|
142
|
+
...(ngDevMode ? [undefined, { debugName: "sfSymbol" }] : /* istanbul ignore next */ []));
|
|
143
|
+
icon = input(/* @ts-ignore */
|
|
144
|
+
...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
145
|
+
destructive = input(false, { ...(ngDevMode ? { debugName: "destructive" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
146
|
+
own = inject(MENU_MODEL, { self: true });
|
|
147
|
+
constructor() {
|
|
148
|
+
registerIn(computed(() => ({
|
|
149
|
+
label: this.label(),
|
|
150
|
+
items: this.own.entries(),
|
|
151
|
+
...(this.menuRole() && { group: this.menuRole() }),
|
|
152
|
+
...(this.inline() && { inline: true }),
|
|
153
|
+
...(this.sfSymbol() && { sfSymbol: this.sfSymbol() }),
|
|
154
|
+
...(this.icon() && { icon: this.icon() }),
|
|
155
|
+
...(this.destructive() && { destructive: true }),
|
|
156
|
+
})), 'menu-group');
|
|
157
|
+
}
|
|
158
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MenuGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
159
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: MenuGroup, isStandalone: true, selector: "menu-group", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, menuRole: { classPropertyName: "menuRole", publicName: "menuRole", isSignal: true, isRequired: false, transformFunction: null }, inline: { classPropertyName: "inline", publicName: "inline", isSignal: true, isRequired: false, transformFunction: null }, sfSymbol: { classPropertyName: "sfSymbol", publicName: "sfSymbol", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, destructive: { classPropertyName: "destructive", publicName: "destructive", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.display": "\"none\"" } }, providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }], ngImport: i0, template: '<ng-content />', isInline: true });
|
|
160
|
+
}
|
|
161
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MenuGroup, decorators: [{
|
|
162
|
+
type: Component,
|
|
163
|
+
args: [{
|
|
164
|
+
selector: 'menu-group',
|
|
165
|
+
template: '<ng-content />',
|
|
166
|
+
host: { '[style.display]': '"none"' },
|
|
167
|
+
providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }],
|
|
168
|
+
}]
|
|
169
|
+
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], menuRole: [{ type: i0.Input, args: [{ isSignal: true, alias: "menuRole", required: false }] }], inline: [{ type: i0.Input, args: [{ isSignal: true, alias: "inline", required: false }] }], sfSymbol: [{ type: i0.Input, args: [{ isSignal: true, alias: "sfSymbol", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], destructive: [{ type: i0.Input, args: [{ isSignal: true, alias: "destructive", required: false }] }] } });
|
|
170
|
+
/**
|
|
171
|
+
* The app's menus in the menu bar, merged with the menus every desktop app has: App, Edit, View,
|
|
172
|
+
* Window and Help. On macOS and iPadOS it is the menu bar. On iPhone and Android nothing is drawn,
|
|
173
|
+
* and the items' shortcuts work from a hardware keyboard. It can be anywhere in the app, and
|
|
174
|
+
* follows what its items say for as long as it is there.
|
|
175
|
+
*/
|
|
176
|
+
export class MenuBar {
|
|
177
|
+
constructor() {
|
|
178
|
+
const own = inject(MENU_MODEL, { self: true });
|
|
179
|
+
inject(DestroyRef).onDestroy(inject(Menus).addMenuBar(own.entries));
|
|
180
|
+
}
|
|
181
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MenuBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
182
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.2.0", type: MenuBar, isStandalone: true, selector: "menu-bar", host: { properties: { "style.display": "\"none\"" } }, providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }], ngImport: i0, template: '<ng-content />', isInline: true });
|
|
183
|
+
}
|
|
184
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MenuBar, decorators: [{
|
|
185
|
+
type: Component,
|
|
186
|
+
args: [{
|
|
187
|
+
selector: 'menu-bar',
|
|
188
|
+
template: '<ng-content />',
|
|
189
|
+
host: { '[style.display]': '"none"' },
|
|
190
|
+
providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }],
|
|
191
|
+
}]
|
|
192
|
+
}], ctorParameters: () => [] });
|
|
193
|
+
//# sourceMappingURL=menu.js.map
|
package/dist/menu.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,EACN,MAAM,GAGP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,UAAU,EACV,KAAK,EACL,oBAAoB,GAIrB,MAAM,mBAAmB,CAAC;;AAG3B,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEpE,4FAA4F;AAC5F,SAAS,UAAU,CAAC,KAAwB,EAAE,OAAe;IAC3D,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACpE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,IAAI,CACV,qBAAqB,OAAO,mDAAmD;YAC7E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,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC,0BAF5D,gBAAgB;;2FAIf,SAAS;kBANrB,SAAS;mBAAC;oBACT,QAAQ,EAAE,YAAY;oBACtB,QAAQ,EAAE,gBAAgB;oBAC1B,IAAI,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE;oBACrC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;iBACvE;;AA2BD;;;;;GAKG;AAOH,MAAM,OAAO,OAAO;IAClB;QACE,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IACtE,CAAC;uGAJU,OAAO;2FAAP,OAAO,8GAFP,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC,0BAF5D,gBAAgB;;2FAIf,OAAO;kBANnB,SAAS;mBAAC;oBACT,QAAQ,EAAE,UAAU;oBACpB,QAAQ,EAAE,gBAAgB;oBAC1B,IAAI,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE;oBACrC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;iBACvE","sourcesContent":["/**\n * Menus written as elements: `<menu-bar>`, `<menu-group>`, `<menu-item>` and `<menu-separator>`.\n * They draw nothing themselves. Each item registers itself with the menu it is written in, through\n * `MENU_MODEL`, and the menu's owner draws it: `Menus` sends a `<menu-bar>` to the host, and a\n * `[contextMenu]` or a `<native-header-item [menu]>` reads a template of items.\n */\nimport {\n Component,\n DestroyRef,\n ElementRef,\n booleanAttribute,\n computed,\n inject,\n input,\n model,\n output,\n signal,\n type OutputEmitterRef,\n type Signal,\n} from '@angular/core';\nimport {\n MENU_MODEL,\n Menus,\n menuModelInTreeOrder,\n type MenuEntry,\n type MenuGroupRole,\n type MenuRole,\n} from '@ng-native/device';\nimport type { EngineNode } from '@ng-native/fabric';\n\nexport { menuModelInTreeOrder, treeOrder } from '@ng-native/device';\n\n/** Register `entry` with the menu the element is written in, and take it out as it goes. */\nfunction registerIn(entry: Signal<MenuEntry>, element: string): void {\n const menu = inject(MENU_MODEL, { optional: true, skipSelf: true });\n if (!menu) {\n console.warn(\n `[angular-native] <${element}> is outside a menu: write it in a <menu-bar>, a ` +\n '<menu-group>, or a template given to [contextMenu] or <native-header-item [menu]>.',\n );\n return;\n }\n const node = inject(ElementRef).nativeElement as EngineNode;\n inject(DestroyRef).onDestroy(menu.register(entry, node));\n}\n\n/**\n * Count an output's listeners, so an item knows whether the app handles it: as a signal, so the\n * menu follows a listener added or removed after it was first sent.\n */\nfunction listened(emitter: OutputEmitterRef<void>): Signal<boolean> {\n const listeners = signal(0);\n const subscribe = emitter.subscribe.bind(emitter);\n emitter.subscribe = (callback) => {\n listeners.update((count) => count + 1);\n const subscription = subscribe(callback);\n let stopped = false;\n return {\n unsubscribe: () => {\n if (stopped) return;\n stopped = true;\n listeners.update((count) => count - 1);\n subscription.unsubscribe();\n },\n };\n };\n return computed(() => listeners() > 0);\n}\n\n/**\n * One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. An\n * item with a `menuRole` and no `(select)` does what the OS does for that role.\n */\n@Component({\n selector: 'menu-item',\n template: '',\n host: { '[style.display]': '\"none\"' },\n})\nexport class MenuItem {\n readonly label = input('');\n /** What the item is for, where the OS has a standard one: it replaces that default. */\n readonly menuRole = input<MenuRole>();\n /** `mod+s`: Cmd on Apple's OSes, Ctrl on Android. */\n readonly shortcut = input<string>();\n readonly disabled = input(false, { transform: booleanAttribute });\n /** A check mark. Bound two-way, it toggles as the item is chosen. */\n readonly checked = model<boolean | undefined>(undefined);\n readonly destructive = input(false, { transform: booleanAttribute });\n readonly subtitle = input<string>();\n /** An SF Symbol, on Apple's OSes. */\n readonly sfSymbol = input<string>();\n /** A drawable resource's name, on Android. */\n readonly icon = input<string>();\n readonly select = output<void>();\n\n private readonly handled = listened(this.select);\n\n constructor() {\n registerIn(\n computed(() => {\n const checked = this.checked();\n const role = this.menuRole();\n // An item with a role and no handler is the OS's: no `select`, so the host does it.\n const own = !role || this.handled() || checked !== undefined;\n return {\n label: this.label(),\n ...(role && { menuRole: role }),\n ...(this.shortcut() && { shortcut: this.shortcut() }),\n ...(this.disabled() && { disabled: true }),\n ...(checked !== undefined && { checked }),\n ...(this.destructive() && { destructive: true }),\n ...(this.subtitle() && { subtitle: this.subtitle() }),\n ...(this.sfSymbol() && { sfSymbol: this.sfSymbol() }),\n ...(this.icon() && { icon: this.icon() }),\n ...(own && { select: this.choose }),\n };\n }),\n 'menu-item',\n );\n }\n\n /** One handler for the item's life: the id a host reports a choice by. See `menuActionId`. */\n private readonly choose = (): void => {\n if (this.disabled()) return;\n const checked = this.checked();\n if (checked !== undefined) this.checked.set(!checked);\n this.select.emit();\n };\n}\n\n/** A line between items. */\n@Component({\n selector: 'menu-separator',\n template: '',\n host: { '[style.display]': '\"none\"' },\n})\nexport class MenuSeparator {\n constructor() {\n registerIn(\n computed(() => ({ separator: true }) as const),\n 'menu-separator',\n );\n }\n}\n\n/**\n * A submenu, a section of the menu it is in (`inline`), or in a `<menu-bar>` a menu of the bar. In\n * a bar, a `menuRole` of `app`, `file`, `edit`, `view`, `window` or `help` adds its items to that\n * standard menu.\n */\n@Component({\n selector: 'menu-group',\n template: '<ng-content />',\n host: { '[style.display]': '\"none\"' },\n providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }],\n})\nexport class MenuGroup {\n readonly label = input('');\n readonly menuRole = input<MenuGroupRole>();\n readonly inline = input(false, { transform: booleanAttribute });\n readonly sfSymbol = input<string>();\n readonly icon = input<string>();\n readonly destructive = input(false, { transform: booleanAttribute });\n\n private readonly own = inject(MENU_MODEL, { self: true });\n\n constructor() {\n registerIn(\n computed(() => ({\n label: this.label(),\n items: this.own.entries(),\n ...(this.menuRole() && { group: this.menuRole() }),\n ...(this.inline() && { inline: true }),\n ...(this.sfSymbol() && { sfSymbol: this.sfSymbol() }),\n ...(this.icon() && { icon: this.icon() }),\n ...(this.destructive() && { destructive: true }),\n })),\n 'menu-group',\n );\n }\n}\n\n/**\n * The app's menus in the menu bar, merged with the menus every desktop app has: App, Edit, View,\n * Window and Help. On macOS and iPadOS it is the menu bar. On iPhone and Android nothing is drawn,\n * and the items' shortcuts work from a hardware keyboard. It can be anywhere in the app, and\n * follows what its items say for as long as it is there.\n */\n@Component({\n selector: 'menu-bar',\n template: '<ng-content />',\n host: { '[style.display]': '\"none\"' },\n providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }],\n})\nexport class MenuBar {\n constructor() {\n const own = inject(MENU_MODEL, { self: true });\n inject(DestroyRef).onDestroy(inject(Menus).addMenuBar(own.entries));\n }\n}\n"]}
|
package/dist/modal.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { ElementRef } from '@angular/core';
|
|
2
|
+
import { type EngineNode } from '@ng-native/fabric';
|
|
1
3
|
import { ViewBase } from './view-base.ts';
|
|
2
4
|
import * as i0 from "@angular/core";
|
|
3
5
|
export type ModalPresentationStyle = 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen';
|
|
6
|
+
/** What `anchor` takes: an element, its `ElementRef`, or a component or directive with a `node`. */
|
|
7
|
+
export type ModalAnchor = ElementRef | EngineNode | {
|
|
8
|
+
readonly node: unknown;
|
|
9
|
+
} | null | undefined;
|
|
4
10
|
export type ModalOrientation = 'portrait' | 'portrait-upside-down' | 'landscape' | 'landscape-left' | 'landscape-right';
|
|
5
11
|
/**
|
|
6
12
|
* Content presented over everything else. Commits as `ModalHostView`.
|
|
@@ -48,7 +54,25 @@ export declare class Modal extends ViewBase {
|
|
|
48
54
|
readonly navigationBarTranslucent: import("@angular/core").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
49
55
|
/** Android: give the modal's window a hardware-accelerated surface. */
|
|
50
56
|
readonly hardwareAccelerated: import("@angular/core").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
57
|
+
/**
|
|
58
|
+
* The element the modal points at. With one, it shows as a popover at the element on macOS; on
|
|
59
|
+
* every other OS, iPadOS included, it shows as it would without one. Committed as the react tag
|
|
60
|
+
* of the element's view.
|
|
61
|
+
*/
|
|
62
|
+
readonly anchor: import("@angular/core").InputSignal<ModalAnchor>;
|
|
51
63
|
private readonly direction;
|
|
64
|
+
/** Only macOS reads the anchor, so only there does the modal wait for it. */
|
|
65
|
+
private readonly readsAnchor;
|
|
66
|
+
/** For the anchor view tag, which only the engine itself hands out. */
|
|
67
|
+
private readonly views;
|
|
68
|
+
private readonly injector;
|
|
69
|
+
/** The anchor's view tag, committed as `anchor`, or undefined with none. */
|
|
70
|
+
protected readonly anchorTag: import("@angular/core").WritableSignal<number | undefined>;
|
|
71
|
+
/**
|
|
72
|
+
* Whether the anchor's view has still to commit, which gives it its tag. On macOS the modal waits:
|
|
73
|
+
* the host reads the anchor as it presents, and one presented without it stays a sheet.
|
|
74
|
+
*/
|
|
75
|
+
protected readonly awaitingAnchor: import("@angular/core").WritableSignal<boolean>;
|
|
52
76
|
protected readonly resolvedPresentationStyle: import("@angular/core").Signal<ModalPresentationStyle | undefined>;
|
|
53
77
|
protected readonly containerStyle: import("@angular/core").Signal<{
|
|
54
78
|
[x: string]: string | number;
|
|
@@ -57,6 +81,11 @@ export declare class Modal extends ViewBase {
|
|
|
57
81
|
backgroundColor: string;
|
|
58
82
|
}>;
|
|
59
83
|
constructor();
|
|
84
|
+
/**
|
|
85
|
+
* Commit the anchor's tag. A view not yet committed has none, so it is read again once the
|
|
86
|
+
* commit that makes it has happened.
|
|
87
|
+
*/
|
|
88
|
+
private followAnchor;
|
|
60
89
|
static ɵfac: i0.ɵɵFactoryDeclaration<Modal, never>;
|
|
61
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<Modal, "modal", never, { "visible": { "alias": "visible"; "required": false; "isSignal": true; }; "transparent": { "alias": "transparent"; "required": false; "isSignal": true; }; "backdropColor": { "alias": "backdropColor"; "required": false; "isSignal": true; }; "animationType": { "alias": "animationType"; "required": false; "isSignal": true; }; "presentationStyle": { "alias": "presentationStyle"; "required": false; "isSignal": true; }; "supportedOrientations": { "alias": "supportedOrientations"; "required": false; "isSignal": true; }; "allowSwipeDismissal": { "alias": "allowSwipeDismissal"; "required": false; "isSignal": true; }; "statusBarTranslucent": { "alias": "statusBarTranslucent"; "required": false; "isSignal": true; }; "navigationBarTranslucent": { "alias": "navigationBarTranslucent"; "required": false; "isSignal": true; }; "hardwareAccelerated": { "alias": "hardwareAccelerated"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
90
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<Modal, "modal", never, { "visible": { "alias": "visible"; "required": false; "isSignal": true; }; "transparent": { "alias": "transparent"; "required": false; "isSignal": true; }; "backdropColor": { "alias": "backdropColor"; "required": false; "isSignal": true; }; "animationType": { "alias": "animationType"; "required": false; "isSignal": true; }; "presentationStyle": { "alias": "presentationStyle"; "required": false; "isSignal": true; }; "supportedOrientations": { "alias": "supportedOrientations"; "required": false; "isSignal": true; }; "allowSwipeDismissal": { "alias": "allowSwipeDismissal"; "required": false; "isSignal": true; }; "statusBarTranslucent": { "alias": "statusBarTranslucent"; "required": false; "isSignal": true; }; "navigationBarTranslucent": { "alias": "navigationBarTranslucent"; "required": false; "isSignal": true; }; "hardwareAccelerated": { "alias": "hardwareAccelerated"; "required": false; "isSignal": true; }; "anchor": { "alias": "anchor"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
62
91
|
}
|