@molecule/app-medication-row-angular
v1.1.2
Published
Medication row — name, dosage, form, instructions, refills remaining, prescriber
Maintainers
Readme
@molecule/app-medication-row-angular
Angular medication record row — the counterpart of
@molecule/app-medication-row-react: the same props and the same DOM for the
same input.
Exports <MedicationRow> — drug name + dosage/form, instructions,
prescriber, days-of-supply and refills-remaining readouts, optional
pill-color dot and right-side actions.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { Component } from '@angular/core'
import { MedicationRow } from '@molecule/app-medication-row-angular'
@Component({
selector: 'app-medications',
standalone: true,
imports: [MedicationRow],
template: `
<div
mol-medication-row
name="Lisinopril"
dosage="10mg"
form="tablet"
color="#4ade80"
instructions="Take with water in the morning"
prescriber="Dr. Sarah Chen"
[supplyDays]="14"
[refills]="2"
>
<button slot="actions" type="button">Mark taken</button>
</div>
`,
})
export class Medications {}Type
feature
Installation
npm install @molecule/app-medication-row-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angularAPI
Interfaces
MedicationRowProps
Props accepted by {@link MedicationRow} — the same props
@molecule/app-medication-row-react accepts. Node props (name, dosage,
form, instructions, prescriber, actions) are projected content in
Angular (an input cannot carry a node), so they are typed unknown: pass
node content as [slot=<name>] children of the host element, and plain
strings as the input.
interface MedicationRowProps {
/** Drug name — a string input, or `[slot=name]` projected content. */
name?: unknown
/** Dosage display ("10mg", "1 tablet") — a string input, or `[slot=dosage]` content. */
dosage?: unknown
/** Form (tablet, capsule, liquid, etc.) — a string input, or `[slot=form]` content. */
form?: unknown
/** Optional accent color (typically used to differentiate pill colors). */
color?: string
/** Instructions text ("Take with food") — a string input, or `[slot=instructions]` content. */
instructions?: unknown
/** Prescriber display — a string input, or `[slot=prescriber]` content. */
prescriber?: unknown
/** Days of supply remaining. */
supplyDays?: number
/** Refills remaining. */
refills?: number
/** Right-side actions — a string input, or `[slot=actions]` content. */
actions?: unknown
/** Extra classes. */
className?: string
}Classes
MedicationRow
MedicationRow component.
Medication record row — drug name, dosage/form, instructions, prescriber,
supply countdown, refills remaining. Used in medication-reminder,
patient-facing health portals, pharmacy dashboards. The host IS the card
<div> (div[mol-medication-row]), matching React's root exactly, so the
card's ClassMap classes are the host's.
Node props (name, dosage, form, instructions, prescriber,
actions) are projected content ([slot=<name>]); plain strings are
inputs. The optional wrappers render only when React would render them —
Angular projection needs always-mounted capture points, so
{@link MedicationRow.reconcile} takes an unrendered wrapper out of the DOM
({@link setElementPresent}).
@Component({
selector: 'div[mol-medication-row]',
standalone: true,
hostDirectives: [MolPlacement],
inputs: [
'name',
'dosage',
'form',
'color',
'instructions',
'prescriber',
'supplyDays',
'refills',
'actions',
'className',
],
host: {
'[class]': 'cardClasses()',
},
// prettier-ignore
template: `<div [class]="rowClass()">@if (color) {<span aria-hidden="true" [class]="dotClass()" [style.width]="'24px'" [style.height]="'24px'" [style.background]="color"></span>}<div [class]="bodyClass()"><header [class]="headerClass()"><h3 [class]="nameClass()">@if (nameText()) {<ng-container>{{ nameText() }}</ng-container>}<ng-content select="[slot=name]"></ng-content></h3><span #dosageWrap [class]="dosageClass()">@if (dosageText()) {<ng-container>{{ dosageText() }}</ng-container>}<ng-content select="[slot=dosage]"></ng-content></span><span #formWrap [class]="smallClass()">@if (formText()) {<ng-container>{{ formText() }}</ng-container>}<ng-content select="[slot=form]"></ng-content></span></header><p #instructionsWrap [class]="instructionsClass()">@if (instructionsText()) {<ng-container>{{ instructionsText() }}</ng-container>}<ng-content select="[slot=instructions]"></ng-content></p><div [class]="metaClass()"><span #prescriberWrap [class]="smallClass()">{{ prescribedBy() }}@if (prescriberText()) {<ng-container>{{ prescriberText() }}</ng-container>}<ng-content select="[slot=prescriber]"></ng-content></span>@if (supplyDays !== undefined) {<span [class]="supplyClass()">· {{ supplyText() }}</span>}@if (refills !== undefined) {<span [class]="smallClass()">· {{ refillsText() }}</span>}</div></div><div #actionsWrap [class]="actionsClass()">@if (actionsText()) {<ng-container>{{ actionsText() }}</ng-container>}<ng-content select="[slot=actions]"></ng-content></div></div>`,
})
export class MedicationRow {
/** Drug name — a string input, or `[slot=name]` projected content. */
name?: unknown
/** Dosage display — a string input, or `[slot=dosage]` projected content. */
dosage?: unknown
/** Form — a string input, or `[slot=form]` projected content. */
form?: unknown
/** Optional accent color (typically used to differentiate pill colors). */
color?: string
/** Instructions text — a string input, or `[slot=instructions]` content. */
instructions?: unknown
/** Prescriber display — a string input, or `[slot=prescriber]` content. */
prescriber?: unknown
/** Days of supply remaining. */
supplyDays?: number
/** Refills remaining. */
refills?: number
/** Right-side actions — a string input, or `[slot=actions]` projected content. */
actions?: unknown
/** Extra classes on the card. */
className?: string
/** The optional dosage span. */
@ViewChild('dosageWrap') private dosageWrap?: ElementRef<HTMLElement>
/** The optional form span. */
@ViewChild('formWrap') private formWrap?: ElementRef<HTMLElement>
/** The optional instructions paragraph. */
@ViewChild('instructionsWrap') private instructionsWrap?: ElementRef<HTMLElement>
/** The optional prescriber span. */
@ViewChild('prescriberWrap') private prescriberWrap?: ElementRef<HTMLElement>
/** The optional actions wrapper. */
@ViewChild('actionsWrap') private actionsWrap?: ElementRef<HTMLElement>
/** The i18n provider above the row. */
private readonly i18n = useTranslation()
constructor() {
usePlacement((hasContent) => this.reconcile(hasContent))
}
/** The current class map. */
cm(): UIClassMap {
return getClassMap()
}
cardClasses(): string {
const cm = this.cm()
return cm.cn(cm.card({ variant: 'elevated' }), cm.cardPadding('md'), this.className)
}
/** The outer row's class list (`cm.flex({ align: 'start', gap: 'md' })`). */
rowClass(): string {
return this.cm().flex({ align: 'start', gap: 'md' })
}
/** The pill-color dot's class list (`cm.cn(cm.shrink0, cm.roundedFull)`). */
dotClass(): string {
return this.cm().cn(this.cm().shrink0, this.cm().roundedFull)
}
/** The name column's class list (`cm.cn(cm.flex1, cm.stack(1))`). */
bodyClass(): string {
return this.cm().cn(this.cm().flex1, this.cm().stack(1))
}
/** The header row's class list (`cm.flex({ align: 'baseline', gap: 'sm', wrap: 'wrap' })`). */
headerClass(): string {
return this.cm().flex({ align: 'baseline', gap: 'sm', wrap: 'wrap' })
}
/** The name heading's class list (`cm.cn(cm.textSize('base'), cm.fontWeight('bold'))`). */
nameClass(): string {
return this.cm().cn(this.cm().textSize('base'), this.cm().fontWeight('bold'))
}
/** The dosage span's class list (`cm.cn(cm.textSize('sm'), cm.fontWeight('medium'))`). */
dosageClass(): string {
return this.cm().cn(this.cm().textSize('sm'), this.cm().fontWeight('medium'))
}
/** The small-text class (`cm.textSize('xs')`). */
smallClass(): string {
return this.cm().textSize('xs')
}
/** The instructions paragraph's class (`cm.textSize('sm')`). */
instructionsClass(): string {
return this.cm().textSize('sm')
}
/** The actions wrapper's class (`cm.shrink0`). */
actionsClass(): string {
return this.cm().cn(this.cm().shrink0)
}
/** The meta row's class list (`cm.flex({ align: 'center', gap: 'sm', wrap: 'wrap' })`). */
metaClass(): string {
return this.cm().flex({ align: 'center', gap: 'sm', wrap: 'wrap' })
}
/** The supply span's class list (`cm.cn(cm.textSize('xs'), cm.fontWeight('semibold'))`). */
supplyClass(): string {
return this.cm().cn(this.cm().textSize('xs'), this.cm().fontWeight('semibold'))
}
/** The name input's text (React's `{name}` for a text child). */
nameText(): string {
return textOf(this.name)
}
/** The dosage input's text (React's `{dosage && …}` for a text child). */
dosageText(): string {
return textOf(this.dosage)
}
/** The form input's text (React's `{form && …}` for a text child). */
formText(): string {
return textOf(this.form)
}
/** The instructions input's text (React's `{instructions && …}` for a text child). */
instructionsText(): string {
return textOf(this.instructions)
}
/** The prescriber input's text (React's `{prescriber && …}` for a text child). */
prescriberText(): string {
return textOf(this.prescriber)
}
/** The actions input's text (React's `{actions && …}` for a text child). */
actionsText(): string {
return textOf(this.actions)
}
/** The "Prescribed by" label, with the space React renders before the prescriber display (`{t(…)} {prescriber}`). */
prescribedBy(): string {
return `${this.i18n.t('medication.prescribedBy', {}, { defaultValue: 'Prescribed by' })} `
}
/** The translated supply line (`medication.supplyDays`). */
supplyText(): string {
return this.i18n.t(
'medication.supplyDays',
{ days: this.supplyDays ?? 0 },
{ defaultValue: '{{days}} day supply' },
)
}
/** The translated refills line (`medication.refills`). */
refillsText(): string {
return this.i18n.t(
'medication.refills',
{ refills: this.refills ?? 0 },
{ defaultValue: '{{refills}} refills' },
)
}
private reconcile(hasContent: SlotReader): void {
const dosage = this.dosageWrap?.nativeElement
const form = this.formWrap?.nativeElement
const instructions = this.instructionsWrap?.nativeElement
const prescriber = this.prescriberWrap?.nativeElement
const actions = this.actionsWrap?.nativeElement
setElementPresent(dosage, Boolean(this.dosage) || hasContent(dosage))
setElementPresent(form, Boolean(this.form) || hasContent(form))
setElementPresent(instructions, Boolean(this.instructions) || hasContent(instructions))
// The prescriber span always renders its label first, so the slot read
// skips that one leading node.
setElementPresent(prescriber, Boolean(this.prescriber) || hasContent(prescriber, 1))
setElementPresent(actions, Boolean(this.actions) || hasContent(actions))
}
}(Member comments are shortened to their first sentence, and the 2 longest are left out to fit; the full declaration is in node_modules/@molecule/app-medication-row-angular/dist/medication-row.component.d.ts.)
Injection Notes
Requirements
Peer dependencies:
@angular/common^22.0.0@angular/core^22.0.0@angular/platform-browser^22.0.0@molecule/app-angular^3.13.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-angular^1.1.0
Runtime Dependencies
@angular/common@angular/core@angular/platform-browser@molecule/app-angular@molecule/app-ui@molecule/app-ui-angularThe "Prescribed by" / "N day supply" / "N refills" labels route through
t()under themedication.prefix. The companion@molecule/app-locales-medication-rowbond currently ships onlymedication.prescribedBy—medication.supplyDaysandmedication.refillsfall back to English until the bond gains them.Fields you pass are rendered as-is (strings) — format dosage/dates and translate free text yourself.
Node props are projected content:
name,dosage,form,instructions,prescriberandactionsare selected by[slot=<name>]; plain strings may also be passed as inputs.No
data-mol-idprop. Renders inside the card styling of@molecule/app-ui-angular; a ClassMap bond must be wired.
Translations
Translation strings are provided by @molecule/app-locales-medication-row.
