@vectoriox/iox-ui 5.118.0 → 5.119.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/assist-core/index.d.ts +41 -13
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs +91 -12
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +178 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/generation-core/index.d.ts +56 -2
- package/package.json +1 -1
- package/src/assist-core/assist-turn.ts +3 -3
- package/src/assist-core/page-edits.ts +6 -5
- package/src/assist-core/page-style.ts +115 -13
- package/src/assist-core/page-words.ts +2 -1
- package/src/generation-core/adjustments.ts +182 -0
- package/src/generation-core/public-api.ts +1 -0
|
@@ -11270,5 +11270,59 @@ declare function applyLayoutEdits(page: LayoutPage, edits: ReadonlyArray<LayoutE
|
|
|
11270
11270
|
/** The strict format a repair is asked in: `{ edits: [{ op, path, value }] }`, every key required. */
|
|
11271
11271
|
declare function layoutRepairJsonSchema(): JsonSchema;
|
|
11272
11272
|
|
|
11273
|
-
export { ACCOUNT_ENTRY_ID, ACTION_START_SCALE, ACTIVE_BUILD_STATUSES, AI_COMPOSED_PAGES_ESTIMATED, AI_PLAN_REASKED_PART, AI_REFUSAL_NEXT, AI_REFUSAL_STATUS, AI_STEPS, AI_STEP_FEATURE, AI_STEP_LABELS, AI_STEP_NEEDS, AI_STEP_PART_TOKENS, AI_STEP_TYPICAL_TOKENS, ART_DIRECTION_PARTS, AiCallStatus, AiCapability, AiFeature, AiGenerationStage, AiKeyMode, AiLimit, AiNextKind, AiProviderId, AiRefusalCode, AiStep, BAR_ITEMS_MAX, BAR_ITEMS_MIN, BASELINE_ROLES, BUILD_STEPS, BaselineRole, BindScope, BuildNoticeCode, BuildStep, CONTENT_ROLE_MEANINGS, CREDITS_PER_USD, CardBindTarget, CheckSeverity, ComposeError, ComposeIssueCode, ContentFieldControl, ContentFieldType, ContentRole, ContentTypeAction, CreatedKind, DANGLING_LINK_CODES, DEFAULT_FOOTER_PATTERN, DEFAULT_PHONE_MENU_BREAKPOINT, DEFAULT_SITE_LOCALE, ENTRANCE_EASING, ENTRANCE_ORIGIN_LOOK, ENTRANCE_TRIGGER, EntrancePart, EntranceSide, FACT_KEYS, FIELD_TYPE_OF_CONTROL, FILL_ASPECT, FILM_PATTERN, FINAL_GENERATION_STAGES, FINDING_SEVERITY, FOOTER_TOKEN, FilmUnplaced, FooterArrange, FooterClosing, FooterGround, FooterHold, FooterIngredient, FooterMixError, FooterRepairCode, GRAMMAR_TOO_LARGE_MESSAGE, GlobalSlot, HEADER_TOKEN, HEBREW_PREFIXES, HeaderIngredient, HeaderMixError, JSON_SCHEMA_BANNED_KEYWORDS, JsonSchemaShapeError, KeptReason, LAYOUT_ACCENT_TEXT, LAYOUT_BEAT_DELAY, LAYOUT_CHECK_VIEWPORT, LAYOUT_COLOUR_TOKEN, LAYOUT_COLUMN_GAP, LAYOUT_DEPTH_ON_PHONE, LAYOUT_DRIFT, LAYOUT_EASING, LAYOUT_ENTRANCE_MAX_MS, LAYOUT_FONT_SIZE, LAYOUT_GUTTER, LAYOUT_HIDDEN_OPACITY, LAYOUT_KINETIC_KINDS, LAYOUT_LINE_HEIGHT, LAYOUT_LIST_TOKEN, LAYOUT_MIX_OFFERED, LAYOUT_MIX_WORDS, LAYOUT_OPERATED, LAYOUT_PACE, LAYOUT_PHONE_BREAKPOINT, LAYOUT_PHONE_PADDING, LAYOUT_PHOTO_ASPECT, LAYOUT_READY_MADE_TOKEN, LAYOUT_RISE, LAYOUT_SCREEN_PX, LAYOUT_TEXT_KINDS, LAYOUT_TOOLTIP_TRAIT, LAYOUT_VIEWPORTS, LAYOUT_WIRE_AUTOPLAY_MS, LIST_CARD_PART, LIST_INGREDIENTS, LIST_LONG_WORDS, LIST_ROLE_WORDS, LIST_TABLE, LayoutAlign, LayoutBleed, LayoutButtonVariant, LayoutColour, LayoutColourMode, LayoutDepth, LayoutDial, LayoutEase, LayoutEditOp, LayoutEnter, LayoutGalleryEffect, LayoutGapCode, LayoutIssueCode, LayoutLayerKind, LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListHow, LayoutListItem, LayoutListMove, LayoutListPhone, LayoutListRole, LayoutListWho, LayoutMendKind, LayoutMixIngredient, LayoutNavKind, LayoutPace, LayoutPhotoShape, LayoutPhotoSource, LayoutRole, LayoutSectionKind, LayoutSequenceToken, LayoutSide, LayoutSignatureId, LayoutSize, LayoutSourceChoice, LayoutTrackProp, LayoutTransition, LayoutViewport, MAX_SITE_PICTURES, NAV_PART_LABELS, NAV_SHAPE_COPY, NEUTRAL_STYLE_PROPS, NODE_BASELINES, NO_TOKENS, NavPagesSource, NavRole, NavShape, NavShapeError, PAGE_ARCHETYPES, PHOTO_ANALYSIS_WIDTH, PHOTO_CALM_DETAIL, PHOTO_GRID, PHOTO_LIGHT_LUMINANCE, PICTURE_ASPECTS, PICTURE_NEVER, PICTURE_REAL_PLACE_FAMILIES, PICTURE_REROLL_EVERY, PICTURE_REVIEW_FORMAT, PICTURE_REVIEW_SHAPE, PICTURE_TEXT_CONTRAST, PICTURE_WORLDS, PICTURE_WORLD_IDS, PLAN_EDITS_ANSWER_SHAPES, PLAN_EDITS_PART_SCHEMA_NAMES, PLAN_EDIT_OP_PART, PLAN_EDIT_SHAPE, PLAN_EDIT_WIRE_KEYS, PLAN_PARTS, PLAN_PART_KEYS, PLAN_WIRE_DERIVED, PLAN_WIRE_PART_SCHEMA_NAMES, PLAN_WIRE_SHAPE, PRICING_PATTERN, PROOF_FINGERPRINTS, PUBLISH_BLOCKING_PLACEHOLDERS, PageDataKind, PathIssueCollector, PatternDirective, PatternGlobalPosition, PatternOpens, PatternPlaceholder, PatternRecipe, PhoneMenuBreakpoint, PhotoTone, PictureRefusal, PictureWorld, PlaceholderKind, PlanChangeAction, PlanChangeKind, PlanDataSourceMode, PlanDataSourceType, PlanEditIssueCode, PlanEditOp, PlanEditsOutcome, PlanPart, PlanWireEntry, PlanWireShapeError, PlanWordIssueCode, PreflightRefusalCode, PriceBindTarget, PublishRefusalCode, PublishScope, RENDER_CHECK, REQUIRED_CONTENT_ROLES, RelativeOp, SAMPLE_IMAGE_REF, SCENE_LEVEL, SCENE_OTHER_PAGES, SCRIM_BACKGROUND, SCRIM_COVER, SCRIM_LEVELS, SHOP_CART_BUTTON_ID, SHOP_CART_DRAWER_ID, SHOP_FIELDS, SHOP_LATEST_LIMIT, SHOP_LIST_LIMIT, SHOP_NEED, SHOP_ONLY_CONTENT_ROLES, SHOP_PRODUCTS_MAX, SHOP_ROLES, SHOP_SLUG_FIELD, SHOWCASE_FILM, SHOWCASE_SHOP, SIGN_IN_DIALOG_ID, SITE_CHECKS, SITE_FACT_LABELS, SITE_HEADER_PATTERN, SITE_LIBRARY, SITE_LOCALES, SITE_NEED_IDS, SITE_PATTERNS, SITE_PLAN_VERSION, SITE_TEMPLATES, SPEC_SITE_ARCHETYPES, SPEC_SITE_COPY_LENGTHS, SPEC_SITE_DENSITY_COPY, SPEC_SITE_FACTS, SPEC_SITE_FOOTER_PARTS, SPEC_SITE_LAYOUT, SPEC_SITE_LIBRARY, SPEC_SITE_LOCALES, SPEC_SITE_NEED_IDS, SPEC_SITE_PATTERNS, SPEC_SITE_PICTURE_NEVER, SPEC_SITE_PICTURE_WORLDS, SPEC_SITE_PLAN_SHAPE, SPEC_SITE_REQUIRED_ROLES, SPEC_SITE_ROLES, SPEC_SITE_TEMPLATES, STOCK_FAMILIES, STOCK_FAMILY_INTENTS, STOCK_INTENT_ORDER, STOCK_INTENT_SUBJECTS, STOCK_ITEM_ASPECT, STOCK_MIN_KEPT, STOCK_PROVIDER_TERMS, STOCK_SEED_MARGIN, STOCK_SUBJECT_WORDS, STORE_CONTACT_CODES, STRICT_SCHEMA_BUDGET, STRICT_SCHEMA_LIMITS, STUDIO_TEMPLATE, ScrimLevel, SectionFallbackLastResort, SectionSwapAction, SectionSwapRule, ShopResource, ShopSourceRole, SiteBuildKind, SiteBuildStatus, SiteCheckId, SiteFindingCode, SiteLocale, SitePlanError, SitePlanIssueCode, SitePlanSourceKind, SiteTemplateError, SiteTemplateId, StepState, StockIntent, StockOrientation, StockProviderId, StockReviewFlag, StockReviewVerdict, StockSlotKind, StockSubject, WORDS_AREA_DEFAULT_SHARE, WordsEdge, addBarItem, addStockCredits, aiRefusalNext, aiStepParts, applyLayoutEdits, applyOwnPhotoGalleries, applyPictureScrims, applyPlanEdits, applyStockItemPhotos, applyStockPhotos, archetypeIssues, areaLuminance, artDirectionFor, artDirectionIssues, artDirectionPreamble, aspectRatioOf, assertStyleSlots, assertValidSitePlan, auditLayoutMotion, auditSite, barIconForRoute, blocksPublish, brandHueWord, buildKeys, buildStepFacts, buildStepsOf, builtHomePageId, calmParts, calmUnder, checkFooter, checkLayout, checkList, chooseScrim, composeContextOf, composeLayout, composeNavHeader, composePresetForm, composeSection, composeSite, contentTypeOfSource, contentTypePreviewFields, contentTypeToWire, copyLengthOf, costUsd, coverCrop, createSerializedNode, creditsOfUsd, dataSourceToWire, derivedBeats, derivedDataSources, derivedShopSources, describeInventoryForPrompt, describeListShape, describePlanData, describeShapeKey, distinctFooter, drawnHeaderMix, driftAt, driftOverlap, emptyAreaPhrase, entranceAction, entranceInteraction, estimatePictures, estimateStepCredits, expandLayoutWire, expandPlanWire, expandWireContentType, expandWireDataSource, expandWireEdit, expandWireField, expandWirePage, expandWireSection, expandWireShop, factIssues, failedBuildStep, fallBackBySection, fieldToWire, filmOfPlan, filmPlacement, findNavRoot, fingerprintOf, fingerprintOfPlanPage, footerMeaning, footerMix, footerMixFromWords, footerMixOfPlan, footerMixWords, footerPattern, footerPatternIdOf, footerReferences, footerTokenOf, footerTokenWords, footerWireWords, footerWords, frameWords, headerMeaning, headerMix, headerMixOfNavKind, headerMixOfPlan, headerReferences, headerTokenOf, headerTokenWords, headerWords, isActiveBuild, isLayoutRule, isNonEmptyString, isPictureWorld, isPlainObject, isRtlLocale, isShopResource, jsonAnyOf, jsonBoolean, jsonClosedObject, jsonInteger, jsonListOf, jsonOneOf, jsonSchemaKeywords, jsonSchemaObjects, jsonShapedObject, jsonText, judgeLayoutRender, layerShownSpans, layoutBandScheme, layoutBoxPx, layoutColumnsVw, layoutDesignOf, layoutDialOf, layoutDriftPhoto, layoutElementStyle, layoutGalleryLists, layoutGallerySources, layoutGlideDepth, layoutHeldStill, layoutListBinding, layoutListShapes, layoutLookChanges, layoutLookOf, layoutMixOffered, layoutMotionOf, layoutNodeClass, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutPathSteps, layoutPhotoIds, layoutPresetColours, layoutPresetOf, layoutRepairJsonSchema, layoutRoomPx, layoutRuleEdge, layoutShapeHasPurpose, layoutStillLine, layoutTextFits, layoutTextWidthEm, layoutToWire, layoutVoidScreens, layoutVoids, layoutWireJsonSchema, layoutWirePartWords, listBuiltWords, listIngredientWords, listMeaning, listNeverIsEmpty, listTokenOf, listTokensOf, listWait, listWords, luminanceOf, measureLayout, mendLayout, menuAtEveryWidth, modelCanDo, moveBarItem, namedFooterMix, namedHeaderMix, navPages, navShapeBreakpoint, navShapeOf, nextSourceOf, nodeBindPaths, orientationOfRatio, ownPhotoFit, pageListIssues, pageToWire, parseLayoutPhotoId, parsePatternPath, parseSampleImageRef, pathAt, patternById, patternHasForm, patternLinkSlots, patternListGap, patternManifest, patternNeedsBinding, patternNodes, patternOptionalParts, patternRoleNeeds, patternScopes, patternSlotBudgets, patternSlots, patternTakesBinding, phoneGapBefore, phoneMenuPages, phoneWordsColour, photoInventory, photoShapeOf, pictureAspect, pictureItemsOf, picturePrompt, pictureRefusalOf, pictureRerolls, pictureReviewIssues, pictureReviewJsonSchema, pictureReviewPasses, pictureSlotKey, pictureTargets, pictureTryFits, pixelsUnder, placeFilm, planEditOps, planEditToWire, planEditWireGaps, planEditWireKeys, planEditWireOps, planEditWireShape, planEditsFromWire, planEditsJsonSchema, planEditsToWire, planEntrances, planFromTemplate, planHasShopSource, planLayoutPhotos, planNavShape, planOwnPhotos, planPartOfPath, planPartToWire, planPictures, planSells, planStockPhotos, planToWire, planWireGaps, planWirePartJsonSchema, planWirePartShape, planWordIssues, pricesIn, publishRefusal, publishVerdict, readyMadeColumn, recipeListBinds, recomposeAsks, releasedLayoutDefaults, removeBarItem, requiredAcknowledgements, requiredShapeKeys, roleField, routeMatches, routeParams, samenessIssues, sampleImageRef, scoreStockPhoto, screenFontSize, screenWordColumns, screenWordMisfit, screenWordOverflowPx, sectionEntrances, sectionPatternIds, sectionToWire, sectionTokenOf, sectionsNamed, sequenceShare, sequenceTokenOf, setStyleProps, shapeKeys, shopCategoriesOf, shopContentType, shopSourceAliases, showcaseGlobals, showcasePages, showcasePlans, showcaseScenes, showcaseStorePages, shownTogether, signatureOf, siteNavPages, siteSells, slotBudget, splitSide, stockCopyKey, stockCreditLine, stockCreditLines, stockCreditNode, stockCreditNodeId, stockFits, stockGroupOf, stockItemSlots, stockKept, stockPhotoRatio, stockPhotoSubject, stockPhotoUsable, stockPhotoWords, stockSlots, stockWord, stockWords, strictSchemaComplexity, strictSchemaRefusal, toneOf, typicalStepTokens, validatePlanEdits, validateSitePlan, variantNamesOf, walkSerialized, wireContentTypeJsonSchema, wireDataSourceJsonSchema, wireFieldJsonSchema, wirePageJsonSchema, wireSectionJsonSchema, wireShopProductJsonSchema, withDerivedSources, withDistinctFooter, wordPattern, wordsOverPhotos, wordsOverPicture, writtenTexts };
|
|
11274
|
-
|
|
11273
|
+
/**
|
|
11274
|
+
* `ADJUSTMENTS` — the size and spacing STEPS an element may take by asking (ai-session-panel-plan `adjust`, ai-assist-plan
|
|
11275
|
+
* AI2c). "Make the hero taller" is a row of this table, never a number: the model picks an axis and a step, this file is
|
|
11276
|
+
* the ONLY place their style literals come from, and every value is a token of the look wherever a token exists (the
|
|
11277
|
+
* section rhythm `--iox-space-section`, a framed box's padding `--iox-space-pad`) — so a re-themed site keeps its steps in
|
|
11278
|
+
* proportion. The same pure functions read the current step (`adjustStepOf`) and write a new one (`adjustStyleProps`) on
|
|
11279
|
+
* the server's check and in the builder's trial.
|
|
11280
|
+
*
|
|
11281
|
+
* Every value is a desktop-first BASE value: a width the author (or the composer) set on its own keeps its own value.
|
|
11282
|
+
*/
|
|
11283
|
+
/** What a step changes. */
|
|
11284
|
+
declare enum AdjustAxis {
|
|
11285
|
+
/** How tall a section stands: fit its content · tall · one screen. */
|
|
11286
|
+
Height = "height",
|
|
11287
|
+
/** The space inside: a section's rhythm above and below, a card's or panel's padding all round. */
|
|
11288
|
+
Spacing = "spacing",
|
|
11289
|
+
/** Where words sit on their line: start · centre · end (logical — follows the page's direction). */
|
|
11290
|
+
Align = "align"
|
|
11291
|
+
}
|
|
11292
|
+
/** Which kind of element an axis acts on — a section's spacing is its rhythm, a card's is its padding. */
|
|
11293
|
+
declare enum AdjustKind {
|
|
11294
|
+
Section = "section",
|
|
11295
|
+
Box = "box",
|
|
11296
|
+
Words = "words"
|
|
11297
|
+
}
|
|
11298
|
+
/** What a node holds when its value is none of the steps — the author's (or the composer's) own. */
|
|
11299
|
+
declare const ADJUST_OWN = "own";
|
|
11300
|
+
interface AdjustStep {
|
|
11301
|
+
readonly id: string;
|
|
11302
|
+
/** How the owner reads it on a change card. */
|
|
11303
|
+
readonly label: string;
|
|
11304
|
+
}
|
|
11305
|
+
/** The steps of each axis, smallest first. */
|
|
11306
|
+
declare const ADJUST_STEPS: Readonly<Record<AdjustAxis, ReadonlyArray<AdjustStep>>>;
|
|
11307
|
+
declare const ADJUST_AXIS_LABELS: Readonly<Record<AdjustAxis, string>>;
|
|
11308
|
+
/**
|
|
11309
|
+
* THE table: per axis and kind, the style props each step writes. Spacing on a section writes only the block (top and
|
|
11310
|
+
* bottom) half of its padding — the sides stay the section's own (`adjustStyleProps`).
|
|
11311
|
+
*/
|
|
11312
|
+
declare const ADJUSTMENTS: Readonly<Record<AdjustAxis, Partial<Record<AdjustKind, Readonly<Record<string, Readonly<Record<string, string>>>>>>>>;
|
|
11313
|
+
/** Split a CSS value on its top-level spaces (a `calc(a * b)` stays one part). */
|
|
11314
|
+
declare function splitCssValue(value: string): string[];
|
|
11315
|
+
/**
|
|
11316
|
+
* The style props a step writes on a node holding `styleProps` (merged by the caller), or null when the axis does not act
|
|
11317
|
+
* on that kind or the step is not one of its rows. Section spacing keeps the node's own sides.
|
|
11318
|
+
*/
|
|
11319
|
+
declare function adjustStyleProps(axis: AdjustAxis, kind: AdjustKind, step: string, styleProps?: Readonly<Record<string, unknown>>): Record<string, string> | null;
|
|
11320
|
+
/** The step a node's current values are, or {@link ADJUST_OWN} when they are none of the rows. */
|
|
11321
|
+
declare function adjustStepOf(axis: AdjustAxis, kind: AdjustKind, styleProps?: Readonly<Record<string, unknown>>): string;
|
|
11322
|
+
/** How the owner reads a step id ("own" → "As set"). */
|
|
11323
|
+
declare function adjustStepLabel(axis: AdjustAxis, step: string): string;
|
|
11324
|
+
/** Every step id of every axis — the strict format's enum (which axis takes which step is the check's). */
|
|
11325
|
+
declare const ADJUST_STEP_IDS: ReadonlyArray<string>;
|
|
11326
|
+
|
|
11327
|
+
export { ACCOUNT_ENTRY_ID, ACTION_START_SCALE, ACTIVE_BUILD_STATUSES, ADJUSTMENTS, ADJUST_AXIS_LABELS, ADJUST_OWN, ADJUST_STEPS, ADJUST_STEP_IDS, AI_COMPOSED_PAGES_ESTIMATED, AI_PLAN_REASKED_PART, AI_REFUSAL_NEXT, AI_REFUSAL_STATUS, AI_STEPS, AI_STEP_FEATURE, AI_STEP_LABELS, AI_STEP_NEEDS, AI_STEP_PART_TOKENS, AI_STEP_TYPICAL_TOKENS, ART_DIRECTION_PARTS, AdjustAxis, AdjustKind, AiCallStatus, AiCapability, AiFeature, AiGenerationStage, AiKeyMode, AiLimit, AiNextKind, AiProviderId, AiRefusalCode, AiStep, BAR_ITEMS_MAX, BAR_ITEMS_MIN, BASELINE_ROLES, BUILD_STEPS, BaselineRole, BindScope, BuildNoticeCode, BuildStep, CONTENT_ROLE_MEANINGS, CREDITS_PER_USD, CardBindTarget, CheckSeverity, ComposeError, ComposeIssueCode, ContentFieldControl, ContentFieldType, ContentRole, ContentTypeAction, CreatedKind, DANGLING_LINK_CODES, DEFAULT_FOOTER_PATTERN, DEFAULT_PHONE_MENU_BREAKPOINT, DEFAULT_SITE_LOCALE, ENTRANCE_EASING, ENTRANCE_ORIGIN_LOOK, ENTRANCE_TRIGGER, EntrancePart, EntranceSide, FACT_KEYS, FIELD_TYPE_OF_CONTROL, FILL_ASPECT, FILM_PATTERN, FINAL_GENERATION_STAGES, FINDING_SEVERITY, FOOTER_TOKEN, FilmUnplaced, FooterArrange, FooterClosing, FooterGround, FooterHold, FooterIngredient, FooterMixError, FooterRepairCode, GRAMMAR_TOO_LARGE_MESSAGE, GlobalSlot, HEADER_TOKEN, HEBREW_PREFIXES, HeaderIngredient, HeaderMixError, JSON_SCHEMA_BANNED_KEYWORDS, JsonSchemaShapeError, KeptReason, LAYOUT_ACCENT_TEXT, LAYOUT_BEAT_DELAY, LAYOUT_CHECK_VIEWPORT, LAYOUT_COLOUR_TOKEN, LAYOUT_COLUMN_GAP, LAYOUT_DEPTH_ON_PHONE, LAYOUT_DRIFT, LAYOUT_EASING, LAYOUT_ENTRANCE_MAX_MS, LAYOUT_FONT_SIZE, LAYOUT_GUTTER, LAYOUT_HIDDEN_OPACITY, LAYOUT_KINETIC_KINDS, LAYOUT_LINE_HEIGHT, LAYOUT_LIST_TOKEN, LAYOUT_MIX_OFFERED, LAYOUT_MIX_WORDS, LAYOUT_OPERATED, LAYOUT_PACE, LAYOUT_PHONE_BREAKPOINT, LAYOUT_PHONE_PADDING, LAYOUT_PHOTO_ASPECT, LAYOUT_READY_MADE_TOKEN, LAYOUT_RISE, LAYOUT_SCREEN_PX, LAYOUT_TEXT_KINDS, LAYOUT_TOOLTIP_TRAIT, LAYOUT_VIEWPORTS, LAYOUT_WIRE_AUTOPLAY_MS, LIST_CARD_PART, LIST_INGREDIENTS, LIST_LONG_WORDS, LIST_ROLE_WORDS, LIST_TABLE, LayoutAlign, LayoutBleed, LayoutButtonVariant, LayoutColour, LayoutColourMode, LayoutDepth, LayoutDial, LayoutEase, LayoutEditOp, LayoutEnter, LayoutGalleryEffect, LayoutGapCode, LayoutIssueCode, LayoutLayerKind, LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListHow, LayoutListItem, LayoutListMove, LayoutListPhone, LayoutListRole, LayoutListWho, LayoutMendKind, LayoutMixIngredient, LayoutNavKind, LayoutPace, LayoutPhotoShape, LayoutPhotoSource, LayoutRole, LayoutSectionKind, LayoutSequenceToken, LayoutSide, LayoutSignatureId, LayoutSize, LayoutSourceChoice, LayoutTrackProp, LayoutTransition, LayoutViewport, MAX_SITE_PICTURES, NAV_PART_LABELS, NAV_SHAPE_COPY, NEUTRAL_STYLE_PROPS, NODE_BASELINES, NO_TOKENS, NavPagesSource, NavRole, NavShape, NavShapeError, PAGE_ARCHETYPES, PHOTO_ANALYSIS_WIDTH, PHOTO_CALM_DETAIL, PHOTO_GRID, PHOTO_LIGHT_LUMINANCE, PICTURE_ASPECTS, PICTURE_NEVER, PICTURE_REAL_PLACE_FAMILIES, PICTURE_REROLL_EVERY, PICTURE_REVIEW_FORMAT, PICTURE_REVIEW_SHAPE, PICTURE_TEXT_CONTRAST, PICTURE_WORLDS, PICTURE_WORLD_IDS, PLAN_EDITS_ANSWER_SHAPES, PLAN_EDITS_PART_SCHEMA_NAMES, PLAN_EDIT_OP_PART, PLAN_EDIT_SHAPE, PLAN_EDIT_WIRE_KEYS, PLAN_PARTS, PLAN_PART_KEYS, PLAN_WIRE_DERIVED, PLAN_WIRE_PART_SCHEMA_NAMES, PLAN_WIRE_SHAPE, PRICING_PATTERN, PROOF_FINGERPRINTS, PUBLISH_BLOCKING_PLACEHOLDERS, PageDataKind, PathIssueCollector, PatternDirective, PatternGlobalPosition, PatternOpens, PatternPlaceholder, PatternRecipe, PhoneMenuBreakpoint, PhotoTone, PictureRefusal, PictureWorld, PlaceholderKind, PlanChangeAction, PlanChangeKind, PlanDataSourceMode, PlanDataSourceType, PlanEditIssueCode, PlanEditOp, PlanEditsOutcome, PlanPart, PlanWireEntry, PlanWireShapeError, PlanWordIssueCode, PreflightRefusalCode, PriceBindTarget, PublishRefusalCode, PublishScope, RENDER_CHECK, REQUIRED_CONTENT_ROLES, RelativeOp, SAMPLE_IMAGE_REF, SCENE_LEVEL, SCENE_OTHER_PAGES, SCRIM_BACKGROUND, SCRIM_COVER, SCRIM_LEVELS, SHOP_CART_BUTTON_ID, SHOP_CART_DRAWER_ID, SHOP_FIELDS, SHOP_LATEST_LIMIT, SHOP_LIST_LIMIT, SHOP_NEED, SHOP_ONLY_CONTENT_ROLES, SHOP_PRODUCTS_MAX, SHOP_ROLES, SHOP_SLUG_FIELD, SHOWCASE_FILM, SHOWCASE_SHOP, SIGN_IN_DIALOG_ID, SITE_CHECKS, SITE_FACT_LABELS, SITE_HEADER_PATTERN, SITE_LIBRARY, SITE_LOCALES, SITE_NEED_IDS, SITE_PATTERNS, SITE_PLAN_VERSION, SITE_TEMPLATES, SPEC_SITE_ARCHETYPES, SPEC_SITE_COPY_LENGTHS, SPEC_SITE_DENSITY_COPY, SPEC_SITE_FACTS, SPEC_SITE_FOOTER_PARTS, SPEC_SITE_LAYOUT, SPEC_SITE_LIBRARY, SPEC_SITE_LOCALES, SPEC_SITE_NEED_IDS, SPEC_SITE_PATTERNS, SPEC_SITE_PICTURE_NEVER, SPEC_SITE_PICTURE_WORLDS, SPEC_SITE_PLAN_SHAPE, SPEC_SITE_REQUIRED_ROLES, SPEC_SITE_ROLES, SPEC_SITE_TEMPLATES, STOCK_FAMILIES, STOCK_FAMILY_INTENTS, STOCK_INTENT_ORDER, STOCK_INTENT_SUBJECTS, STOCK_ITEM_ASPECT, STOCK_MIN_KEPT, STOCK_PROVIDER_TERMS, STOCK_SEED_MARGIN, STOCK_SUBJECT_WORDS, STORE_CONTACT_CODES, STRICT_SCHEMA_BUDGET, STRICT_SCHEMA_LIMITS, STUDIO_TEMPLATE, ScrimLevel, SectionFallbackLastResort, SectionSwapAction, SectionSwapRule, ShopResource, ShopSourceRole, SiteBuildKind, SiteBuildStatus, SiteCheckId, SiteFindingCode, SiteLocale, SitePlanError, SitePlanIssueCode, SitePlanSourceKind, SiteTemplateError, SiteTemplateId, StepState, StockIntent, StockOrientation, StockProviderId, StockReviewFlag, StockReviewVerdict, StockSlotKind, StockSubject, WORDS_AREA_DEFAULT_SHARE, WordsEdge, addBarItem, addStockCredits, adjustStepLabel, adjustStepOf, adjustStyleProps, aiRefusalNext, aiStepParts, applyLayoutEdits, applyOwnPhotoGalleries, applyPictureScrims, applyPlanEdits, applyStockItemPhotos, applyStockPhotos, archetypeIssues, areaLuminance, artDirectionFor, artDirectionIssues, artDirectionPreamble, aspectRatioOf, assertStyleSlots, assertValidSitePlan, auditLayoutMotion, auditSite, barIconForRoute, blocksPublish, brandHueWord, buildKeys, buildStepFacts, buildStepsOf, builtHomePageId, calmParts, calmUnder, checkFooter, checkLayout, checkList, chooseScrim, composeContextOf, composeLayout, composeNavHeader, composePresetForm, composeSection, composeSite, contentTypeOfSource, contentTypePreviewFields, contentTypeToWire, copyLengthOf, costUsd, coverCrop, createSerializedNode, creditsOfUsd, dataSourceToWire, derivedBeats, derivedDataSources, derivedShopSources, describeInventoryForPrompt, describeListShape, describePlanData, describeShapeKey, distinctFooter, drawnHeaderMix, driftAt, driftOverlap, emptyAreaPhrase, entranceAction, entranceInteraction, estimatePictures, estimateStepCredits, expandLayoutWire, expandPlanWire, expandWireContentType, expandWireDataSource, expandWireEdit, expandWireField, expandWirePage, expandWireSection, expandWireShop, factIssues, failedBuildStep, fallBackBySection, fieldToWire, filmOfPlan, filmPlacement, findNavRoot, fingerprintOf, fingerprintOfPlanPage, footerMeaning, footerMix, footerMixFromWords, footerMixOfPlan, footerMixWords, footerPattern, footerPatternIdOf, footerReferences, footerTokenOf, footerTokenWords, footerWireWords, footerWords, frameWords, headerMeaning, headerMix, headerMixOfNavKind, headerMixOfPlan, headerReferences, headerTokenOf, headerTokenWords, headerWords, isActiveBuild, isLayoutRule, isNonEmptyString, isPictureWorld, isPlainObject, isRtlLocale, isShopResource, jsonAnyOf, jsonBoolean, jsonClosedObject, jsonInteger, jsonListOf, jsonOneOf, jsonSchemaKeywords, jsonSchemaObjects, jsonShapedObject, jsonText, judgeLayoutRender, layerShownSpans, layoutBandScheme, layoutBoxPx, layoutColumnsVw, layoutDesignOf, layoutDialOf, layoutDriftPhoto, layoutElementStyle, layoutGalleryLists, layoutGallerySources, layoutGlideDepth, layoutHeldStill, layoutListBinding, layoutListShapes, layoutLookChanges, layoutLookOf, layoutMixOffered, layoutMotionOf, layoutNodeClass, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutPathSteps, layoutPhotoIds, layoutPresetColours, layoutPresetOf, layoutRepairJsonSchema, layoutRoomPx, layoutRuleEdge, layoutShapeHasPurpose, layoutStillLine, layoutTextFits, layoutTextWidthEm, layoutToWire, layoutVoidScreens, layoutVoids, layoutWireJsonSchema, layoutWirePartWords, listBuiltWords, listIngredientWords, listMeaning, listNeverIsEmpty, listTokenOf, listTokensOf, listWait, listWords, luminanceOf, measureLayout, mendLayout, menuAtEveryWidth, modelCanDo, moveBarItem, namedFooterMix, namedHeaderMix, navPages, navShapeBreakpoint, navShapeOf, nextSourceOf, nodeBindPaths, orientationOfRatio, ownPhotoFit, pageListIssues, pageToWire, parseLayoutPhotoId, parsePatternPath, parseSampleImageRef, pathAt, patternById, patternHasForm, patternLinkSlots, patternListGap, patternManifest, patternNeedsBinding, patternNodes, patternOptionalParts, patternRoleNeeds, patternScopes, patternSlotBudgets, patternSlots, patternTakesBinding, phoneGapBefore, phoneMenuPages, phoneWordsColour, photoInventory, photoShapeOf, pictureAspect, pictureItemsOf, picturePrompt, pictureRefusalOf, pictureRerolls, pictureReviewIssues, pictureReviewJsonSchema, pictureReviewPasses, pictureSlotKey, pictureTargets, pictureTryFits, pixelsUnder, placeFilm, planEditOps, planEditToWire, planEditWireGaps, planEditWireKeys, planEditWireOps, planEditWireShape, planEditsFromWire, planEditsJsonSchema, planEditsToWire, planEntrances, planFromTemplate, planHasShopSource, planLayoutPhotos, planNavShape, planOwnPhotos, planPartOfPath, planPartToWire, planPictures, planSells, planStockPhotos, planToWire, planWireGaps, planWirePartJsonSchema, planWirePartShape, planWordIssues, pricesIn, publishRefusal, publishVerdict, readyMadeColumn, recipeListBinds, recomposeAsks, releasedLayoutDefaults, removeBarItem, requiredAcknowledgements, requiredShapeKeys, roleField, routeMatches, routeParams, samenessIssues, sampleImageRef, scoreStockPhoto, screenFontSize, screenWordColumns, screenWordMisfit, screenWordOverflowPx, sectionEntrances, sectionPatternIds, sectionToWire, sectionTokenOf, sectionsNamed, sequenceShare, sequenceTokenOf, setStyleProps, shapeKeys, shopCategoriesOf, shopContentType, shopSourceAliases, showcaseGlobals, showcasePages, showcasePlans, showcaseScenes, showcaseStorePages, shownTogether, signatureOf, siteNavPages, siteSells, slotBudget, splitCssValue, splitSide, stockCopyKey, stockCreditLine, stockCreditLines, stockCreditNode, stockCreditNodeId, stockFits, stockGroupOf, stockItemSlots, stockKept, stockPhotoRatio, stockPhotoSubject, stockPhotoUsable, stockPhotoWords, stockSlots, stockWord, stockWords, strictSchemaComplexity, strictSchemaRefusal, toneOf, typicalStepTokens, validatePlanEdits, validateSitePlan, variantNamesOf, walkSerialized, wireContentTypeJsonSchema, wireDataSourceJsonSchema, wireFieldJsonSchema, wirePageJsonSchema, wireSectionJsonSchema, wireShopProductJsonSchema, withDerivedSources, withDistinctFooter, wordPattern, wordsOverPhotos, wordsOverPicture, writtenTexts };
|
|
11328
|
+
export type { AddBarItemResult, AdjustStep, AiBuyCredits, AiEntitlementsView, AiMeter, AiModelEntry, AiRefusal, AiTokenCounts, AiTokenPrice, AreaLuminance, ArtDirection, AuditPage, AuditPlaceholder, BarItemsEditResult, BuildNotice, BuildStepError, BuildStepFacts, BuildStepRecord, CalmReading, CheckLayoutContext, CmsDataSourcePlan, ComposeContext, ComposeIssue, ComposeLayoutOptions, ComposedDataSource, ComposedItem, ComposedLayout, ComposedNavHeader, ComposedPage, ComposedPlaceholder, ComposedProduct, ComposedRoute, ComposedSection, ComposedShop, ComposedSite, ContentFieldPlan, ContentRoles, ContentSeedPlan, ContentTypePlan, CreateNodeOptions, CreatedRecord, DataSourcePlan, DriftBox, DriftLayer, DriftMeeting, DynamicKeysAsList, EntranceAction, EntranceActionOptions, EntranceInteraction, EntranceMark, EntranceSpec, EntranceStamp, FactKey, FilmPlacement, FilmTarget, FingerprintedPage, FooterContext, FooterMix, FooterRepair, FrameRegion, HeaderGap, HeaderMix, JsonSchema, LayoutBandMove, LayoutColours, LayoutEdit, LayoutFingerprint, LayoutForm, LayoutGallery, LayoutGalleryList, LayoutGap, LayoutGivenAway, LayoutIssue, LayoutLayer, LayoutListBinding, LayoutListMix, LayoutListNever, LayoutListShape, LayoutLook, LayoutMend, LayoutPage, LayoutPhotoAddress, LayoutReadyMade, LayoutRect, LayoutSection, LayoutSite, LayoutTrack, LayoutVoid, LayoutWire, LayoutWireLayer, LayoutWireList, LayoutWireOptions, LayoutWireSection, LayoutWireSlot, LayoutWireTrack, ListIngredient, ListWait, MeasuredLayer, MeasuredLayout, NavHeaderInput, NavHeaderOptions, NavPage, NavShapeOptions, NavShapeResult, NodeBaseline, OwnPhoto, OwnPhotoPlacement, PageArchetype, PageArchetypeId, PageArchetypeSlot, PageData, PageDataLine, PagePlan, PageSectionPlan, PageSeoPlan, PathIssue, PatternManifestEntry, PatternManifestOptions, PatternNode, PatternPath, PatternRoleNeed, PatternTrack, PhotoInventory, PhotoWordsArea, PicturePlan, PicturePlanOptions, PicturePromptContext, PictureReview, PictureSlot, PictureTryBudget, PictureWorldSpec, PicturesEstimate, PixelReading, PlacedFilm, PlainObject, PlanChange, PlanDirection, PlanEdit, PlanEditIssue, PlanEditResult, PlanEditsAnswer, PlanEntrancesInput, PlanFilm, PlanMixes, PlanWireContext, PlanWireParts, PlanWordContext, PlanWordIssue, PreflightRefusal, PublishRefusal, RecipeListBinds, RelativeDataSourcePlan, ScrimChoice, SectionEntrances, SectionFallback, SectionInput, SectionJudge, SectionOptions, SectionSwap, SerializedBinding, SerializedNode, SerializedResponsive, ShapeEntry, ShapeIssueCodes, ShopDataSourcePlan, ShopOptionPlan, ShopPlan, ShopProductPlan, ShowcaseInput, SiteAudit, SiteAuditOptions, SiteAuditSnapshot, SiteBuildRun, SiteBusiness, SiteCheck, SiteFinding, SiteNeedId, SitePageRef, SitePattern, SitePlan, SitePlanContext, SitePlanIssue, SitePlanSource, SitePlanValidation, SiteTemplate, StockCredit, StockItemSlot, StockLink, StockNeed, StockPhoto, StockPhotoTraits, StockPlacement, StockPlanOptions, StockProviderTerms, StockReview, StockSlot, StockTarget, StrictSchemaComplexity, StrictSchemaRefusal, TemplatePlanInput, UndoKept, UndoPreview, UndoRecord, WireOptions, WordsArea, WrittenText };
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import type { SerializedNode } from '@vectoriox/iox-ui/generation-core';
|
|
|
4
4
|
|
|
5
5
|
import { FieldChange } from './field-edits';
|
|
6
6
|
import { FieldEdit } from './fields-schema';
|
|
7
|
-
import { PageChangeOp, SchemeEdit, StyleChange, StyleEdit } from './page-style';
|
|
7
|
+
import { PageChangeOp, SchemeEdit, SizeEdit, StyleChange, StyleEdit } from './page-style';
|
|
8
8
|
import { WordChange, WordEdit } from './page-words';
|
|
9
9
|
import { ContentRecord, clipText } from './summarize-item';
|
|
10
10
|
import { AssistScope, AssistSurface, CommitKind, EditFamily, SURFACES, SurfaceStatus } from './surfaces';
|
|
@@ -65,12 +65,12 @@ export interface AssistTurnRequest {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/** What a turn proposes, per family: a field's value (`fields`), a part's words (`words`), an element's style or a section's scheme (`style`). */
|
|
68
|
-
export type AssistEdit = FieldEdit | WordEdit | StyleEdit | SchemeEdit;
|
|
68
|
+
export type AssistEdit = FieldEdit | WordEdit | StyleEdit | SchemeEdit | SizeEdit;
|
|
69
69
|
|
|
70
70
|
/** What a turn changed, as the card says it. */
|
|
71
71
|
export type AssistChange = FieldChange | WordChange | StyleChange;
|
|
72
72
|
|
|
73
|
-
const isLookChange = (c: AssistChange): c is StyleChange => 'op' in c && (c.op === PageChangeOp.Style || c.op === PageChangeOp.Scheme);
|
|
73
|
+
const isLookChange = (c: AssistChange): c is StyleChange => 'op' in c && (c.op === PageChangeOp.Style || c.op === PageChangeOp.Scheme || c.op === PageChangeOp.Size);
|
|
74
74
|
|
|
75
75
|
/** POST's 202 answer. */
|
|
76
76
|
export interface AssistTurnAccepted {
|
|
@@ -2,14 +2,15 @@ import { SerializedNode } from '@vectoriox/iox-ui/generation-core';
|
|
|
2
2
|
|
|
3
3
|
import { AssistIssue } from './brief';
|
|
4
4
|
import { applyWordEdits, SummarizedPage, WordChange, WordEdit, WordEditContext } from './page-words';
|
|
5
|
-
import { applyStyleEdits, BaselineStyles, isSchemeEdit, isStyleEdit, SchemeEdit, StyleChange, StyleEdit } from './page-style';
|
|
5
|
+
import { applyStyleEdits, BaselineStyles, isSchemeEdit, isSizeEdit, isStyleEdit, LookEdit, SchemeEdit, SizeEdit, StyleChange, StyleEdit } from './page-style';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Surface S1's answer as ONE thing (AI2b): the edits of every family a page turn routed to — words (`{ handle, value }`),
|
|
9
|
-
* styles (`{ handle, style }`), schemes (`{ handle, scheme }`)
|
|
8
|
+
* Surface S1's answer as ONE thing (AI2b, AI2c): the edits of every family a page turn routed to — words (`{ handle, value }`),
|
|
9
|
+
* styles (`{ handle, style }`), schemes (`{ handle, scheme }`), size steps (`{ handle, axis, step }`) — applied in that
|
|
10
|
+
* order on a copy, all or none. The server
|
|
10
11
|
* checks each family as it is asked; the builder's trial applies the turn's edits through this, so both read one rule.
|
|
11
12
|
*/
|
|
12
|
-
export type PageEdit = WordEdit | StyleEdit | SchemeEdit;
|
|
13
|
+
export type PageEdit = WordEdit | StyleEdit | SchemeEdit | SizeEdit;
|
|
13
14
|
export type PageChange = WordChange | StyleChange;
|
|
14
15
|
|
|
15
16
|
export interface PageEditContext extends Omit<WordEditContext, 'handles' | 'never'> {
|
|
@@ -31,7 +32,7 @@ export function applyPageEdits(layout: ReadonlyArray<SerializedNode>, edits: Rea
|
|
|
31
32
|
const words = applyWordEdits(layout, edits.filter(isWordEdit), {
|
|
32
33
|
handles: ctx.summary.handles, never: ctx.summary.brief.rules.never, sentence: ctx.sentence, words: ctx.words,
|
|
33
34
|
});
|
|
34
|
-
const looks = edits.filter((e): e is
|
|
35
|
+
const looks = edits.filter((e): e is LookEdit => !isWordEdit(e) && (isStyleEdit(e) || isSchemeEdit(e) || isSizeEdit(e)));
|
|
35
36
|
const style = applyStyleEdits(words.result, looks, { looks: ctx.summary.looks, baseline: ctx.baseline });
|
|
36
37
|
const issues = [...words.issues, ...style.issues];
|
|
37
38
|
if (issues.length) return { ok: false, result: JSON.parse(JSON.stringify(layout)) as SerializedNode[], changes: [], issues };
|
|
@@ -2,7 +2,10 @@ import {
|
|
|
2
2
|
COLOR_SCHEME_TYPES, COLOR_SCHEMES, ColorScheme, colorSchemeOf, elementStyleById, elementStylesFor, ElementStyleTarget, NEW_NODE_STYLE_DEFAULTS,
|
|
3
3
|
setColorScheme, switchElementStyle,
|
|
4
4
|
} from '@vectoriox/iox-ui/design-core';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ADJUST_AXIS_LABELS, ADJUST_STEPS, AdjustAxis, AdjustKind, adjustStepLabel, adjustStepOf, adjustStyleProps, jsonClosedObject, jsonListOf, jsonOneOf,
|
|
7
|
+
JsonSchema, jsonText, NODE_BASELINES, SerializedNode, walkSerialized,
|
|
8
|
+
} from '@vectoriox/iox-ui/generation-core';
|
|
6
9
|
|
|
7
10
|
import { assertAssistBudget } from './budget';
|
|
8
11
|
import { AssistIssue, AssistIssueCode } from './brief';
|
|
@@ -15,6 +18,9 @@ import { AssistIssue, AssistIssueCode } from './brief';
|
|
|
15
18
|
* copy) and in the builder (the trial): `pageLooks` (the targets and their handles), `styleJsonSchema`,
|
|
16
19
|
* `decodeStyleAnswers`, `applyStyleEdits` — design-core's `switchElementStyle` (the author's own changes are kept) and
|
|
17
20
|
* `setColorScheme` (the ONE scheme writer), all or none.
|
|
21
|
+
*
|
|
22
|
+
* AI2c adds SIZE STEPS to the same family: a section's height and spacing, a card's or panel's padding, where words sit
|
|
23
|
+
* — each a row of generation-core `ADJUSTMENTS` (the only place their values come from), never a number the model wrote.
|
|
18
24
|
*/
|
|
19
25
|
|
|
20
26
|
/**
|
|
@@ -42,6 +48,35 @@ const paintsGround = (style: string | null | undefined): boolean => SURFACE_STYL
|
|
|
42
48
|
/** A Text wearing this is a ButtonBlock's words: the button is the style target. */
|
|
43
49
|
const BUTTON_LABEL_STYLE = 'button-label';
|
|
44
50
|
|
|
51
|
+
/** The words types whose line alignment may be asked for (a button's or a link's words sit as their button does). */
|
|
52
|
+
const ALIGNABLE_TYPES: ReadonlySet<string> = new Set(['Heading', 'Text']);
|
|
53
|
+
|
|
54
|
+
/** Boxes whose padding is a framed box's (`--iox-space-pad`). */
|
|
55
|
+
const PADDED_STYLES: ReadonlySet<string> = new Set(['card', 'panel']);
|
|
56
|
+
|
|
57
|
+
/** A Scene, or a section holding a pinned (sticky) part, owns its height — it plays over the scroll it is given. */
|
|
58
|
+
function ownsItsHeight(root: SerializedNode): boolean {
|
|
59
|
+
let owns = false;
|
|
60
|
+
walkSerialized([root], n => { if (n.role === 'scene' || n.styleProps?.['position'] === 'sticky') owns = true; });
|
|
61
|
+
return owns;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The size axes a node may be stepped on, and which kind each acts as (AI2c): a section root its height and rhythm, a
|
|
66
|
+
* card or panel its padding, a heading or text its alignment. A node that is none of these takes no step.
|
|
67
|
+
*/
|
|
68
|
+
export function adjustAxesOf(node: SerializedNode, isRoot: boolean, carriesWords: boolean): Partial<Record<AdjustAxis, AdjustKind>> {
|
|
69
|
+
const axes: Partial<Record<AdjustAxis, AdjustKind>> = {};
|
|
70
|
+
if (isRoot) {
|
|
71
|
+
if (!ownsItsHeight(node)) axes[AdjustAxis.Height] = AdjustKind.Section;
|
|
72
|
+
axes[AdjustAxis.Spacing] = AdjustKind.Section;
|
|
73
|
+
} else if (PADDED_STYLES.has(node.elementStyle ?? '')) {
|
|
74
|
+
axes[AdjustAxis.Spacing] = AdjustKind.Box;
|
|
75
|
+
}
|
|
76
|
+
if (carriesWords && ALIGNABLE_TYPES.has(node.type) && node.elementStyle !== BUTTON_LABEL_STYLE) axes[AdjustAxis.Align] = AdjustKind.Words;
|
|
77
|
+
return axes;
|
|
78
|
+
}
|
|
79
|
+
|
|
45
80
|
/** The styles a node may take by asking — its own among them — or [] when it is not a target. */
|
|
46
81
|
export function askableStyles(node: Pick<SerializedNode, 'type' | 'elementStyle'>): string[] {
|
|
47
82
|
const current = node.elementStyle;
|
|
@@ -61,10 +96,14 @@ export interface PageLook {
|
|
|
61
96
|
readonly styles?: ReadonlyArray<string>;
|
|
62
97
|
/** Its colour scheme, when it takes one. */
|
|
63
98
|
readonly scheme?: string;
|
|
99
|
+
/** The size axes it may be stepped on, each with the step it holds now (`own` = a value of its own). */
|
|
100
|
+
readonly sizes?: Readonly<Partial<Record<AdjustAxis, string>>>;
|
|
64
101
|
}
|
|
65
102
|
|
|
66
103
|
export interface WalkedLook {
|
|
67
104
|
readonly look: PageLook;
|
|
105
|
+
/** Which kind each of its size axes acts as — what the check writes with (never sent). */
|
|
106
|
+
readonly axes: Readonly<Partial<Record<AdjustAxis, AdjustKind>>>;
|
|
68
107
|
readonly section: number;
|
|
69
108
|
readonly nodeId: string;
|
|
70
109
|
readonly type: string;
|
|
@@ -96,7 +135,9 @@ export function pageLooks(
|
|
|
96
135
|
// TAKE such a style is offered one too; the check refuses the scheme unless the turn gives it that style.
|
|
97
136
|
const takesScheme = COLOR_SCHEME_TYPES.includes(node.type) && !isRecipePart(node)
|
|
98
137
|
&& (paintsGround(node.elementStyle) || scheme !== ColorScheme.Default || (takesStyle && styles.some(paintsGround)));
|
|
99
|
-
|
|
138
|
+
const axes = adjustAxesOf(node, isRoot, wordHandles.has(node.id));
|
|
139
|
+
const sized = Object.entries(axes) as Array<[AdjustAxis, AdjustKind]>;
|
|
140
|
+
if (takesStyle || takesScheme || sized.length) {
|
|
100
141
|
const handle = lookHandle(node, index, isRoot, wordHandles, () => ++boxes);
|
|
101
142
|
if (handle) {
|
|
102
143
|
out.push({
|
|
@@ -105,8 +146,9 @@ export function pageLooks(
|
|
|
105
146
|
label: lookLabel(handle, root, index),
|
|
106
147
|
...(takesStyle ? { style: node.elementStyle!, styles } : {}),
|
|
107
148
|
...(takesScheme ? { scheme } : {}),
|
|
149
|
+
...(sized.length ? { sizes: Object.fromEntries(sized.map(([axis, kind]) => [axis, adjustStepOf(axis, kind, node.styleProps)])) } : {}),
|
|
108
150
|
},
|
|
109
|
-
section: index, nodeId: node.id, type: node.type, lineage: here,
|
|
151
|
+
axes, section: index, nodeId: node.id, type: node.type, lineage: here,
|
|
110
152
|
});
|
|
111
153
|
}
|
|
112
154
|
}
|
|
@@ -158,6 +200,8 @@ export interface LookTarget {
|
|
|
158
200
|
readonly label: string;
|
|
159
201
|
readonly styles: ReadonlyArray<string>;
|
|
160
202
|
readonly scheme: boolean;
|
|
203
|
+
/** The size axes it may be stepped on, and the kind each acts as. */
|
|
204
|
+
readonly sizes?: Readonly<Partial<Record<AdjustAxis, AdjustKind>>>;
|
|
161
205
|
}
|
|
162
206
|
|
|
163
207
|
export type LookMap = Readonly<Record<string, LookTarget>>;
|
|
@@ -165,6 +209,7 @@ export type LookMap = Readonly<Record<string, LookTarget>>;
|
|
|
165
209
|
export enum StyleAnswerKey {
|
|
166
210
|
Styles = 'styles',
|
|
167
211
|
Schemes = 'schemes',
|
|
212
|
+
Sizes = 'sizes',
|
|
168
213
|
Note = 'note',
|
|
169
214
|
}
|
|
170
215
|
|
|
@@ -182,7 +227,8 @@ export interface StyleSchemas {
|
|
|
182
227
|
export function styleJsonSchema(looks: LookMap): StyleSchemas {
|
|
183
228
|
const styled = Object.entries(looks).filter(([, t]) => t.styles.length);
|
|
184
229
|
const schemed = Object.entries(looks).filter(([, t]) => t.scheme);
|
|
185
|
-
|
|
230
|
+
const sized = Object.entries(looks).filter(([, t]) => Object.keys(t.sizes ?? {}).length);
|
|
231
|
+
if (!styled.length && !schemed.length && !sized.length) return { parts: [], handles: [] };
|
|
186
232
|
const properties: Record<string, JsonSchema> = {};
|
|
187
233
|
if (styled.length) {
|
|
188
234
|
const ids = [...new Set(styled.flatMap(([, t]) => t.styles))];
|
|
@@ -203,10 +249,21 @@ export function styleJsonSchema(looks: LookMap): StyleSchemas {
|
|
|
203
249
|
description: 'A section or box taking another colour scheme; [] changes no colours.',
|
|
204
250
|
};
|
|
205
251
|
}
|
|
252
|
+
if (sized.length) {
|
|
253
|
+
const axes = [...new Set(sized.flatMap(([, t]) => Object.keys(t.sizes ?? {})))] as AdjustAxis[];
|
|
254
|
+
properties[StyleAnswerKey.Sizes] = {
|
|
255
|
+
...jsonListOf(jsonClosedObject({
|
|
256
|
+
handle: jsonOneOf(sized.map(([h]) => h)),
|
|
257
|
+
axis: jsonOneOf(axes),
|
|
258
|
+
step: jsonOneOf([...new Set(axes.flatMap(a => ADJUST_STEPS[a].map(s => s.id)))]),
|
|
259
|
+
}, ['handle', 'axis', 'step'])),
|
|
260
|
+
description: 'An element stepped on one of the size axes the focus lists for it; [] changes no size.',
|
|
261
|
+
};
|
|
262
|
+
}
|
|
206
263
|
properties[StyleAnswerKey.Note] = { ...jsonText(), description: 'One short line for the owner on what changed, or what needs them.' };
|
|
207
264
|
const part = jsonClosedObject(properties, Object.keys(properties));
|
|
208
265
|
assertAssistBudget('style', [part]);
|
|
209
|
-
return { parts: [part], handles: [[...new Set([...styled, ...schemed].map(([h]) => h))]] };
|
|
266
|
+
return { parts: [part], handles: [[...new Set([...styled, ...schemed, ...sized].map(([h]) => h))]] };
|
|
210
267
|
}
|
|
211
268
|
|
|
212
269
|
/** An element taking another element style. */
|
|
@@ -221,35 +278,50 @@ export interface SchemeEdit {
|
|
|
221
278
|
readonly scheme: string;
|
|
222
279
|
}
|
|
223
280
|
|
|
281
|
+
/** An element stepped on a size axis — a row of generation-core `ADJUSTMENTS`. */
|
|
282
|
+
export interface SizeEdit {
|
|
283
|
+
readonly handle: string;
|
|
284
|
+
readonly axis: string;
|
|
285
|
+
readonly step: string;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** Any edit of family `style`. */
|
|
289
|
+
export type LookEdit = StyleEdit | SchemeEdit | SizeEdit;
|
|
290
|
+
|
|
224
291
|
const listOf = (answer: unknown, key: StyleAnswerKey): Array<Record<string, unknown>> => {
|
|
225
292
|
const list = answer && typeof answer === 'object' ? (answer as Record<string, unknown>)[key] : undefined;
|
|
226
293
|
return Array.isArray(list) ? list.filter((x): x is Record<string, unknown> => !!x && typeof x === 'object') : [];
|
|
227
294
|
};
|
|
228
295
|
|
|
229
296
|
/** The answer → the edits it makes. */
|
|
230
|
-
export function decodeStyleAnswers(answers: ReadonlyArray<unknown>):
|
|
297
|
+
export function decodeStyleAnswers(answers: ReadonlyArray<unknown>): LookEdit[] {
|
|
231
298
|
return answers.flatMap(answer => [
|
|
232
299
|
...listOf(answer, StyleAnswerKey.Styles).map(x => ({ handle: String(x['handle'] ?? ''), style: String(x['style'] ?? '') })),
|
|
233
300
|
...listOf(answer, StyleAnswerKey.Schemes).map(x => ({ handle: String(x['handle'] ?? ''), scheme: String(x['scheme'] ?? '') })),
|
|
301
|
+
...listOf(answer, StyleAnswerKey.Sizes).map(x => ({ handle: String(x['handle'] ?? ''), axis: String(x['axis'] ?? ''), step: String(x['step'] ?? '') })),
|
|
234
302
|
]);
|
|
235
303
|
}
|
|
236
304
|
|
|
237
305
|
export const isStyleEdit = (e: object): e is StyleEdit => typeof (e as StyleEdit).style === 'string';
|
|
238
306
|
export const isSchemeEdit = (e: object): e is SchemeEdit => typeof (e as SchemeEdit).scheme === 'string';
|
|
307
|
+
export const isSizeEdit = (e: object): e is SizeEdit => typeof (e as SizeEdit).axis === 'string' && typeof (e as SizeEdit).step === 'string';
|
|
239
308
|
|
|
240
309
|
/** Which kind of change a change card shows. */
|
|
241
310
|
export enum PageChangeOp {
|
|
242
311
|
Words = 'words',
|
|
243
312
|
Style = 'style',
|
|
244
313
|
Scheme = 'scheme',
|
|
314
|
+
Size = 'size',
|
|
245
315
|
}
|
|
246
316
|
|
|
247
317
|
export interface StyleChange {
|
|
248
|
-
readonly op: PageChangeOp.Style | PageChangeOp.Scheme;
|
|
318
|
+
readonly op: PageChangeOp.Style | PageChangeOp.Scheme | PageChangeOp.Size;
|
|
319
|
+
/** A size step's axis. */
|
|
320
|
+
readonly axis?: AdjustAxis;
|
|
249
321
|
readonly handle: string;
|
|
250
322
|
readonly nodeId: string;
|
|
251
323
|
readonly label: string;
|
|
252
|
-
/** The style / scheme ids, and how the owner reads them. */
|
|
324
|
+
/** The style / scheme / step ids, and how the owner reads them. */
|
|
253
325
|
readonly from: string;
|
|
254
326
|
readonly to: string;
|
|
255
327
|
readonly before: string;
|
|
@@ -290,7 +362,7 @@ const styleLabel = (id: string) => elementStyleById(id)?.label ?? id;
|
|
|
290
362
|
* once by the server, never repaired here); an edit that changes nothing is dropped.
|
|
291
363
|
*/
|
|
292
364
|
export function applyStyleEdits(
|
|
293
|
-
layout: ReadonlyArray<SerializedNode>, edits: ReadonlyArray<
|
|
365
|
+
layout: ReadonlyArray<SerializedNode>, edits: ReadonlyArray<LookEdit>, ctx: StyleEditContext,
|
|
294
366
|
): StyleEditsOutcome {
|
|
295
367
|
const result = JSON.parse(JSON.stringify(layout)) as SerializedNode[];
|
|
296
368
|
const byId = new Map<string, SerializedNode>();
|
|
@@ -300,18 +372,48 @@ export function applyStyleEdits(
|
|
|
300
372
|
const changes: StyleChange[] = [];
|
|
301
373
|
const seen = new Set<string>();
|
|
302
374
|
|
|
303
|
-
// Styles first: a scheme may need the style the same turn gives its node (a plain box made a panel, then darkened)
|
|
304
|
-
|
|
375
|
+
// Styles first: a scheme may need the style the same turn gives its node (a plain box made a panel, then darkened);
|
|
376
|
+
// size steps last, over what the style switch released.
|
|
377
|
+
const ordered = [
|
|
378
|
+
...edits.filter(e => !isSchemeEdit(e) && !isSizeEdit(e)), ...edits.filter(isSchemeEdit), ...edits.filter(isSizeEdit),
|
|
379
|
+
];
|
|
305
380
|
for (const edit of ordered) {
|
|
306
381
|
const scheme = isSchemeEdit(edit);
|
|
307
|
-
const
|
|
382
|
+
const size = isSizeEdit(edit);
|
|
383
|
+
const key = size ? `size:${edit.handle}:${edit.axis}` : `${scheme ? 'scheme' : 'style'}:${edit.handle}`;
|
|
308
384
|
const refuse = (code: AssistIssueCode, message: string) => issues.push({ code, handle: edit.handle, message });
|
|
309
|
-
if (seen.has(key)) {
|
|
385
|
+
if (seen.has(key)) {
|
|
386
|
+
refuse(AssistIssueCode.Duplicate, `"${edit.handle}" is given two ${size ? `${edit.axis} steps` : scheme ? 'schemes' : 'styles'}`);
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
310
389
|
seen.add(key);
|
|
311
390
|
const target = Object.prototype.hasOwnProperty.call(ctx.looks, edit.handle) ? ctx.looks[edit.handle] : undefined;
|
|
312
391
|
const node = target ? byId.get(target.id) : undefined;
|
|
313
392
|
if (!target || !node) { refuse(AssistIssueCode.UnknownHandle, `"${edit.handle}" is not an element of the focus`); continue; }
|
|
314
393
|
|
|
394
|
+
if (size) {
|
|
395
|
+
const axis = edit.axis as AdjustAxis;
|
|
396
|
+
const kind = Object.prototype.hasOwnProperty.call(target.sizes ?? {}, axis) ? target.sizes![axis] : undefined;
|
|
397
|
+
if (!kind) {
|
|
398
|
+
const takes = Object.keys(target.sizes ?? {});
|
|
399
|
+
refuse(AssistIssueCode.NotAnOption, `${target.label} takes no ${edit.axis} step${takes.length ? ` — only ${takes.join(', ')}` : ''}`);
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
const props = adjustStyleProps(axis, kind, edit.step, node.styleProps);
|
|
403
|
+
if (!props) {
|
|
404
|
+
refuse(AssistIssueCode.NotAnOption, `${ADJUST_AXIS_LABELS[axis].toLowerCase()} takes ${ADJUST_STEPS[axis].map(s => `"${s.id}"`).join(', ')} — not "${edit.step}"`);
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
const from = adjustStepOf(axis, kind, node.styleProps);
|
|
408
|
+
if (from === edit.step) continue;
|
|
409
|
+
node.styleProps = { ...(node.styleProps ?? {}), ...props };
|
|
410
|
+
changes.push({
|
|
411
|
+
op: PageChangeOp.Size, axis, handle: edit.handle, nodeId: node.id, label: `${target.label} · ${ADJUST_AXIS_LABELS[axis].toLowerCase()}`,
|
|
412
|
+
from, to: edit.step, before: adjustStepLabel(axis, from), after: adjustStepLabel(axis, edit.step),
|
|
413
|
+
});
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
|
|
315
417
|
if (scheme) {
|
|
316
418
|
const to = (edit as SchemeEdit).scheme;
|
|
317
419
|
if (!target.scheme) { refuse(AssistIssueCode.NotAnOption, `${target.label} takes no colour scheme`); continue; }
|
|
@@ -92,7 +92,7 @@ export interface PageSectionSummary {
|
|
|
92
92
|
/** The section's own name ("Hero", "Our work") or "Section 3". */
|
|
93
93
|
readonly label: string;
|
|
94
94
|
readonly parts: ReadonlyArray<PagePart>;
|
|
95
|
-
/** Family `style`: the elements of the section that may take another element style or
|
|
95
|
+
/** Family `style`: the elements of the section that may take another element style, colour scheme or size step. */
|
|
96
96
|
readonly looks?: ReadonlyArray<PageLook>;
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -260,6 +260,7 @@ export function summarizePage(layout: ReadonlyArray<SerializedNode>, ctx: PageBr
|
|
|
260
260
|
const focusLooks = walkedLooks.filter(lookInFocus);
|
|
261
261
|
const looks: LookMap = Object.fromEntries(focusLooks.map(l => [l.look.handle, {
|
|
262
262
|
id: l.nodeId, type: l.type, label: l.look.label, styles: [...(l.look.styles ?? [])], scheme: l.look.scheme !== undefined,
|
|
263
|
+
...(Object.keys(l.axes).length ? { sizes: { ...l.axes } } : {}),
|
|
263
264
|
}]));
|
|
264
265
|
for (const l of walkedLooks) nodes[l.look.handle] ??= l.nodeId;
|
|
265
266
|
const names = lookNames(focusLooks.map(l => l.look));
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ADJUSTMENTS` — the size and spacing STEPS an element may take by asking (ai-session-panel-plan `adjust`, ai-assist-plan
|
|
3
|
+
* AI2c). "Make the hero taller" is a row of this table, never a number: the model picks an axis and a step, this file is
|
|
4
|
+
* the ONLY place their style literals come from, and every value is a token of the look wherever a token exists (the
|
|
5
|
+
* section rhythm `--iox-space-section`, a framed box's padding `--iox-space-pad`) — so a re-themed site keeps its steps in
|
|
6
|
+
* proportion. The same pure functions read the current step (`adjustStepOf`) and write a new one (`adjustStyleProps`) on
|
|
7
|
+
* the server's check and in the builder's trial.
|
|
8
|
+
*
|
|
9
|
+
* Every value is a desktop-first BASE value: a width the author (or the composer) set on its own keeps its own value.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** What a step changes. */
|
|
13
|
+
export enum AdjustAxis {
|
|
14
|
+
/** How tall a section stands: fit its content · tall · one screen. */
|
|
15
|
+
Height = 'height',
|
|
16
|
+
/** The space inside: a section's rhythm above and below, a card's or panel's padding all round. */
|
|
17
|
+
Spacing = 'spacing',
|
|
18
|
+
/** Where words sit on their line: start · centre · end (logical — follows the page's direction). */
|
|
19
|
+
Align = 'align',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Which kind of element an axis acts on — a section's spacing is its rhythm, a card's is its padding. */
|
|
23
|
+
export enum AdjustKind {
|
|
24
|
+
Section = 'section',
|
|
25
|
+
Box = 'box',
|
|
26
|
+
Words = 'words',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** What a node holds when its value is none of the steps — the author's (or the composer's) own. */
|
|
30
|
+
export const ADJUST_OWN = 'own';
|
|
31
|
+
|
|
32
|
+
export interface AdjustStep {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
/** How the owner reads it on a change card. */
|
|
35
|
+
readonly label: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The steps of each axis, smallest first. */
|
|
39
|
+
export const ADJUST_STEPS: Readonly<Record<AdjustAxis, ReadonlyArray<AdjustStep>>> = {
|
|
40
|
+
[AdjustAxis.Height]: [
|
|
41
|
+
{ id: 'fit', label: 'Fits its content' },
|
|
42
|
+
{ id: 'tall', label: 'Tall' },
|
|
43
|
+
{ id: 'screen', label: 'One screen' },
|
|
44
|
+
],
|
|
45
|
+
[AdjustAxis.Spacing]: [
|
|
46
|
+
{ id: 'tight', label: 'Tight' },
|
|
47
|
+
{ id: 'normal', label: 'Normal' },
|
|
48
|
+
{ id: 'airy', label: 'Airy' },
|
|
49
|
+
],
|
|
50
|
+
[AdjustAxis.Align]: [
|
|
51
|
+
{ id: 'start', label: 'Start' },
|
|
52
|
+
{ id: 'center', label: 'Centre' },
|
|
53
|
+
{ id: 'end', label: 'End' },
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const ADJUST_AXIS_LABELS: Readonly<Record<AdjustAxis, string>> = {
|
|
58
|
+
[AdjustAxis.Height]: 'Height',
|
|
59
|
+
[AdjustAxis.Spacing]: 'Spacing',
|
|
60
|
+
[AdjustAxis.Align]: 'Alignment',
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const SECTION_SPACE = 'var(--iox-space-section)';
|
|
64
|
+
const BOX_PAD = 'var(--iox-space-pad)';
|
|
65
|
+
/** The section style's padding (`--iox-section-pad` = `var(--iox-space-section) var(--iox-space-gutter)`). */
|
|
66
|
+
const SECTION_PAD = 'var(--iox-section-pad)';
|
|
67
|
+
const SECTION_GUTTER = 'var(--iox-space-gutter)';
|
|
68
|
+
|
|
69
|
+
const scaled = (token: string, by: number) => by === 1 ? token : `calc(${token} * ${by})`;
|
|
70
|
+
|
|
71
|
+
/** A step's scale of the axis's token (spacing). */
|
|
72
|
+
const SPACING_SCALE: Readonly<Record<string, number>> = { tight: 0.5, normal: 1, airy: 1.5 };
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* THE table: per axis and kind, the style props each step writes. Spacing on a section writes only the block (top and
|
|
76
|
+
* bottom) half of its padding — the sides stay the section's own (`adjustStyleProps`).
|
|
77
|
+
*/
|
|
78
|
+
export const ADJUSTMENTS: Readonly<Record<AdjustAxis, Partial<Record<AdjustKind, Readonly<Record<string, Readonly<Record<string, string>>>>>>>> = {
|
|
79
|
+
[AdjustAxis.Height]: {
|
|
80
|
+
[AdjustKind.Section]: {
|
|
81
|
+
fit: { height: 'auto', minHeight: '0px' },
|
|
82
|
+
tall: { height: 'auto', minHeight: '70svh' },
|
|
83
|
+
screen: { height: 'auto', minHeight: '100svh' },
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
[AdjustAxis.Spacing]: {
|
|
87
|
+
[AdjustKind.Section]: Object.fromEntries(Object.entries(SPACING_SCALE).map(([id, by]) => [id, { paddingBlock: scaled(SECTION_SPACE, by) }])),
|
|
88
|
+
[AdjustKind.Box]: Object.fromEntries(Object.entries(SPACING_SCALE).map(([id, by]) => [id, { padding: scaled(BOX_PAD, by) }])),
|
|
89
|
+
},
|
|
90
|
+
[AdjustAxis.Align]: {
|
|
91
|
+
[AdjustKind.Words]: {
|
|
92
|
+
start: { textAlign: 'start' },
|
|
93
|
+
center: { textAlign: 'center' },
|
|
94
|
+
end: { textAlign: 'end' },
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** Split a CSS value on its top-level spaces (a `calc(a * b)` stays one part). */
|
|
100
|
+
export function splitCssValue(value: string): string[] {
|
|
101
|
+
const parts: string[] = [];
|
|
102
|
+
let depth = 0;
|
|
103
|
+
let current = '';
|
|
104
|
+
for (const ch of value.trim()) {
|
|
105
|
+
if (ch === '(') depth++;
|
|
106
|
+
if (ch === ')') depth = Math.max(0, depth - 1);
|
|
107
|
+
if (/\s/.test(ch) && depth === 0) {
|
|
108
|
+
if (current) parts.push(current);
|
|
109
|
+
current = '';
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
current += ch;
|
|
113
|
+
}
|
|
114
|
+
if (current) parts.push(current);
|
|
115
|
+
return parts;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** A `padding` value as its four sides (top, right, bottom, left). The section style's pad token is read as its pair. */
|
|
119
|
+
function paddingSides(value: unknown): [string, string, string, string] {
|
|
120
|
+
const raw = typeof value === 'string' ? value.trim() : '';
|
|
121
|
+
if (!raw) return ['0px', '0px', '0px', '0px'];
|
|
122
|
+
if (raw === SECTION_PAD) return [SECTION_SPACE, SECTION_GUTTER, SECTION_SPACE, SECTION_GUTTER];
|
|
123
|
+
const p = splitCssValue(raw);
|
|
124
|
+
if (p.length === 1) return [p[0], p[0], p[0], p[0]];
|
|
125
|
+
if (p.length === 2) return [p[0], p[1], p[0], p[1]];
|
|
126
|
+
if (p.length === 3) return [p[0], p[1], p[2], p[1]];
|
|
127
|
+
return [p[0], p[1], p[2], p[3]];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Four sides back to the shortest `padding`; the section style's own pair is written as its token. */
|
|
131
|
+
function paddingValue([top, right, bottom, left]: [string, string, string, string]): string {
|
|
132
|
+
if (top === SECTION_SPACE && bottom === SECTION_SPACE && right === SECTION_GUTTER && left === SECTION_GUTTER) return SECTION_PAD;
|
|
133
|
+
if (right === left) return top === bottom ? (top === right ? top : `${top} ${right}`) : `${top} ${right} ${bottom}`;
|
|
134
|
+
return `${top} ${right} ${bottom} ${left}`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const isStep = (axis: AdjustAxis, step: string) => ADJUST_STEPS[axis].some(s => s.id === step);
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The style props a step writes on a node holding `styleProps` (merged by the caller), or null when the axis does not act
|
|
141
|
+
* on that kind or the step is not one of its rows. Section spacing keeps the node's own sides.
|
|
142
|
+
*/
|
|
143
|
+
export function adjustStyleProps(
|
|
144
|
+
axis: AdjustAxis, kind: AdjustKind, step: string, styleProps: Readonly<Record<string, unknown>> = {},
|
|
145
|
+
): Record<string, string> | null {
|
|
146
|
+
const row = ADJUSTMENTS[axis][kind]?.[step];
|
|
147
|
+
if (!row || !isStep(axis, step)) return null;
|
|
148
|
+
if (axis === AdjustAxis.Spacing && kind === AdjustKind.Section) {
|
|
149
|
+
const [, right, , left] = paddingSides(styleProps['padding']);
|
|
150
|
+
const block = row['paddingBlock'];
|
|
151
|
+
return { padding: paddingValue([block, right, block, left]) };
|
|
152
|
+
}
|
|
153
|
+
return { ...row };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The step a node's current values are, or {@link ADJUST_OWN} when they are none of the rows. */
|
|
157
|
+
export function adjustStepOf(axis: AdjustAxis, kind: AdjustKind, styleProps: Readonly<Record<string, unknown>> = {}): string {
|
|
158
|
+
const rows = ADJUSTMENTS[axis][kind];
|
|
159
|
+
if (!rows) return ADJUST_OWN;
|
|
160
|
+
const value = (name: string): string => String(styleProps[name] ?? '').trim();
|
|
161
|
+
for (const { id } of ADJUST_STEPS[axis]) {
|
|
162
|
+
const row = rows[id];
|
|
163
|
+
if (!row) continue;
|
|
164
|
+
if (axis === AdjustAxis.Spacing && kind === AdjustKind.Section) {
|
|
165
|
+
const [top, , bottom] = paddingSides(styleProps['padding']);
|
|
166
|
+
if (top === row['paddingBlock'] && bottom === row['paddingBlock']) return id;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
// `height: auto` is also what an unset height is.
|
|
170
|
+
if (Object.entries(row).every(([name, want]) => value(name) === want || (name === 'height' && want === 'auto' && !value(name)))) return id;
|
|
171
|
+
}
|
|
172
|
+
return ADJUST_OWN;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** How the owner reads a step id ("own" → "As set"). */
|
|
176
|
+
export function adjustStepLabel(axis: AdjustAxis, step: string): string {
|
|
177
|
+
if (step === ADJUST_OWN) return 'As set';
|
|
178
|
+
return ADJUST_STEPS[axis].find(s => s.id === step)?.label ?? step;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Every step id of every axis — the strict format's enum (which axis takes which step is the check's). */
|
|
182
|
+
export const ADJUST_STEP_IDS: ReadonlyArray<string> = [...new Set(Object.values(ADJUST_STEPS).flat().map(s => s.id))];
|