@vectoriox/iox-ui 5.206.0 → 5.207.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/fesm2022/vectoriox-iox-ui-generation-core.mjs +401 -48
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/generation-core/index.d.ts +152 -7
- package/package.json +1 -1
- package/src/generation-core/compose-layout.ts +27 -3
- package/src/generation-core/compose-site.ts +5 -9
- package/src/generation-core/fact-words.ts +65 -0
- package/src/generation-core/layout-space.ts +2 -1
- package/src/generation-core/opening-mix.ts +13 -2
- package/src/generation-core/stock-photos.ts +40 -8
- package/src/generation-core/stock-search.ts +139 -9
- package/src/generation-core/stock-subjects.ts +183 -0
- package/styles/iox-design.css +9 -0
|
@@ -747,6 +747,12 @@ const INSET_LAPTOP = '24px';
|
|
|
747
747
|
/** iox-ui#196: the cue stands at the end inset (`inset-inline-end: 4%`, iox-design.css) and keeps the same inset on its
|
|
748
748
|
* start side — every word inside the screen, at 1440 and 390, in both directions. */
|
|
749
749
|
export const OPENING_CUE_MAX_WIDTH = '92%';
|
|
750
|
+
/** iox-ui#196 (the cue never meets the action): on a phone the frame's bottom padding is only the cue's own 20px, so a cue
|
|
751
|
+
* over the frame stood in the words' panel — two lines ran 7px across the hotel's "Ask for a booking". There it is the
|
|
752
|
+
* frame's last line, in the flow under the words (the frame is a column at its end; the frame's gap between them), at the
|
|
753
|
+
* inline end — the shared CSS's phone rule (`inset: auto; align-self: flex-end`, which also holds a cue saved before on
|
|
754
|
+
* the live site). The node says the position because the canvas forces a node's own. */
|
|
755
|
+
export const OPENING_CUE_PHONE: Readonly<Record<string, string>> = Object.freeze({ position: 'relative', bottom: '0px' });
|
|
750
756
|
const ABS_FILL: Readonly<Record<string, string>> = { position: 'absolute', top: '0px', left: '0px', width: '100%', height: '100%', zIndex: '0' };
|
|
751
757
|
const MEDIA_FILL: Readonly<Record<string, string>> = { ...ABS_FILL, aspectRatio: 'auto', borderRadius: '0px', objectFit: 'cover' };
|
|
752
758
|
const OVER = (z: number): Readonly<Record<string, string>> => ({ position: 'relative', zIndex: String(z) });
|
|
@@ -1063,8 +1069,13 @@ function extrasNodes(mix: OpeningMix): PatternNode[] {
|
|
|
1063
1069
|
}
|
|
1064
1070
|
if (mix.extras.includes(OpeningExtra.Cue)) {
|
|
1065
1071
|
// iox-ui#196: as wide as its words (a Text is 100% by default — at the end inset it started 4% off the screen), and
|
|
1066
|
-
// never wider than the room between the two insets (the shared CSS holds that for a cue saved before).
|
|
1067
|
-
|
|
1072
|
+
// never wider than the room between the two insets (the shared CSS holds that for a cue saved before). On a phone it
|
|
1073
|
+
// is the frame's last line, in the flow under the words (`OPENING_CUE_PHONE`): over the frame it met the action.
|
|
1074
|
+
out.push({
|
|
1075
|
+
t: 'Text', es: 'eyebrow', role: OpeningRole.Cue, text: 'Scroll', textHe: 'גללו',
|
|
1076
|
+
lay: { position: 'absolute', bottom: '20px', zIndex: '2', margin: '0px', width: 'auto', maxWidth: OPENING_CUE_MAX_WIDTH },
|
|
1077
|
+
resp: { mobile: { ...OPENING_CUE_PHONE } },
|
|
1078
|
+
});
|
|
1068
1079
|
}
|
|
1069
1080
|
return out;
|
|
1070
1081
|
}
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
aspectRatioOf, scoreStockPhoto, STOCK_FAMILY_INTENTS, STOCK_INTENT_ORDER, StockIntent, StockNeed, stockFits, StockPhotoTraits, stockPhotoUsable,
|
|
8
8
|
stockWords,
|
|
9
9
|
} from './stock-match';
|
|
10
|
-
import { isPeopleContentType, StockFit, stockMayFill, stockPhotoFits } from './stock-search';
|
|
11
|
-
import { stockNearWords } from './stock-subjects';
|
|
10
|
+
import { isPeopleContentType, StockFit, STOCK_FIT_ANY, stockMayFill, stockPhotoFits, stockPlaceItem, stockShowsItem } from './stock-search';
|
|
11
|
+
import { stockNearWords, stockPhotoAbout } from './stock-subjects';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Stock photos in a built site (AI plan §3g / §3m, I2 + I2.1): a FREE picture from the platform's curated library, copied
|
|
@@ -354,17 +354,47 @@ function captionOf(row: SerializedNode | undefined, skip: string): string {
|
|
|
354
354
|
return heading || text;
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
+
/** What `stockPhotoAlt` is told besides the place: the photo placed there, the site's language, the site's fit. */
|
|
358
|
+
export interface StockAltOptions {
|
|
359
|
+
/** The site's language (`SitePlan.locale`); absent — Hebrew when the place's words are, else English. */
|
|
360
|
+
locale?: string | null;
|
|
361
|
+
/** What the site holds photos to (`stockFitFor(type)`) — which item meanings hold in its trade. */
|
|
362
|
+
fit?: StockFit;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** A place as its alt reads it (a `StockSlot` or a `StockItemSlot`). */
|
|
366
|
+
export interface StockAltPlace {
|
|
367
|
+
caption?: string;
|
|
368
|
+
about?: string;
|
|
369
|
+
kind?: string;
|
|
370
|
+
near?: ReadonlyArray<string>;
|
|
371
|
+
subject?: ReadonlyArray<string>;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** A photo as its alt reads it: its tags (else the provider's words). */
|
|
375
|
+
export type StockAltPhoto = Pick<StockPhoto, 'alt' | 'tags' | 'review'> & { credit?: Pick<StockCredit, 'title'> };
|
|
376
|
+
|
|
377
|
+
const HEBREW_LETTERS = /[-]/;
|
|
378
|
+
|
|
357
379
|
/**
|
|
358
380
|
* The alt of a stock photo in a place (iox-cms#130): the place's OWN words, in the site's language — a sample item's name,
|
|
359
381
|
* the heading (else the text) beside a section's picture, else the first thing its section says. Never the provider's tags
|
|
360
382
|
* (a tag list read aloud is noise, and an English one on a Hebrew site). Nothing written there: '' (a picture that only
|
|
361
383
|
* sets the mood, which a screen reader passes).
|
|
384
|
+
*
|
|
385
|
+
* Second half: the place's words never name what the picture was not chosen for. Given the `photo`, when the place names
|
|
386
|
+
* an item (`stockPlaceItem`: a dish, a service, a room) the photo does not show (`stockShowsItem`), the alt describes the
|
|
387
|
+
* PHOTO from its own tags (`stockPhotoAbout`, in the site's language) — never "Shakshuka" over croissants; nothing the
|
|
388
|
+
* table knows: ''. `planStockPhotos` only places a photo that shows the item, so this is the guard for every other caller.
|
|
362
389
|
*/
|
|
363
|
-
export function stockPhotoAlt(target:
|
|
364
|
-
const
|
|
365
|
-
if (
|
|
366
|
-
const
|
|
367
|
-
|
|
390
|
+
export function stockPhotoAlt(target: StockAltPlace, photo?: StockAltPhoto, opts: StockAltOptions = {}): string {
|
|
391
|
+
const own = altText(target.caption) || altText((target.about ?? '').split(' — ')[0].replace(/…$/, ''));
|
|
392
|
+
if (!photo) return own;
|
|
393
|
+
const item = stockPlaceItem({ intent: '', ...target }, opts.fit ?? STOCK_FIT_ANY);
|
|
394
|
+
if (!item || stockShowsItem(photo, item)) return own;
|
|
395
|
+
const locale = opts.locale ?? (HEBREW_LETTERS.test(own) ? 'he' : 'en');
|
|
396
|
+
const tags = photo.tags?.length ? photo.tags : String(photo.credit?.title ?? photo.alt ?? '').split(',');
|
|
397
|
+
return altText(stockPhotoAbout(tags, locale));
|
|
368
398
|
}
|
|
369
399
|
|
|
370
400
|
/** Where a photo may not appear twice: one page; one content type's samples (a list shows them together). */
|
|
@@ -533,6 +563,8 @@ export interface StockPlanOptions {
|
|
|
533
563
|
* never-words of every site and of the trade, and an opening's second word of the business. Absent: the never-words only.
|
|
534
564
|
*/
|
|
535
565
|
fit?: StockFit;
|
|
566
|
+
/** iox-cms#130: the site's language (`SitePlan.locale`) — an alt that describes a photo is written in it (`stockPhotoAlt`). */
|
|
567
|
+
locale?: string | null;
|
|
536
568
|
}
|
|
537
569
|
|
|
538
570
|
/** How far below the best score a photo may be and still be the seed's choice (one word of the plan's, about). */
|
|
@@ -594,7 +626,7 @@ export function planStockPhotos<T extends StockTarget>(slots: ReadonlyArray<T>,
|
|
|
594
626
|
here.add(best.key);
|
|
595
627
|
shownIn.set(group, here);
|
|
596
628
|
// iox-cms#130: the photo as placed HERE carries this place's alt — the provider's words stay on `credit.title`.
|
|
597
|
-
placed.set(i, { ...slot, photo: { ...best, alt: stockPhotoAlt(slot) } });
|
|
629
|
+
placed.set(i, { ...slot, photo: { ...best, alt: stockPhotoAlt(slot, best, { locale: opts.locale, fit: opts.fit }) } });
|
|
598
630
|
}
|
|
599
631
|
return slots.map((_, i) => placed.get(i)).filter((p): p is StockPlacement<T> => !!p);
|
|
600
632
|
}
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
} from './stock-match';
|
|
6
6
|
import type { StockTarget } from './stock-photos';
|
|
7
7
|
import {
|
|
8
|
-
STOCK_FACET_VOCABULARY, STOCK_GENERIC_WORDS, STOCK_UNRELATED_WORDS, stockFacetsOf,
|
|
8
|
+
STOCK_FACET_VOCABULARY, STOCK_GENERIC_WORDS, STOCK_ITEM_MODIFIERS, STOCK_ITEMS, STOCK_UNRELATED_WORDS, stockFacetsOf, stockItemsNamed,
|
|
9
|
+
stockNearWords, stockPhotoNamesItem, stockPlaceNamesIn, stockSubjectsHe, stockTagPhrases, stockTokens,
|
|
9
10
|
} from './stock-subjects';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -41,8 +42,12 @@ export interface StockSearchType {
|
|
|
41
42
|
readonly imagery?: string;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
/**
|
|
45
|
-
|
|
45
|
+
/**
|
|
46
|
+
* LS-D4: the most searches one build asks — the type's base query first, then the places' own. 8 since iox-cms#130's
|
|
47
|
+
* second half (was 4): a place that names an item takes only a photo of it, so a café's cards need their dishes asked —
|
|
48
|
+
* with 4, every card after the third took only the base query's hits and none of them showed its dish.
|
|
49
|
+
*/
|
|
50
|
+
export const STOCK_MAX_SEARCHES = 8;
|
|
46
51
|
|
|
47
52
|
/**
|
|
48
53
|
* Words that never stand on a business's site, whatever it is (compared as `stockWord`s): crime and the law's force,
|
|
@@ -151,6 +156,23 @@ const PEOPLE_TYPE_WORDS_HE: ReadonlySet<string> = new Set([
|
|
|
151
156
|
'צוות', 'הצוות', 'אנשי', 'עובדים', 'העובדים', 'המלצות', 'ממליצים', 'ביקורות', 'לקוחות', 'מטפלים', 'מטפלות', 'מאמנים', 'מאמנות',
|
|
152
157
|
'מורים', 'מורות', 'מדריכים', 'מדריכות', 'מייסדים', 'מייסדות', 'שפים', 'רופאים', 'עורכי', 'מעצבים', 'מעצבות', 'אמנים',
|
|
153
158
|
]);
|
|
159
|
+
/**
|
|
160
|
+
* iox-cms#130: words of the heading beside a section's picture that say the picture is of PEOPLE ("Our team", "הצוות
|
|
161
|
+
* שלנו") — no stock there, a stranger under "the team" is a made-up fact (iox-ui#172's rule for a section). English as
|
|
162
|
+
* `stockWord`s, Hebrew whole (a prefix ה kept as written).
|
|
163
|
+
*/
|
|
164
|
+
const PEOPLE_CAPTION_WORDS: ReadonlySet<string> = new Set([
|
|
165
|
+
...['team', 'staff', 'crew', 'founder', 'employee', 'stylist', 'therapist', 'instructor', 'trainer', 'doctor', 'lawyer', 'attorney'].map(stockWord),
|
|
166
|
+
'צוות', 'הצוות', 'צוותנו', 'עובדים', 'העובדים', 'מייסד', 'המייסד', 'מייסדת', 'המייסדת', 'מייסדים', 'המייסדים', 'מעצבות', 'המעצבות',
|
|
167
|
+
'מטפלים', 'מטפלות', 'מאמנים', 'מאמנות', 'מדריכים', 'מדריכות', 'רופאים', 'עורכי',
|
|
168
|
+
]);
|
|
169
|
+
|
|
170
|
+
/** Does a section picture's heading say it shows people (`PEOPLE_CAPTION_WORDS`)? */
|
|
171
|
+
export function captionNamesPeople(caption: unknown): boolean {
|
|
172
|
+
if (typeof caption !== 'string') return false;
|
|
173
|
+
return stockTokens(caption).some(w => PEOPLE_CAPTION_WORDS.has(w));
|
|
174
|
+
}
|
|
175
|
+
|
|
154
176
|
/** Field names only a person has (a bio, a job title, a headshot). */
|
|
155
177
|
const PEOPLE_FIELD_WORDS: ReadonlySet<string> = new Set(['bio', 'biography', 'position', 'jobtitle', 'headshot', 'portrait', 'avatar', 'testimonial', 'quote', 'pronoun']);
|
|
156
178
|
|
|
@@ -178,9 +200,13 @@ export function isPeopleContentType(type: Pick<ContentTypePlan, 'name' | 'label'
|
|
|
178
200
|
return (type.fields ?? []).some(f => PEOPLE_FIELD_WORDS.has(String(f?.name ?? '').toLowerCase()));
|
|
179
201
|
}
|
|
180
202
|
|
|
181
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* A place stock may fill: anything but a person — a sample item of a people type (`StockItemSlot.person`, set by
|
|
205
|
+
* `stockItemSlots`), or a section picture whose heading says it shows people (iox-cms#130: the salon's "team" took make-up).
|
|
206
|
+
*/
|
|
182
207
|
export function stockMayFill(target: StockTarget): boolean {
|
|
183
|
-
|
|
208
|
+
if (target.kind === 'item') return !target.person;
|
|
209
|
+
return !captionNamesPeople(target.caption);
|
|
184
210
|
}
|
|
185
211
|
|
|
186
212
|
/**
|
|
@@ -214,8 +240,12 @@ export function stockPlaceNear(slot: Pick<StockFitPlace, 'near' | 'subject'>): R
|
|
|
214
240
|
* towers), never another trade's place, never the type's own word. None: the base query.
|
|
215
241
|
*/
|
|
216
242
|
export function stockSearchFocus(slot: StockTarget, type: StockSearchType | Pick<StockSearchType, 'imagery'>, term: string): string | null {
|
|
243
|
+
const fit = 'label' in type ? stockFitFor(type) : STOCK_FIT_ANY;
|
|
244
|
+
// iox-cms#130 (second half): the item the place names, as its row asks it ("hotel breakfast", "salon keratin").
|
|
245
|
+
const item = stockPlaceItem(slot, fit);
|
|
246
|
+
if (item?.ask) return item.ask;
|
|
217
247
|
// iox-ui#175: another trade's place word is never the subject ("Boutique law firm" → never "law boutique").
|
|
218
|
-
const vocabulary =
|
|
248
|
+
const vocabulary = fit.vocabulary;
|
|
219
249
|
const asked = new Set(term.split(' ').map(stockWord));
|
|
220
250
|
const open = (w: string) => !asked.has(w) && !STOCK_GENERIC_WORDS.has(w) && !foreignTrade(w, vocabulary);
|
|
221
251
|
const imagery = stockWords(type.imagery).filter(w => !IMAGERY_NOISE.has(w));
|
|
@@ -230,10 +260,16 @@ export function stockSearchFocus(slot: StockTarget, type: StockSearchType | Pick
|
|
|
230
260
|
return null;
|
|
231
261
|
}
|
|
232
262
|
|
|
233
|
-
/**
|
|
263
|
+
/**
|
|
264
|
+
* A place's query: the type's word and its focus word, or the type's word alone; none without a type word. A place that
|
|
265
|
+
* names an item whose own name says what it is (`StockItem.alone`: a dish, a drink, "hair color") asks the item alone —
|
|
266
|
+
* "shakshuka", never "cafe shakshuka" (Pixabay matches every word, and no shakshuka is tagged "cafe").
|
|
267
|
+
*/
|
|
234
268
|
export function stockSearchQuery(slot: StockTarget, type: StockSearchType): string | null {
|
|
235
269
|
const term = stockSearchTerm(type);
|
|
236
270
|
if (!term) return null;
|
|
271
|
+
const item = stockPlaceItem(slot, stockFitFor(type));
|
|
272
|
+
if (item?.ask && item.alone) return item.ask;
|
|
237
273
|
const focus = stockSearchFocus(slot, type, term);
|
|
238
274
|
return focus ? `${term} ${focus}` : term;
|
|
239
275
|
}
|
|
@@ -244,6 +280,8 @@ export interface StockFit {
|
|
|
244
280
|
readonly never: ReadonlySet<string>;
|
|
245
281
|
/** The type's own words (label, Latin keywords, imagery) — an opening's photo names it `STOCK_OPENING_TYPE_WORDS` times. */
|
|
246
282
|
readonly vocabulary: ReadonlySet<string>;
|
|
283
|
+
/** iox-cms#130: the business type's id — which `STOCK_ITEMS` meanings hold here (`StockItem.trades`). */
|
|
284
|
+
readonly trade?: string;
|
|
247
285
|
}
|
|
248
286
|
|
|
249
287
|
/** The universal fit — no type known: only the never-words. */
|
|
@@ -256,6 +294,7 @@ export function stockFitFor(type: StockSearchType | null | undefined): StockFit
|
|
|
256
294
|
const tagged = (type.id ? STOCK_TRADE_WORDS[type.id] : undefined) ?? [];
|
|
257
295
|
const latin = (type.match ?? []).map(plain).filter(k => LATIN_KEYWORD.test(k));
|
|
258
296
|
return {
|
|
297
|
+
...(type.id ? { trade: type.id } : {}),
|
|
259
298
|
never: new Set([...STOCK_NEVER_WORDS, ...fears.map(stockWord)]),
|
|
260
299
|
vocabulary: new Set([...stockWords(type.label, ...latin, ...tagged), ...stockWords(type.imagery).filter(w => !IMAGERY_NOISE.has(w))]),
|
|
261
300
|
};
|
|
@@ -286,6 +325,84 @@ export interface StockFitPlace {
|
|
|
286
325
|
readonly words?: ReadonlyArray<string>;
|
|
287
326
|
/** iox-cms#130: the place's OWN words (`stockNearWords`: the text beside it, an item's name) — the part of the business it shows. */
|
|
288
327
|
readonly near?: ReadonlyArray<string>;
|
|
328
|
+
/** iox-cms#130: the place's words as written (an item's name, the heading beside a picture) — the item it names (`stockPlaceItem`). */
|
|
329
|
+
readonly caption?: string;
|
|
330
|
+
/** `item` for a sample item's picture (its name is the item, whatever it says); a section's otherwise. */
|
|
331
|
+
readonly kind?: string;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** How a place's item is known (`StockPlaceItem.kind`). */
|
|
335
|
+
export enum StockItemKind {
|
|
336
|
+
/** A row of `STOCK_ITEMS` — the first the place's words name. */
|
|
337
|
+
Table = 'table',
|
|
338
|
+
/** A sample item's name the table does not hold: its own words, any of which a photo must name. */
|
|
339
|
+
Words = 'words',
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** What a place's picture must show (`stockPlaceItem`). */
|
|
343
|
+
export interface StockPlaceItem {
|
|
344
|
+
readonly kind: `${StockItemKind}`;
|
|
345
|
+
/** The `STOCK_ITEMS` row (`table`). */
|
|
346
|
+
readonly id?: string;
|
|
347
|
+
/** The name's own words (`words`), as compared. */
|
|
348
|
+
readonly words?: ReadonlyArray<string>;
|
|
349
|
+
/** What a search asks for it — closed English only (LS-D3): the row's `ask`; never a name's own words. */
|
|
350
|
+
readonly ask: string | null;
|
|
351
|
+
/** Asked without the type's word (`StockItem.alone`). */
|
|
352
|
+
readonly alone: boolean;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const HEBREW = /[-]/;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* THE item a place names (iox-cms#130, second half) — what its picture must show, or null when it names none. Read from
|
|
359
|
+
* the place's words as written (`caption`: an item's name, the heading beside a section's picture; else an item's `near`):
|
|
360
|
+
* 1. the first `STOCK_ITEMS` row they name, in the order said, of the rows whose meaning holds in this trade
|
|
361
|
+
* ("Breakfast on the roof" → breakfast, "צבע" → hair colour at a salon, "Avocado toast" → avocado toast);
|
|
362
|
+
* 2. else — a sample item only (its name IS what it is) — its own words: every word but a modifier
|
|
363
|
+
* (`STOCK_ITEM_MODIFIERS`), scenery, another trade's place or a function word, the Hebrew ones through the English
|
|
364
|
+
* subjects they name. A word no photo is ever tagged with (an unknown Hebrew dish) leaves the card without stock — the
|
|
365
|
+
* honest fallback, never a photo of something else under its name.
|
|
366
|
+
* A section heading that names no row names no item (its prose is not a list of things): any photo of the business.
|
|
367
|
+
*/
|
|
368
|
+
export function stockPlaceItem(place: StockFitPlace, fit: StockFit = STOCK_FIT_ANY): StockPlaceItem | null {
|
|
369
|
+
// Read once per place and fit: `planStockPhotos` asks it for every candidate photo of every place.
|
|
370
|
+
const known = ITEM_READ.get(place);
|
|
371
|
+
if (known?.fit === fit) return known.item;
|
|
372
|
+
const item = readPlaceItem(place, fit);
|
|
373
|
+
ITEM_READ.set(place, { fit, item });
|
|
374
|
+
return item;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** The last reading per place (its fit and item) — places are the planner's own slot objects, never mutated after. */
|
|
378
|
+
const ITEM_READ = new WeakMap<StockFitPlace, { fit: StockFit; item: StockPlaceItem | null }>();
|
|
379
|
+
|
|
380
|
+
function readPlaceItem(place: StockFitPlace, fit: StockFit): StockPlaceItem | null {
|
|
381
|
+
const item = place.kind === 'item';
|
|
382
|
+
const text = place.caption ?? (item ? (place.near ?? place.subject ?? []).join(' ') : '');
|
|
383
|
+
if (!text) return null;
|
|
384
|
+
const tokens = [...stockTokens(text), ...stockSubjectsHe(text).flatMap(stockTokens)];
|
|
385
|
+
const [id] = stockItemsNamed(tokens, fit.trade);
|
|
386
|
+
if (id) {
|
|
387
|
+
const row = STOCK_ITEMS[id];
|
|
388
|
+
return { kind: StockItemKind.Table, id, ask: row.ask, alone: !!row.alone };
|
|
389
|
+
}
|
|
390
|
+
if (!item) return null;
|
|
391
|
+
const named = stockNearWords(text).filter(w => !STOCK_ITEM_MODIFIERS.has(w) && !STOCK_GENERIC_WORDS.has(w) && !STOCK_TRADE_PLACE_WORDS.has(w)
|
|
392
|
+
&& !(HEBREW.test(w) && stockSubjectsHe(w).length));
|
|
393
|
+
// The business's own words say nothing of WHICH item ("Hotel parking" is the parking) — unless they are all it says.
|
|
394
|
+
const own = named.filter(w => !namesOneOf(w, fit.vocabulary));
|
|
395
|
+
const words = own.length ? own : named;
|
|
396
|
+
return words.length ? { kind: StockItemKind.Words, words, ask: null, alone: false } : null;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** Does a photo show a place's item: the row's terms among its words (`table`), or any of the name's words (`words`)? */
|
|
400
|
+
export function stockShowsItem(photo: Pick<StockPhotoTraits, 'alt' | 'tags' | 'review'>, item: StockPlaceItem): boolean {
|
|
401
|
+
const tags = photo.tags?.length ? photo.tags : String(photo.alt ?? '').split(',');
|
|
402
|
+
const tokens = [...tags, photo.review?.notes ?? ''].flatMap(stockTokens);
|
|
403
|
+
if (item.kind === StockItemKind.Table) return stockPhotoNamesItem(tokens, item.id!);
|
|
404
|
+
const words = new Set([...tokens, ...stockPhotoWords(photo)]);
|
|
405
|
+
return (item.words ?? []).some(w => words.has(w));
|
|
289
406
|
}
|
|
290
407
|
|
|
291
408
|
/** Why a photo may not stand in a place (`stockRelevance`). */
|
|
@@ -298,6 +415,8 @@ export enum StockOffSubject {
|
|
|
298
415
|
Unrelated = 'unrelated',
|
|
299
416
|
/** It shows another part of the business than the place names: a manicure under "straightening". */
|
|
300
417
|
OtherPart = 'other-part',
|
|
418
|
+
/** It does not show the item the place names (`stockPlaceItem`): croissants under "Shakshuka", a nail kit under "צבע". */
|
|
419
|
+
NotTheItem = 'not-the-item',
|
|
301
420
|
/** It does not name the business (twice in an opening). */
|
|
302
421
|
NotTheBusiness = 'not-the-business',
|
|
303
422
|
}
|
|
@@ -312,6 +431,8 @@ export interface StockRelevance {
|
|
|
312
431
|
readonly business: number;
|
|
313
432
|
/** Distinct words of the photo the place's own words name (`near`) — how closely it shows THIS place. */
|
|
314
433
|
readonly near: number;
|
|
434
|
+
/** iox-cms#130: whether it shows the item the place names (`stockShowsItem`); null — the place names none. */
|
|
435
|
+
readonly showsItem: boolean | null;
|
|
315
436
|
}
|
|
316
437
|
|
|
317
438
|
/**
|
|
@@ -323,6 +444,9 @@ export interface StockRelevance {
|
|
|
323
444
|
* words nor the business's vocabulary name;
|
|
324
445
|
* 4. the place's own words name a part of the business (`STOCK_FACETS`: hair, nails, a meal, a bed…) and the photo names
|
|
325
446
|
* other parts but none of those — an approved library photo too: it was seen for its type, never for this place;
|
|
447
|
+
* 4b. (iox-cms#130, second half) the place names an item (`stockPlaceItem`: a dish, a service, a room, the meal of a
|
|
448
|
+
* heading) and the photo does not show it (`stockShowsItem`) — croissants under "Shakshuka", a nail kit under "צבע", a
|
|
449
|
+
* newspaper under "Avocado toast" — an approved library photo too;
|
|
326
450
|
* 5. (unreviewed, type known) it does not name the business `STOCK_OPENING_TYPE_WORDS` times in an opening,
|
|
327
451
|
* `STOCK_PLACE_TYPE_WORDS` times elsewhere (iox-ui#175).
|
|
328
452
|
* No type known (`STOCK_FIT_ANY`): the never-words only. The counts are reported for reading a choice; the ranking among the
|
|
@@ -331,7 +455,12 @@ export interface StockRelevance {
|
|
|
331
455
|
export function stockRelevance(photo: Pick<StockPhotoTraits, 'alt' | 'tags' | 'review'>, place: StockFitPlace, fit: StockFit = STOCK_FIT_ANY): StockRelevance {
|
|
332
456
|
const words = stockPhotoWords(photo);
|
|
333
457
|
const near = new Set(stockPlaceNear(place));
|
|
334
|
-
const
|
|
458
|
+
const item = stockPlaceItem(place, fit);
|
|
459
|
+
const showsItem = item ? stockShowsItem(photo, item) : null;
|
|
460
|
+
const opening = OPENING_INTENTS.has(place.intent);
|
|
461
|
+
// A photo of the item a place names shows the business there (the place vouches) — an opening still names it twice.
|
|
462
|
+
const business = businessWordsOf(words, place, fit) + (showsItem && !opening ? 1 : 0);
|
|
463
|
+
const counts = { business, near: words.filter(w => near.has(w)).length, showsItem };
|
|
335
464
|
const off = (why: StockOffSubject, offWords: ReadonlyArray<string>): StockRelevance => ({ off: why, offWords, ...counts });
|
|
336
465
|
const never = words.filter(w => fit.never.has(w));
|
|
337
466
|
if (never.length) return off(StockOffSubject.Never, never);
|
|
@@ -350,7 +479,8 @@ export function stockRelevance(photo: Pick<StockPhotoTraits, 'alt' | 'tags' | 'r
|
|
|
350
479
|
const parts = stockFacetsOf([...near]);
|
|
351
480
|
const shown = parts.length ? stockFacetsOf(words) : [];
|
|
352
481
|
if (shown.length && !shown.some(f => parts.includes(f))) return off(StockOffSubject.OtherPart, shown);
|
|
353
|
-
if (
|
|
482
|
+
if (item && !showsItem) return off(StockOffSubject.NotTheItem, item.id ? [item.id] : item.words ?? []);
|
|
483
|
+
if (!reviewed && counts.business < (opening ? STOCK_OPENING_TYPE_WORDS : STOCK_PLACE_TYPE_WORDS)) {
|
|
354
484
|
return off(StockOffSubject.NotTheBusiness, []);
|
|
355
485
|
}
|
|
356
486
|
return { off: null, offWords: [], ...counts };
|
|
@@ -110,6 +110,18 @@ export const STOCK_SUBJECTS_HE: Readonly<Record<string, string>> = {
|
|
|
110
110
|
'בראנץ': 'brunch', 'בראנץ׳': 'brunch', 'קפה': 'coffee', 'אספרסו': 'espresso', 'לחם': 'bread', 'מאפים': 'pastry', 'מאפה': 'pastry',
|
|
111
111
|
'עוגה': 'cake', 'עוגות': 'cake', 'קרואסון': 'croissant', 'סוויטה': 'suite', 'סוויטות': 'suite', 'מיטה': 'bed', 'בריכה': 'pool',
|
|
112
112
|
'ג׳קוזי': 'jacuzzi', "ג'קוזי": 'jacuzzi', 'גג': 'rooftop', 'מרפסת': 'terrace', 'גינה': 'garden', 'חצר': 'courtyard',
|
|
113
|
+
// iox-cms#130 (second half): the items a place names — a salon's colour, a café's dishes and drinks, a hotel's rooms —
|
|
114
|
+
// as `STOCK_ITEMS` reads them.
|
|
115
|
+
'צבע': 'hair color', 'צביעה': 'hair color', 'צביעת': 'hair color', 'צבע לשיער': 'hair color', 'צבע שיער': 'hair color', 'פן': 'blowout',
|
|
116
|
+
'חדר': 'room', 'חדרים': 'room', 'שקשוקה': 'shakshuka', 'טוסט אבוקדו': 'avocado toast', 'טוסט': 'toast', 'לבנה': 'labneh',
|
|
117
|
+
'חומוס': 'hummus', 'פלאפל': 'falafel', 'סביח': 'sabich', 'חלומי': 'halloumi', 'בורקס': 'bourekas', 'סלט': 'salad', 'סלטים': 'salad',
|
|
118
|
+
'פנקייק': 'pancake', 'פנקייקים': 'pancake', 'וופל': 'waffle', 'גרנולה': 'granola', 'יוגורט': 'yogurt', 'חביתה': 'omelette',
|
|
119
|
+
'שייק': 'smoothie', 'סמוזי': 'smoothie', 'מיץ': 'juice', 'לימונדה': 'lemonade', 'כריך': 'sandwich', 'כריכים': 'sandwich',
|
|
120
|
+
'סנדוויץ׳': 'sandwich', 'פיצה': 'pizza', 'פסטה': 'pasta', 'המבורגר': 'burger', 'מרק': 'soup', 'יין': 'wine', 'יינות': 'wine',
|
|
121
|
+
'בירה': 'beer', 'קוקטייל': 'cocktail', 'קוקטיילים': 'cocktail', 'קפוצ׳ינו': 'cappuccino', "קפוצ'ינו": 'cappuccino', 'הפוך': 'cappuccino',
|
|
122
|
+
'לאטה': 'latte', 'קולד ברו': 'cold brew', 'קפה קר': 'iced coffee', 'אייס קפה': 'iced coffee', 'תה': 'tea', 'עוגיות': 'cookie',
|
|
123
|
+
'עוגייה': 'cookie', 'חלה': 'challah', 'בגט': 'baguette', 'מחמצת': 'sourdough', 'גלידה': 'ice cream', 'קינוח': 'dessert',
|
|
124
|
+
'קינוחים': 'dessert', 'ארוחה': 'meal', 'ארוחות': 'meal',
|
|
113
125
|
};
|
|
114
126
|
const HE_PREFIX = /^[הובלמשכ]/;
|
|
115
127
|
const HE_LETTERS = /[-]/;
|
|
@@ -202,3 +214,174 @@ export function stockPlaceNamesIn(phrases: ReadonlyArray<string>): string[] {
|
|
|
202
214
|
}
|
|
203
215
|
return [...out];
|
|
204
216
|
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* iox-cms#130 (second half) — THE ITEM a place names: the dish under a café's card, the service on a salon's, the room of
|
|
220
|
+
* a hotel's, the meal a scene's heading says. A part of the business (`STOCK_FACETS`) was not enough: the salon's "צבע"
|
|
221
|
+
* (hair colour) took a nail kit, the café's "Shakshuka" croissants and its "Avocado toast" a newspaper, because nothing
|
|
222
|
+
* asked the photo to show THAT. A place that names an item takes only a photo that shows it — none shows it: no photo
|
|
223
|
+
* (the place keeps its own fallback), never another part of the business.
|
|
224
|
+
*
|
|
225
|
+
* One row per item, specific before generic (a "Cappuccino" is the cappuccino's row, not coffee's). `terms` are English,
|
|
226
|
+
* as a place or a provider's tags say it; a phrase counts when all its words are there (`avocado, toast` is avocado toast).
|
|
227
|
+
* `ask` is what a search asks for it (closed English, LS-D3) — `alone` when the item's own name says what it is (a dish:
|
|
228
|
+
* "shakshuka", never "cafe shakshuka", which Pixabay answers with nothing), else after the type's word ("hotel room").
|
|
229
|
+
* `trades` keeps a meaning to the trades it holds in (a Hebrew "צבע" is hair colour only at a salon). `en` / `he` name it
|
|
230
|
+
* in an alt that describes a photo (`stockPhotoAbout`).
|
|
231
|
+
*/
|
|
232
|
+
export interface StockItem {
|
|
233
|
+
readonly terms: ReadonlyArray<string>;
|
|
234
|
+
readonly ask: string;
|
|
235
|
+
readonly alone?: boolean;
|
|
236
|
+
readonly trades?: ReadonlyArray<string>;
|
|
237
|
+
readonly en: string;
|
|
238
|
+
readonly he: string;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const BEAUTY = ['salon', 'spa'];
|
|
242
|
+
const FOOD = ['cafe-bakery', 'restaurant', 'bar-winery', 'hotel-bnb', 'venue-events'];
|
|
243
|
+
|
|
244
|
+
export const STOCK_ITEMS: Readonly<Record<string, StockItem>> = {
|
|
245
|
+
// beauty
|
|
246
|
+
hairColor: {
|
|
247
|
+
terms: ['hair color', 'hair colour', 'hair dye', 'haircolor', 'hair coloring', 'hair colouring', 'dye', 'dyeing', 'highlights', 'balayage', 'ombre'],
|
|
248
|
+
ask: 'hair color', alone: true, trades: BEAUTY, en: 'Hair colour', he: 'צבע לשיער',
|
|
249
|
+
},
|
|
250
|
+
straightening: {
|
|
251
|
+
terms: ['straighten', 'straightening', 'straightener', 'keratin', 'flat iron', 'hair iron', 'blowout', 'blow dry', 'blowdry'],
|
|
252
|
+
ask: 'keratin', trades: BEAUTY, en: 'Hair straightening', he: 'החלקת שיער',
|
|
253
|
+
},
|
|
254
|
+
haircut: { terms: ['haircut', 'hair cut', 'haircutting', 'cut', 'trim', 'hairstyle', 'hairstyling', 'barber', 'barbershop'], ask: 'haircut', trades: BEAUTY, en: 'Haircut', he: 'תספורת' },
|
|
255
|
+
pedicure: { terms: ['pedicure', 'toenail', 'foot care'], ask: 'pedicure', trades: BEAUTY, en: 'Pedicure', he: 'פדיקור' },
|
|
256
|
+
manicure: { terms: ['manicure', 'manicurist', 'nail', 'fingernail', 'nail polish', 'nail art'], ask: 'manicure', trades: BEAUTY, en: 'Manicure', he: 'מניקור' },
|
|
257
|
+
makeup: { terms: ['makeup', 'make up', 'lipstick', 'mascara', 'eyeshadow', 'eyeliner'], ask: 'makeup', trades: BEAUTY, en: 'Make-up', he: 'איפור' },
|
|
258
|
+
lashes: { terms: ['eyelash', 'lash', 'lash extension'], ask: 'eyelash', trades: BEAUTY, en: 'Eyelashes', he: 'ריסים' },
|
|
259
|
+
brows: { terms: ['eyebrow', 'brow'], ask: 'eyebrow', trades: BEAUTY, en: 'Eyebrows', he: 'גבות' },
|
|
260
|
+
facial: { terms: ['facial', 'skincare', 'skin care', 'face mask', 'facial mask'], ask: 'facial', trades: BEAUTY, en: 'Facial', he: 'טיפול פנים' },
|
|
261
|
+
massage: { terms: ['massage', 'masseur', 'masseuse'], ask: 'massage', en: 'Massage', he: 'עיסוי' },
|
|
262
|
+
// stays
|
|
263
|
+
// A room is a hotel's to name ("our treatment rooms" at a spa is the spa, a florist's "flower bed" no bed).
|
|
264
|
+
room: { terms: ['room', 'bedroom', 'hotel room', 'guest room', 'suite', 'bed', 'bedding', 'headboard'], ask: 'room', trades: ['hotel-bnb'], en: 'Room', he: 'חדר' },
|
|
265
|
+
jacuzzi: { terms: ['jacuzzi', 'hot tub', 'whirlpool'], ask: 'jacuzzi', en: 'Jacuzzi', he: 'ג׳קוזי' },
|
|
266
|
+
pool: { terms: ['pool', 'swimming pool'], ask: 'pool', en: 'Pool', he: 'בריכה' },
|
|
267
|
+
// dishes — their own name says what they are
|
|
268
|
+
shakshuka: { terms: ['shakshuka', 'shakshouka'], ask: 'shakshuka', alone: true, trades: FOOD, en: 'Shakshuka', he: 'שקשוקה' },
|
|
269
|
+
avocadoToast: { terms: ['avocado toast'], ask: 'avocado toast', alone: true, trades: FOOD, en: 'Avocado toast', he: 'טוסט אבוקדו' },
|
|
270
|
+
labneh: { terms: ['labneh', 'labne', 'labaneh'], ask: 'labneh', alone: true, trades: FOOD, en: 'Labneh', he: 'לבנה' },
|
|
271
|
+
hummus: { terms: ['hummus', 'houmous', 'humus'], ask: 'hummus', alone: true, trades: FOOD, en: 'Hummus', he: 'חומוס' },
|
|
272
|
+
falafel: { terms: ['falafel'], ask: 'falafel', alone: true, trades: FOOD, en: 'Falafel', he: 'פלאפל' },
|
|
273
|
+
sabich: { terms: ['sabich'], ask: 'sabich', alone: true, trades: FOOD, en: 'Sabich', he: 'סביח' },
|
|
274
|
+
halloumi: { terms: ['halloumi'], ask: 'halloumi', alone: true, trades: FOOD, en: 'Halloumi', he: 'חלומי' },
|
|
275
|
+
bourekas: { terms: ['bourekas', 'burekas', 'borek', 'bureka'], ask: 'borek', alone: true, trades: FOOD, en: 'Bourekas', he: 'בורקס' },
|
|
276
|
+
pancake: { terms: ['pancake', 'crepe'], ask: 'pancakes', alone: true, trades: FOOD, en: 'Pancakes', he: 'פנקייק' },
|
|
277
|
+
waffle: { terms: ['waffle'], ask: 'waffles', alone: true, trades: FOOD, en: 'Waffles', he: 'וופל' },
|
|
278
|
+
granola: { terms: ['granola', 'muesli', 'yogurt', 'yoghurt'], ask: 'granola', alone: true, trades: FOOD, en: 'Granola', he: 'גרנולה' },
|
|
279
|
+
omelette: { terms: ['omelette', 'omelet'], ask: 'omelette', alone: true, trades: FOOD, en: 'Omelette', he: 'חביתה' },
|
|
280
|
+
salad: { terms: ['salad'], ask: 'salad', alone: true, trades: FOOD, en: 'Salad', he: 'סלט' },
|
|
281
|
+
sandwich: { terms: ['sandwich', 'bagel'], ask: 'sandwich', alone: true, trades: FOOD, en: 'Sandwich', he: 'כריך' },
|
|
282
|
+
pizza: { terms: ['pizza'], ask: 'pizza', alone: true, trades: FOOD, en: 'Pizza', he: 'פיצה' },
|
|
283
|
+
pasta: { terms: ['pasta', 'spaghetti', 'ravioli'], ask: 'pasta', alone: true, trades: FOOD, en: 'Pasta', he: 'פסטה' },
|
|
284
|
+
burger: { terms: ['burger', 'hamburger'], ask: 'burger', alone: true, trades: FOOD, en: 'Burger', he: 'המבורגר' },
|
|
285
|
+
soup: { terms: ['soup'], ask: 'soup', alone: true, trades: FOOD, en: 'Soup', he: 'מרק' },
|
|
286
|
+
toast: { terms: ['toast', 'french toast'], ask: 'toast', alone: true, trades: FOOD, en: 'Toast', he: 'טוסט' },
|
|
287
|
+
// drinks, specific first
|
|
288
|
+
icedCoffee: { terms: ['cold brew', 'iced coffee', 'iced latte', 'cold coffee'], ask: 'iced coffee', alone: true, trades: FOOD, en: 'Iced coffee', he: 'קפה קר' },
|
|
289
|
+
cappuccino: { terms: ['cappuccino', 'latte', 'flat white', 'latte art', 'milk foam'], ask: 'cappuccino', alone: true, trades: FOOD, en: 'Cappuccino', he: 'קפוצ׳ינו' },
|
|
290
|
+
espresso: { terms: ['espresso', 'ristretto', 'doppio'], ask: 'espresso', alone: true, trades: FOOD, en: 'Espresso', he: 'אספרסו' },
|
|
291
|
+
coffee: { terms: ['coffee', 'espresso', 'cappuccino', 'latte', 'americano', 'barista', 'coffee bean'], ask: 'coffee', en: 'Coffee', he: 'קפה' },
|
|
292
|
+
tea: { terms: ['tea', 'herbal tea', 'teapot'], ask: 'tea', en: 'Tea', he: 'תה' },
|
|
293
|
+
smoothie: { terms: ['smoothie', 'milkshake'], ask: 'smoothie', alone: true, trades: FOOD, en: 'Smoothie', he: 'שייק' },
|
|
294
|
+
juice: { terms: ['juice', 'lemonade', 'orange juice'], ask: 'juice', alone: true, trades: FOOD, en: 'Juice', he: 'מיץ' },
|
|
295
|
+
wine: { terms: ['wine', 'wine glass'], ask: 'wine', en: 'Wine', he: 'יין' },
|
|
296
|
+
beer: { terms: ['beer'], ask: 'beer', en: 'Beer', he: 'בירה' },
|
|
297
|
+
cocktail: { terms: ['cocktail', 'mojito', 'margarita'], ask: 'cocktail', alone: true, en: 'Cocktail', he: 'קוקטייל' },
|
|
298
|
+
// baking, specific first
|
|
299
|
+
croissant: { terms: ['croissant'], ask: 'croissant', alone: true, trades: FOOD, en: 'Croissant', he: 'קרואסון' },
|
|
300
|
+
cookie: { terms: ['cookie', 'biscuit'], ask: 'cookies', alone: true, trades: FOOD, en: 'Cookies', he: 'עוגיות' },
|
|
301
|
+
cake: { terms: ['cake', 'cheesecake', 'cupcake'], ask: 'cake', alone: true, trades: FOOD, en: 'Cake', he: 'עוגה' },
|
|
302
|
+
dessert: { terms: ['dessert', 'ice cream', 'gelato', 'sorbet', 'pudding', 'tart'], ask: 'dessert', alone: true, trades: FOOD, en: 'Dessert', he: 'קינוח' },
|
|
303
|
+
bread: { terms: ['bread', 'sourdough', 'loaf', 'baguette', 'challah'], ask: 'bread', alone: true, trades: FOOD, en: 'Bread', he: 'לחם' },
|
|
304
|
+
pastry: { terms: ['pastry', 'danish', 'puff pastry', 'cinnamon roll'], ask: 'pastry', alone: true, trades: FOOD, en: 'Pastry', he: 'מאפה' },
|
|
305
|
+
// meals
|
|
306
|
+
breakfast: { terms: ['breakfast', 'brunch'], ask: 'breakfast', en: 'Breakfast', he: 'ארוחת בוקר' },
|
|
307
|
+
dinner: { terms: ['dinner', 'supper'], ask: 'dinner', en: 'Dinner', he: 'ארוחת ערב' },
|
|
308
|
+
lunch: { terms: ['lunch'], ask: 'lunch', en: 'Lunch', he: 'ארוחת צהריים' },
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Words of an item's name that only say WHICH or HOW (English, `stockWord`s): never the item a photo must show ("Deluxe
|
|
313
|
+
* room" is a room, "Classic labneh plate" labneh). A name of only these, and of the business's own words, names no item.
|
|
314
|
+
*/
|
|
315
|
+
export const STOCK_ITEM_MODIFIERS: ReadonlySet<string> = new Set([
|
|
316
|
+
'classic', 'signature', 'special', 'house', 'homemade', 'home', 'fresh', 'daily', 'seasonal', 'premium', 'deluxe', 'luxury',
|
|
317
|
+
'standard', 'superior', 'double', 'single', 'twin', 'family', 'small', 'large', 'big', 'mini', 'full', 'half', 'hot', 'cold',
|
|
318
|
+
'iced', 'warm', 'sweet', 'savory', 'savoury', 'green', 'red', 'white', 'black', 'new', 'best', 'famous', 'traditional',
|
|
319
|
+
'original', 'israeli', 'mediterranean', 'french', 'italian', 'local', 'organic', 'vegan', 'vegetarian', 'gluten', 'free',
|
|
320
|
+
'plate', 'bowl', 'dish', 'platter', 'board', 'combo', 'set', 'menu', 'option', 'package', 'treatment', 'session',
|
|
321
|
+
'consultation', 'basic', 'express', 'extra', 'view', 'side',
|
|
322
|
+
].map(stockWord));
|
|
323
|
+
|
|
324
|
+
/** A text's words as compared, in order (accents gone, `stockWord`), every word kept — the order an item is read in. */
|
|
325
|
+
export function stockTokens(text: unknown): string[] {
|
|
326
|
+
if (typeof text !== 'string') return [];
|
|
327
|
+
return text.replace(HTML_TAG, ' ').normalize('NFD').replace(/\p{M}+/gu, '').toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(stockWord);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** Per item, its terms as compared (each a list of `stockWord`s). */
|
|
331
|
+
const ITEM_TERMS: ReadonlyArray<[string, ReadonlyArray<ReadonlyArray<string>>]> = Object.entries(STOCK_ITEMS)
|
|
332
|
+
.map(([id, item]) => [id, item.terms.map(t => stockTokens(t))]);
|
|
333
|
+
|
|
334
|
+
/** Where in `tokens` a term is first said (all its words there; the first of them), or -1. */
|
|
335
|
+
function termAt(term: ReadonlyArray<string>, tokens: ReadonlyArray<string>): number {
|
|
336
|
+
let at = Infinity;
|
|
337
|
+
for (const w of term) {
|
|
338
|
+
const i = tokens.indexOf(w);
|
|
339
|
+
if (i < 0) return -1;
|
|
340
|
+
at = Math.min(at, i);
|
|
341
|
+
}
|
|
342
|
+
return at;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* The `STOCK_ITEMS` a place's words name, in the order they are said (ties: the table's order — the specific row first),
|
|
347
|
+
* those whose meaning holds in `trade` only (a row without `trades` holds everywhere; no trade known: every row).
|
|
348
|
+
*/
|
|
349
|
+
export function stockItemsNamed(tokens: ReadonlyArray<string>, trade?: string | null): string[] {
|
|
350
|
+
const found: Array<{ id: string; at: number; row: number }> = [];
|
|
351
|
+
ITEM_TERMS.forEach(([id, terms], row) => {
|
|
352
|
+
const trades = STOCK_ITEMS[id].trades;
|
|
353
|
+
if (trade && trades && !trades.includes(trade)) return;
|
|
354
|
+
const at = terms.map(t => termAt(t, tokens)).filter(i => i >= 0);
|
|
355
|
+
if (at.length) found.push({ id, at: Math.min(...at), row });
|
|
356
|
+
});
|
|
357
|
+
return found.sort((a, b) => a.at - b.at || a.row - b.row).map(f => f.id);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** Does a photo show an item of the table: one of its terms, every word of it among the photo's words? */
|
|
361
|
+
export function stockPhotoNamesItem(photoWords: ReadonlyArray<string>, id: string): boolean {
|
|
362
|
+
const terms = ITEM_TERMS.find(([row]) => row === id)?.[1] ?? [];
|
|
363
|
+
return terms.some(t => termAt(t, photoWords) >= 0);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** The longest description of a photo, in items. */
|
|
367
|
+
const ABOUT_MAX_ITEMS = 2;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* What a photo shows, in the site's language, from its OWN words (iox-cms#130): the first items of `STOCK_ITEMS` its tags
|
|
371
|
+
* name, in the tags' order (each tag read alone — "croissant, coffee" is "Croissant and coffee" / "קרואסון וקפה"), at most
|
|
372
|
+
* two. Nothing the table names: '' (a picture whose subject is not known is passed over by a screen reader, never named
|
|
373
|
+
* by the words of a place it was not chosen for).
|
|
374
|
+
*/
|
|
375
|
+
export function stockPhotoAbout(tags: ReadonlyArray<string>, locale?: string | null): string {
|
|
376
|
+
const he = locale === 'he';
|
|
377
|
+
const names: string[] = [];
|
|
378
|
+
for (const tag of tags) {
|
|
379
|
+
const tokens = stockTokens(tag);
|
|
380
|
+
const hit = ITEM_TERMS.find(([, terms]) => terms.some(t => termAt(t, tokens) >= 0))?.[0];
|
|
381
|
+
const name = hit ? (he ? STOCK_ITEMS[hit].he : STOCK_ITEMS[hit].en) : undefined;
|
|
382
|
+
if (name && !names.includes(name)) names.push(name);
|
|
383
|
+
if (names.length >= ABOUT_MAX_ITEMS) break;
|
|
384
|
+
}
|
|
385
|
+
if (names.length < 2) return names[0] ?? '';
|
|
386
|
+
return he ? `${names[0]} ו${names[1]}` : `${names[0]} and ${names[1].toLowerCase()}`;
|
|
387
|
+
}
|
package/styles/iox-design.css
CHANGED
|
@@ -2580,13 +2580,22 @@ dialog[data-iox-dialog].iox-es.iox-role-shop-cart-drawer:is([data-iox-closing],
|
|
|
2580
2580
|
second leaves. The node holds that hide too (`resp.mobile`), but an Image's own component rule (`display: block`, one
|
|
2581
2581
|
attribute) comes after the layout's styles on the engine and wins the tie — vectoriox/iox-ui#104 — so the two classes
|
|
2582
2582
|
here hold it. The canvas sizes by its frame. */
|
|
2583
|
+
/* iox-ui#196 (the cue never meets the action): on a phone the frame's bottom padding is as small as the cue's own 20px, so
|
|
2584
|
+
a cue standing over the frame sat in the words' panel — one line in its padding, two lines (the hotel's place line at
|
|
2585
|
+
92% of 390) 7px across "Ask for a booking". There the cue is the frame's LAST LINE instead: in the flow under the words
|
|
2586
|
+
(the frame is a column at its end), at the inline end, the frame's gap between them — it pushes the words up, it can
|
|
2587
|
+
never cover them, however many lines it wraps to. The node says `position: relative` for the phone (the canvas forces a
|
|
2588
|
+
node's position); this rule holds a cue saved before on the live site, and its insets either way. On a laptop the
|
|
2589
|
+
frame's padding (≥ 4vw) is the cue's room and it stays over the frame's corner. */
|
|
2583
2590
|
@media (max-width: 767px) {
|
|
2584
2591
|
.iox-role-opening .iox-role-opening-card { inset: auto; }
|
|
2585
2592
|
.iox-role-opening .iox-role-opening-second { display: none; }
|
|
2593
|
+
.iox-role-opening .iox-role-opening-cue { position: relative; inset: auto; align-self: flex-end; }
|
|
2586
2594
|
}
|
|
2587
2595
|
@container iox-canvas (max-width: 767px) {
|
|
2588
2596
|
.iox-role-opening .iox-role-opening-card { inset: auto; }
|
|
2589
2597
|
.iox-role-opening .iox-role-opening-second { display: none; }
|
|
2598
|
+
.iox-role-opening .iox-role-opening-cue { inset: auto; align-self: flex-end; }
|
|
2590
2599
|
}
|
|
2591
2600
|
/* The frame settles once from the full screen into its inset card as the page loads (≤ 700 ms, never holding the
|
|
2592
2601
|
scroll); a picture comes slowly closer (≥ 15 s, the contract's rules). Both only where motion is welcome — under
|