surfaceAttrs function

Map<String, String> surfaceAttrs({
  1. required String surface,
  2. required String id,
  3. bool initiallyOpen = false,
  4. bool dismissible = true,
  5. bool escapeCloses = true,
  6. bool focusTrap = true,
  7. bool scrimCloses = true,
  8. bool restoreFocus = true,
  9. String? anchorId,
  10. String? anchorPlacement,
  11. String? anchorOffset,
  12. String? anchorAlign,
  13. String? animation,
  14. String? group,
  15. bool exclusive = false,
})

Implementation

Map<String, String> surfaceAttrs({
  required String surface,
  required String id,
  bool initiallyOpen = false,
  bool dismissible = true,
  bool escapeCloses = true,
  bool focusTrap = true,
  bool scrimCloses = true,
  bool restoreFocus = true,
  String? anchorId,
  String? anchorPlacement,
  String? anchorOffset,
  String? anchorAlign,
  String? animation,
  String? group,
  bool exclusive = false,
}) {
  final Map<String, String> out = <String, String>{
    'data-arcane-surface': surface,
    'data-arcane-id': id,
    'data-arcane-state': initiallyOpen ? 'open' : 'closed',
  };
  if (!dismissible) out['data-arcane-dismissible'] = 'false';
  if (!escapeCloses) out['data-arcane-escape-closes'] = 'false';
  if (!focusTrap) out['data-arcane-focus-trap'] = 'false';
  if (!scrimCloses) out['data-arcane-scrim-closes'] = 'false';
  if (!restoreFocus) out['data-arcane-restore-focus'] = 'false';
  if (anchorId != null && anchorId.isNotEmpty) {
    out['data-arcane-anchor'] = anchorId;
  }
  if (anchorPlacement != null && anchorPlacement.isNotEmpty) {
    out['data-arcane-anchor-placement'] = anchorPlacement;
  }
  if (anchorOffset != null && anchorOffset.isNotEmpty) {
    out['data-arcane-anchor-offset'] = anchorOffset;
  }
  if (anchorAlign != null && anchorAlign.isNotEmpty) {
    out['data-arcane-anchor-align'] = anchorAlign;
  }
  if (animation != null && animation.isNotEmpty) {
    out['data-arcane-animation'] = animation;
  }
  if (group != null && group.isNotEmpty) {
    out['data-arcane-surface-group'] = group;
  }
  if (exclusive) out['data-arcane-exclusive'] = 'true';
  if (!initiallyOpen) out['hidden'] = '';
  return out;
}